According to the messenger policy, bots cannot send messages first. In order for the user to receive notifications from the bot, he must somehow interact with the bot and send him at least some initial message.

The easiest way to do this is on the site / application side, you need to create a button "I want to receive notifications in the messenger" (or "follow the status of the order in the messenger", "select a support channel" and etc), that the person will click and initiate a contact with a bot.

In this button, the starting parameter can contain the customer_id of the customer in your CRM / ERP and the bot will return the chat_id and the communication channel chosen by the customer so that you can continue to send him notifications. In this script, the bot does nothing other than saying "Great, now I will inform you of all the news on your order, if you want help - click "connect with the operator".

Passing a start parameter (deeplink)

There are mechanisms in messengers that allow you to pass input parameters to the bot. These mechanisms are called deeplinks and are a way to sew a parameter into a link that will open a bot.

In the starting parameter, you can pass the id of the client, order, and etc. In general, anything that will allow you to match data from your site / application with a pair of chat_id + channel from the bot later.

Thus, you need to generate links to your bots indicating the input parameter and ask the user to click on the link and start communicating with the bot.

If you do not need to use the user id in the bot in an external system (for example, identify), you can not pass any parameters, but simply send the user to the bot to take the first steps and save the chat_id + channel in the CRM / application.

<aside> ⚠️ When using a Facebook and Viber deeplink, it sends a command start. Consider this if you are branching your script with with get_commandaction

</aside>

Getting a start parameter for use in a script

If you want to use a start parameter in your script, use the get_command action

It will process a command like /commandname or passed through deeplink, if a parameter is passed, sets the constant {{messenger_input_param}}

Return chat_id and channel back to the application

After the first message from the user, for example, clicking the "Start" button in Telegram, the bot must return a couple of parameters back to the application (website, CRM, etc.), namely