Customizable notifications in Telegram
If Suvvy's standard notifications don't suit you, you can set up notifications in your TG bot using the Webhooks mechanism.
To set up custom alerts for your Telegram bot, follow a few simple steps:
Create a bot in BotFather.
You can find detailed instructions on how to create a bot in BotFather in the Telegram manual section.
Get the chat id (chat_id) to which notification messages will be sent.
a. If you want to receive notifications in the bot, you must obtain your personal user_id, which will also be used as your chat_id in the future. You can learn how to obtain your personal user_id by following this link.
b. If you want to receive notifications in a group, you need to get the chat_id of the group to which notifications will be sent.
Instructions on how to get a group's chat_id.
Step 1: Add your bot to the group
Open Telegram.
Go to the desired group.
Add your bot as a regular member.
Assign it as an admin (if you want it to be able to post messages to the group).
Step 2: Write any message to the group
Anything—whether it's a "test" from yourself or something else entirely. This is necessary to get the group active.
Step 3: Get updates via the Telegram Bot API
In your browser, enter the following URL:
https://api.telegram.org/bot<ТВОЙ_ТОКЕН>/getUpdates
Where <YOUR_TOKEN> is the token of your TG bot.
Example:
https://api.telegram.org/bot123456789:ABCDEF1234567890abcdef12345678/getUpdatesThe response will be JSON, which will contain something like:
{
"update_id": 123456789,
"message": {
"chat": {
"id": -1001234567890,
"title": "Название группы",
"type": "supergroup"
},
...
}
}Step 4: Use the chat_id from the response
chat_id from the responseHere is this id:
-1001234567890— and there's the group's chat_id. It's always negative.
In Savvy, go to Workflows and click Add:

Select Webhook from the list:

Filling in the function fields

Add arguments and constants that will be passed to the webhook:


Arguments are variables that the bot will generate during the conversation. They depend on the user's responses. Constants are parameters that will be passed to the webhook invariably. In our case, the bot name will always be passed to the webhook, such as "Bot - Elsa."
Configure the Webhook step:

Paste the URL into the field: https://api.telegram.org/bot<YOUR_TOKEN>/sendMessage , where <YOUR_TOKEN> is your Telegram bot's token obtained when creating the bot through BotFather.
Request method: POST
Body type: JSON
We write the Request Body in JSON format:
Example:

Please note that arguments to the Request Body are added using the ➕ sign on the right side of the input field:

❗️ Arguments in curly brackets must be replaced with arguments added through ➕.
Click Save:

Now that we've configured the Action to send a notification to our TG, we need to add instructions to the central prompt for the bot, telling it how to generate arguments and when to pass them to the webhook sending function.
Where can we get the parameters {contact_id}, {lead_id}, {manager_id}, {origin} and {source} from the example above if we did not generate them during the dialogue?
In addition to arguments generated during the dialogue from the client's responses, the bot can pass parameters located in placeholders to the function.
Placeholder parameters can be found in the dialog export at the very top of the page. It looks like this:

Depending on the connected channel, the parameters passed to placeholders may differ. The easiest way to find out what parameters we can pass to our function from placeholders is to export the dialog and check which parameters are passed to the Bot.
Structuring Messages
If your notification text is quite long, it's best to set it up so that each line is on a new line to make the information easier to read. You can set up text wrapping for this purpose.
Settings
In the action, you need to add a Constant containing the line feed operator "\n".

Next, in the body of the request, before the first word of the phrase, which should be on a new line, you need to add a constant with a hyphenation operator.

After these actions, phrases that were preceded by the hyphenation operator will start on a new line.
Last updated