Integration with an external messenger
You can set up integration with an external messenger using webhooks. A webhook is sending requests based on events.
Integration setup
Create a channel of the "Page messenger" type.
In the control panel, go to the “Channels" section and click the "Add channel" button located in the upper right corner of the screen.

Next, in the "Add channel" window, select the channel type "Page messenger.”

Specify any required parameters below and click "Add channel.”

More about creating channels in the article "Communication Channels | Channels".
Create AI for incoming messages.
To create AI, go to the "AI" section and click the "Create AI.”

More in the article "Creating and configuring AI | AI".
Create an integration of the "All messages" type to receive webhooks about new messages.
To create an integration of the "All messages" type, go to the "Integrations" section and click the "Create integration.”

In the "Add integration" window, select the integration type "Another.”

In the "Name" field, enter a name. In the "webhook url" field, enter the URL to receive webhooks. Then in the dropdown list "Select webhook type" select "All messages". Click "Create integration.”

More in the article 'Integrations | Integration.'
Create a task of the "Web" type.
To create a task of the "Web" type, go to the "Tasks" section and click the "Create task.”

In the "Create task" window, in the "Type" dropdown, select "Web.”

Next, select the service operation format, the previously created channel, manager, AI, integration, and click the "Create task.”

After creation, copy the task id, you will need it for API requests.
More in the article "Tasks | Tasks".
Integrate the method for sending a message from the user to AI https://docs.selarti.com/#d0d66a94-eebd-4095-b5fe-f58b31b1ab28. Pass the unique user identifier, for example, Telegram user_id, in chat_id. The dialog context will be combined by this id, and you will be able to identify webhooks.
Receive a webhook after the AI generates a message and send the message to the user in the dialog.
List of parameters and description
channel_id
id of the channel. Used to identify the specific channel through which communication is carried out. May be useful for routing and processing messages on your side.
close
Dialog closed/not closed. Used to indicate the closing of a dialog or completion of communication. It signals the end of the communication session with the user or the closure of a specific task.
company_id
company id. Used to identify the organization to which the incoming message or command belongs. Allows accurate processing of data in the context of a specific company or department within the system.
contacts
Contact. Used to transmit contact information, such as phone, username, etc. Allows automatic updating and synchronization of contact data between systems.
external_chat_id
dialog id. Used to identify a specific chat or dialog in an external system or messenger. Allows linking messages and interactions with the required external dialog.
get_contact
Contact received/not received. Informs that the user sent a phone, email, etc. in the dialog.
interest
Interest shown yes/no. Used to indicate the client's interest or activation of interest in a specific product or service.
is_bot
Dialog is with a bot yes/no. If yes, our system has determined that this dialog is with a bot.
manager_id
manager id. Used to identify the specific manager associated with the task or interaction.
message_id
message id. Used for the unique identification of a specific message. Allows you to track, process, and refer to specific messages in the system.
message_text
Message text. Used to transmit the message text. It allows you to receive and process the content of the message sent by the user or system in the required format.
message_type
Message type bot/operator/user.
operator
Dialog transferred to operator yes/no.
panel_url
Link to the dialog in the personal account with the ability to reply to the user.
share_url
Link to the dialog for viewing only, without the ability to reply.
success
Dialog is successful yes/no.
task_id
task id. Used for the unique identification of a task in the system.
thread_id
thread id. Used to identify the dialog with the user.
title
Title. Full name of the user.
wh_type
Webhook type. Indicates the type of webhook, events, or actions. It helps to distinguish which event occurred or what information is being transmitted via the webhook for appropriate processing.
Webhook example:
{
"channel_id": "5q",
"close": "no",
"company_id": "1708251850060x460235863640434700",
"contacts": "123456789",
"external_chat_id": "123456789", // Your dialog id, you can identify by it
"get_contact": "no",
"interest": "no",
"is_bot": "no",
"manager_id": "4q",
"message_id": "1731336491876x582725124419040400",
"message_text": "It looks like you are testing API functionality by sending a test message along with metadata like a timestamp and timezone. If you have any questions or need assistance with this, feel free to ask!",
"message_type": "bot", // Send only bot and operator types to the dialog with the user. You can ignore a webhook with the user type by responding with status 200
"operator": "no",
"panel_url": "https://selarti.com/panel?menu=chats&thread=1731336491572x316716105037601100",
"share_url": "https://selarti.com/share?thread=1731336491572x316716105037601100",
"success": "no",
"task_id": "1721129985149x478019552540622850",
"thread_id": "1731336491572x316716105037601100",
"title": "API chat 123456789",
"wh_type": "all_messages" // Set up processing only for this type of webhook, as webhooks of other types may be sent to your url
}
Try replying to the user through your personal account.
Last updated