Skip to main content

Webhook & AWS SQS

With Webhook and AWS SQS integrations, you can take full control over your chatbot sessions. This integration is ideal if your chatbot requires custom handling of conversations and you can build a service to analyze events and generate responses.

Overview

Webhooks and AWS SQS (Amazon Simple Queue Service) are methods that allow the chatbot service to send chat events to your application. By integrating these, you can:

  • Receive updates about the chatbot session as they happen.
  • Process user messages and generate dynamic responses.
  • Control the conversation flow by sending commands back to the chatbot.

What Are Webhooks?

Webhooks are HTTP callbacks that occur when specific events happen. When the chatbot service detects an event (like a user sent a message), it sends an HTTP POST request to your application’s endpoint with details about that event.

What Is AWS SQS?

AWS SQS is a message queuing service that allows applications to send, store, and receive messages between software components. The chatbot service can send event messages to an SQS queue, which your application can read and process.

How It Works

When integrating webhooks or AWS SQS with your chatbot, the communication flow between the user, the chatbot service, and your application typically looks like this:

Events

The chatbot service sends different types of events to inform your application about the session’s state.

chat:channel:created

Triggered when a new chat channel is created. You can use the WebhookChatChannelCreatedEvent provided by @wildix/xbees-conversations-client for TypeScript definitions.

Example
{
"id": "12345678-abcd-1234-efgh-1234567890ab",
"type": "chat:channel:created",
"company": "demo_company_12345",
"time": 1719842806700,
"integrationId": "demo_integration_01",
"data": {
"channel": {
"channelId": "demo_channel_001",
"channelType": "group",
"memberCount": 3,
"subject": "Demo Subject",
"description": "This is a demo description.",
"access": "private",
"company": "demo_company_12345",
"service": "demo_service",
"serviceTitle": "Demo Service Title",
"broadcast": false,
"external": true,
"createdAt": "2024-07-01T14:06:43.386258Z",
"updatedAt": "2024-07-01T14:06:43.386258Z"
},
"members": [
{
"id": "demo_member_01",
"createdAt": "2024-07-01T14:06:43.389522Z",
"role": "member"
},
{
"id": "demo_member_02",
"createdAt": "2024-07-01T14:06:43.389522Z",
"role": "member"
}
],
"users": [
{
"id": "demo_user_01",
"name": "John Doe",
"email": "john.doe@example.com",
"picture": "https://example.com/avatar1.png",
"company": "demo_company_12345",
"bot": false,
"pbxExtension": "1001",
"pbxSerial": "demo_serial_001",
"pbxUserId": "user_001",
"createdAt": "2022-12-27T22:58:32.370401Z",
"updatedAt": "2022-12-27T22:58:32.370401Z"
},
{
"id": "demo_user_02",
"name": "Jane Smith",
"email": "jane.smith@example.com",
"locale": "en",
"timeZone": "Europe/London",
"company": "demo_company_54321",
"bot": false,
"pbxDomain": "example.com",
"pbxPort": "443",
"pbxExtension": "1002",
"pbxSerial": "demo_serial_002",
"pbxUserId": "user_002",
"createdAt": "2022-06-06T13:52:46.29224Z",
"updatedAt": "2022-12-24T12:22:48.951455Z"
}
]
}
}

chat:message:new

Triggered when a new message is sent in a chat channel.

Example
{
"id": "demo5678-9101-1121-3141-516171819203",
"type": "chat:message:new",
"company": "demo_company_12345",
"time": 1719844426953,
"integrationId": "demo_integration_06",
"data": {
"channel": {
"channelId": "demo_channel_006",
"channelType": "group",
"memberCount": 3,
"subject": "Demo New Subject",
"description": "This is a demo updated description.",
"access": "private",
"company": "demo_company_12345",
"service": "demo_service",
"serviceTitle": "Demo Service Title",
"broadcast": false,
"external": true,
"createdAt": "2024-07-01T14:06:43.386258Z",
"updatedAt": "2024-07-01T14:27:33.375099Z"
},
"members": [
{
"id": "demo_member_01",
"createdAt": "2024-07-01T14:06:43.389522Z",
"role": "member"
},
{
"id": "demo_member_02",
"createdAt": "2024-07-01T14:06:43.389522Z",
"role": "owner"
},
{
"id": "demo_member_03",
"createdAt": "2024-07-01T14:29:41.919174Z",
"role": "member"
}
],
"users": [
{
"id": "demo_user_01",
"name": "John Doe",
"email": "john.doe@example.com",
"picture": "https://example.com/avatar1.png",
"company": "demo_company_12345",
"bot": false,
"pbxExtension": "1001",
"pbxSerial": "demo_serial_001",
"pbxUserId": "user_001",
"createdAt": "2022-12-27T22:58:32.370401Z",
"updatedAt": "2022-12-27T22:58:32.370401Z"
},
{
"id": "demo_user_02",
"name": "Alice Johnson",
"email": "alice.johnson@example.com",
"locale": "en",
"timeZone": "Europe/Berlin",
"company": "demo_company_12345",
"bot": false,
"pbxDomain": "example.com",
"pbxPort": "443",
"pbxExtension": "1003",
"pbxSerial": "demo_serial_003",
"pbxUserId": "user_003",
"createdAt": "2022-05-23T12:38:10.574336Z",
"updatedAt": "2024-06-29T10:09:39.101619Z"
},
{
"id": "demo_user_03",
"email": "john.travolta@example.com",
"bot": false,
"createdAt": "2022-12-27T19:00:22.677386Z",
"updatedAt": "2022-12-27T19:00:22.677386Z"
}
],
"message": {
"messageId": "demo_message_001",
"channelId": "demo_channel_006",
"type": "regular",
"text": "Hi",
"attachments": [],
"mentions": [],
"giphy": null,
"latestReactions": [],
"reactionCounts": {},
"createdAt": "2024-07-01T14:33:46.794077Z",
"user": {
"id": "demo_user_02",
"name": "Alice Johnson",
"email": "alice.johnson@example.com",
"locale": "en",
"timeZone": "Europe/Berlin",
"company": "demo_company_12345",
"bot": false,
"pbxDomain": "example.com",
"pbxPort": "443",
"pbxExtension": "1003",
"pbxSerial": "demo_serial_003",
"pbxUserId": "user_003",
"createdAt": "2022-05-23T12:38:10.574336Z",
"updatedAt": "2024-06-29T10:09:39.101619Z"
},
"quote": null,
"forward": null,
"sms": false,
"silent": false,
"event": null
}
}
}

* For a comprehensive list of events, please refer to the Webhooks documentation.

Commands

Your application can control the voice bot by sending commands over HTTP API and SDK.

Adds members to an existing channel. This operation is idempotent, meaning that if a member already exists in the channel, the operation will still return a successful response.
Retrieves a presigned URL for downloading a specific file from a message in a specified channel.
Sends a message to a specified channel. This operation requires the channel to be accessible to the user.
Sends a typing start event to a specified channel. This operation requires the channel to be accessible to the user.
Sends a typing stop event to a specified channel. This operation requires the channel to be accessible to the user.
Create a presigned URL for file upload in the channel.