Introduction
Description: You can place a call - initiated as Outbound - to a specific destination and, when answered, it will be treated as a regular Inbound Queue Call, waiting in the Queue to be answered by an agentThis section details how to build a chatbot application by using the Sangoma CX WebChat widget, becoming the user interface for the end-customer to interact with the chatbot. We will use the Sangoma Digital Interactions API to handle the backend logic to communicate/integrate with the chatbot.
scope: cx.queue-calls
API Request
Code Block |
---|
curl -XPOST --location 'https://cpaas.sangoma.com/cx/api/v1/queues/call/' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <YOUR_ACCESS_TOKEN>' \
--data '{
"queue_name": "queue_test",
"destination": "9001",
"tenant_domain": "acme.cx.sangoma.com"
}' |
Note: Replace digital-interactions
Integration Flow
Note: In the API Request sections, replace <YOUR_ACCESS_TOKEN>
with your Access Token obtained from the Requesting Access Token authentication step .
This API call will enable the specified Queue (queue_name
) within the tenant_domain
to make calls to the provided destination
.
Creating a Agent Chatbot using Sangoma Digital Interactions API (Our Widget)
scope: cx.digital-interactions
In this section, we will build a chatbot application using a inbox web widget that starts a conversation on your front panel. We will use the Sangoma Digital Interactions API to handle the backend logic for this chatbot.
detailed in API Authentication .
1. Create the agent bot
To receive events from Sangoma CX, you need to set up a agent bot. This requires a publicly accessible FQDN. For development purposes, you can use a tool like ngrok. We will use the outgoing_url
to send webhook events, so certify that . Confirm this is public publicly accessible.
API Request
Code Block |
---|
curl -XPOST --location 'https://cpaas.sangoma.com/cx/api/v1/digital-interactions/agent-bot/' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'Authorization: Bearer <YOUR_ACCESS_TOKEN>' \ --data '{ "tenant_domain": "acme.cx.sangoma.com", "outgoing_url": "<your webhook fqdn>", "name": "My first bot" }' |
2. Choosing an Inbox
You can choose which inbox your chatbot is attached “assigned” to. In order to list the inboxes you can use the following request.
...
API Request
Code Block |
---|
curl --location 'https://cpaas.sangoma.com/cx/api/v1/digital-interactions/inboxes/' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'Authorization: Bearer <YOUR_ACCESS_TOKEN>' |
3.
...
Assigning the agent bot to the inbox
After choose choosing the inbox, you should attach assign the agent bot to that inbox using the following request.
API Request
Code Block |
---|
curl -XPOST --location 'https://cpaas.sangoma.com/cx/api/v1/digital-interactions/assign-agent-bot/' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'Authorization: Bearer <YOUR_ACCESS_TOKEN>' \ --data '{ "tenant_domain": "acme.cx.sangoma.com", "inbox_id": "<inbox_id>", "agent_bot_id": "<agent_bot_id>" }' |
Now Now you can start your conversation using the web widget.
4. Sending Messages
Once the conversation is created, you can start sending messages.
API Request
Code Block |
---|
curl -XPOST --location 'https://cpaas.sangoma.com/cx/api/v1/digital-interactions/messages/' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'Authorization: Bearer <YOUR_ACCESS_TOKEN>' \ --data '{ "tenant_domain": "acme.cx.sangoma.com", "content": "My message", "message_type": "outgoing", "conversation_id": <conversation.id> }' |
6.
...
Redirect to a Customer Representative
If the customer needs human assistance, redirect the conversation to an inbox with agents that will interact with the customer representative.
API Request
Code Block |
---|
curl -XPOST --location 'https://cpaas.sangoma.com/cx/api/v1/digital-interactions/conversations/deliver-to-agent/' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'Authorization: Bearer <YOUR_ACCESS_TOKEN>' \ --data '{ "tenant_domain": "acme.cx.sangoma.com", "conversation_id": <conversation.id> }' |
...
You can choose whether your chatbot will use a unique inbox or if the customer can choose one. This is useful for creating different flows based on the selected inbox.
List Inboxes
Code Block |
---|
curl --location 'https://cpaas.sangoma.com/cx/api/v1/digital-interactions/inboxes/' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'Authorization: Bearer <YOUR_ACCESS_TOKEN>' |
...
Note: If the message_type
is outgoing
, it will be presented as a bot message; if incoming
, it will be a customer message. The default value is outgoing
.
6. Deliver to a Customer Representative
If the customer needs human assistance, redirect the conversation to an inbox customer representative.
...