To enable your bot to reply in private chats through a business connection in n8n, you must use the HTTP Request node to send requests to the Telegram API, specifying the business_connection_id parameter. This parameter is required to identify the business connection and facilitate sending messages in private chats.
Setup Steps:
Extract Necessary Data:
From the JSON response received from Telegram, extract business_connection_id and chat.id.
Configure the HTTP Request node in n8n:
Add the HTTP Request node to your workflow.
Set the request method to POST.
In the “URL” field, specify the Telegram API endpoint for sending messages:
https://api.telegram.org/bot<TOKEN>/sendMessage
replacing <TOKEN> with your bot’s actual token.
In the “Body Parameters” section, include these parameters:
chat_id: {{$json["business_message"]["chat"]["id"]}}
text: Your response message
business_connection_id: {{$json["business_message"]["business_connection_id"]}}
Example configuration of the HTTP Request node: Method:POST Body Parameters:
chat_id: {{$json["business_message"]["chat"]["id"]}}
text: Your reply to the incoming message
business_connection_id: {{$json["business_message"]["business_connection_id"]}}
Hello.
I can’t replicate this with my parameters.
I’m not a coding expert. Could you please point out what I did wrong?
Error code 400
Bussines Mode - turn on
Privacy Mode - turn off
This is because you put your body content in the field called “Body Content Type”. Delete all this, select JSON in that field and then create 3 pairs of name/value parameters with the data (e.g. name=chat_id and value=your expression).