This function allows you to launch the bot via API from any other service.

Why is it needed

Example: a user got into an online school bot.

The bot told about the courses, and the client went to the site. Bought one of the courses there. If you set up webhook integrations in the course learning platform, then the bot will write to the client itself.

That is, with the help of a webhook, another service can launch the desired Smartbot Pro script chain.

Creating and configuring a webhook

  1. We create a token

You can create a new token and see a list of all project tokens in the Integrations section.

To run the bot, you need to create a token with the right to execute blocks. Click "Generate Token" and select "Access Level - Block Execution".

2. Create a "Webhook" event in the script

In the script to start the chain from another service, you need to set up a special Webhook event that will allow you to launch the bot via the API.

Go to the desired scenario, select "Events" --> "Webhook" in the side menu.

3. Specify the token

In the Webhook block, select the created token or create a new one.

4. Choose a channel

Select a channel on the social network where the bot will work after you "pull" it with a webhook.

If the bot works simultaneously in the LAN and in the conversation, you must also specify the desired chat:

5. Request parameters: URL and body.

Copy the specified URL and send a POST request to it from your service.

Copy the following JSON and paste it into the Request Body:

peer_id is the ID of the chat to which the message from the bot will be sent

  • If the bot should work in a group chat, then the peer_id will be set automatically

  • If the bot should work in the LAN, then the peer_id must be filled in independently in accordance with the prompt

Requirements for sending a message via Webhook

For a user to receive a message via a webhook, two conditions must be met:

  • allowed to send messages to PM

  • the user has already communicated with the bot (the bot cannot be the first to write to the user)

Deleting a token

If the token is stolen by an attacker, it must be deleted in the Integrations section.

Last updated