How to create a communication flow using Coversation API
Routee Voice Conversation API can be used to create communication flows as per your desire.
Let's suppose that you want to create a communication flow as described below:
- BOT to pick phone number of employee from your application
- BOT sends Routee API the phone number and message to be delivered to employee and do
the following
a. Place call
b. Send text to voice message with ticket details
c. Provide options to employee
i. Press 1 to accept
ii. Press 2 to reject
d. Wait for response from Employee over call
e. If there is no response for 10 seconds, re run the message and provide same options
f. If still there is no response, provide status as No answer
g. If the employee selects 1, provide status as Accepted - If the employee doesn’t response over call, attempt the call thrice to the employee.
- If the employee does not pick call or does not respond all three times, pick next available
employee’s number and place a call with message. Repeat actions from step 2 until the
response status is Accepted
Let's see how this can be done using Routee API
Step 1: Place a call.
In order to initiate a call you need to consume the following endpoint:
Step 2: Send a text to speech message
The above endpoint has a verbs array. This array contains object. Every object refers to an action. The verb which is dedicated to send text to speech messages is the verb “SAY”.
You can find more information about it at the following url:
Step 3: Create the desired flow.
The dialPlan.verbs array can contain more than one “SAY” verb. In order to achieve the flow which is described you have to add in the dialPlan.verbs array the following verbs:
“PAUSE”: This verb is responsible to add a pause, for a specific duration, to the call.
(https://docs.routee.net/v1.0/reference#collect-verb)
“SAY”: The say verb will turn a text message into voice. (At the first on you can add the details of your ticket)
Then you can add a short duration “PAUSE” verb in order to have a better cohesion in your flow.
Finally add a new “SAY”, which will be responsible to inform the recipient about the options he has.
(Press 1 to receive the call or press 2 to reject it).
Step 4: Collect the DTMF which is pressed during the call.
In order to collect the DTMF, you need to add a “COLLECT” verb.
(https://docs.routee.net/v1.0/reference#collect-verb)
This verb contains an eventUrl. Here you have to define the public url in which information for the pressed DTMF will be posted at. The payload of this post request can be found here:
https://docs.routee.net/docs/webhooks-callbacks#section--collect-verb-eventurl-
If you wish to send the payload with the information to the eventUrl, immediately when the recipient presses a button, then you should set, into the say verb, the variable “bargeIn” as true.
Step 5: Check the real-time status of your call.
In order to retrieve real-time information about the status of an active call you need to set into your body request a callback object.
This callback object contains two variables.:
● callback.url
● callback.strategy
At the “callback.url” have to be set the public url in which the information about the status of the call will be posted there.
The different status of a voice call can be found at the following URL:
https://docs.routee.net/docs/voice-messaging-statuses#section-voice-message-statuses-
The second parameter is the callback.strategy. The callback strategy can be set as OnChange or as OnCompletion. The value OnChange means that every time the status of your call is changing a new payload will be posted at your callback URL. The value OnCompletion means that you will receive information about the call when the call is finished.
The payload of the status callback can be found here at the following URL:
https://docs.routee.net/docs/webhooks-callbacks#section--status-callback-url-
The actual payload for your case.
curl -X POST \
https://connect.routee.net/voice/conversation \
-H 'Content-Type: application/json' \
-H 'authorization: Bearer 3330fa348-245d1-46ege-b27s6-b01223637ead3' \
-H 'cache-control: no-cache' \
-d '{
"from": "123",
"to": {
"phone": "+30697xxxxxxx"
},
"dialPlan": {
"verbs": [{
"type": "PAUSE",
"duration": 3
}, {
"type": "SAY",
"message": {
"text": "here you can define your ticket",
"gender": "male",
"language": "en-US"
}
}, {
"type": "PAUSE",
"duration": 4
}, {
"type": "SAY",
"message": {
"text": "PRESS ONE TO BE CONNECTED THERE OR PRESS 2 TO BE CONNECTED THERE",
"language": "en-US",
"gender": "female"
},
"bargeIn": true
}, {
"type": "PAUSE",
"duration": 10
}, {
"type": "SAY",
"message": {
"text": "PRESS ONE TO BE CONNECTED THERE OR PRESS 2 TO BE CONNECTED THERE",
"language": "en-US",
"gender": "female"
},
"bargeIn": true
}, {
"type": "PAUSE",
"duration": 6
}, {
"type": "COLLECT",
"eventUrl": "https://eventUrl.com"
}]
},
"callback": {
"url": "https://statusCallback.com",
"strategy": "OnChange"
}
}'
Step 6: Call three times to employee.
In order to achieve this, you need to check the status of the call and to keep a counter for it when it’s failing. When you initiate the call you have to increase this counter.
To finalize, this is a thorough example of how a company could take advantage of Routee Conversation API to create a complete communication flow in order to better serve their customer base.
Routee API offers limitless possibilities for you to create the communication flow that will better suit your needs, all our services can be combined easily.
Updated over 5 years ago