SmartbotPro
  • Smartbot Pro – messenger marketing tool
  • Most important
  • Mini-course
    • Registration and personal account
    • Initial scripting tools
    • Creating the first script
    • Users and collection of information
    • Applications, variables and managers
    • Data validation
    • Collection of applications for a webinar within Telegram
    • Testing unpublished scripts
    • Newsletters
    • Template "Test with a set of points"
    • Statistics
    • Interface hacks
  • Beginning of work
    • Registration in the service
    • More about scripts
    • How to add messenger
      • Adding Telegram
        • Adding a bot to a group chat in Telegram
      • Adding ВК
      • Adding Viber
      • Connecting a channel to a script
      • Linking a social network account
  • Scripts
    • Basics
      • Create a script
      • Script templates
      • Editor interface
      • Publishing a script
      • Script testing
      • How the script is chosen
    • Script events
      • Message from user
      • No appropriate script
      • First message
      • VK Events
      • Webhook
    • Actions
      • Send a message
        • Buttons
      • Process message
      • Extract data
      • Change context
      • Write to statistics
      • Send Notification
      • Switching to another script
      • Working with the user
      • Set variable
      • Scheduled transitions
      • Run SmartQuery
    • Conditions
      • Condition
      • Condition with options
      • Conditions of VKontakte
    • Variables
      • Special Variables
      • User variables
      • Global variables
      • Variable %ref%
    • Acceptance of payment
    • Telegram bot menu
    • Integrations
      • Google-таблицы
      • http request
      • amoCRM
      • Get Course
      • Yukassa for receiving payments
    • Reactions
  • Newsletters
  • Settings
    • Projects
    • Cabinets
  • Information sections
    • Statistics
    • Users
  • SmartQuery
    • Introduction
    • Language syntax
    • Function Reference
  • The documents
    • Privacy Policy
    • Terms of service
    • Subscription and rates
Powered by GitBook
On this page
  • Why is it needed
  • Creating and configuring a webhook
  • Requirements for sending a message via Webhook
  • Deleting a token
  1. Scripts
  2. Script events

Webhook

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

PreviousVK EventsNextActions

Last updated 2 years ago

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.

: