-
Notifications
You must be signed in to change notification settings - Fork 3
Send voice message
The action "send voice" is divisible into four main steps. Those conclude (in correct order): IFTTT registers a trigger and sends a https request to the voice endpoint of this API (with predefined attributes). From there on this API converts the data gotten from the request into a format CM can understand. Consequently this API sends a https request to CM. And finally CM handles the sending of a voice notification.
IFTTT send a https request to our API. This request contains a body (configured in the IFTTT service). For the voice action it looks like the following.
{
"actionFields": {
"sender": "0031687654321",
"receiver": "0031612345678",
"body": "This is a sample message",
"language": "nl",
"token": "1t2o3k4e5n",
"username": "sampleUsername",
"key": "1s2h3a4r5e6d7k8e9y"
},
"ifttt_source": {
"id": "2",
"url": "https://ifttt.com/myrecipes/personal/2"
},
"user": {
"timezone": "Pacific Time (US & Canada)"
}
}
The action fields hold the data of the voice message. The IFTTT source fields hold metadata from IFTTT.
Now we have got this data we can convert it into a format that is usable for CM. When we want to send a voice message using CM's API we need to use the following format.
{
"callee": "0031612345678",
"caller": "0031687654321",
"anonymous": false,
"prompt": "This is a sample message",
"prompt-type": "TTS",
"voice": {
"language": "en-GB",
"gender": "Male",
"number": 1
}
}
So this API converts the gotten data from the IFTTT request into something like seen above.
Next we send a https request to the the voice endpoint of CM's API to execute the voice message. The body of our request consists of the JSON body as seen above. We also add authorisation as seen in the code below.
{
url: "https://voiceapi.cmtelecom.com/v2.0/Notification",
headers: {
"X-CM-PRODUCTTOKEN" : voiceObject.token,
"Authorization" : Buffer.from(voiceObject.username + ":" + voiceObject.key).toString('base64'),
},
method: "POST",
json: true,
body: cmVOICE
}
cmVOICE being the JSON object from section 3. The voice endpoint of CM requires a basic authorisation using the username and the secret key. We have used a node package for sending https request which makes things very easy.
And now the rest is on CM! We have send the https request with the gotten data to their specified endpoint. You should expect a call very soon!
- 1.1 Home
- 1.2 Getting started
- 2.1 Send sms
- 2.2 Send voice message
- 2.3 Send hybrid message
- 2.4 Add contact