CTRLK

Shared components

Package multiple CML actions

|

View as Markdown

CML actions provided by your callback webhooks must be included in an actions object, whether the actions object contains a single action or multiple actions. An actions object is a JSON array of CML instructions.

The following example CML actions play text-to-speech content, play an audio file, then hang up the call.

json
1{
2 "actions": [
3 {
4 "action": "say",
5 "text": "Hello! This is Smile Dental calling to remind you of your appointment tomorrow at 10 AM.",
6 "language": "en",
7 "voicePreferences": { "voiceGender": "FEMALE", "voiceName": "Joanna" }
8 },
9 {
10 "action": "play",
11 "content": {
12 "type": "URL",
13 "fileUrl": "https://example.com/content/generic.mp3"
14 }
15 },
16 { "action": "hangup" }
17 ]
18}

Execution flow and control transfer

CML actions run in sequence, but some actions (fetch, captureDtmf, dial) can transfer control to a new set of CML actions. This causes any subsequent actions defined in the initial set to be skipped.

In the following example, the second say action is never executed because the fetch action transfers control to a new set of actions.

json
1{
2 "actions": [
3 {
4 "action": "say",
5 "text": "Hello! This is Smile Dental calling to remind you of your appointment tomorrow at 10 AM.",
6 "language": "en",
7 "voicePreferences": {
8 "voiceGender": "FEMALE",
9 "voiceName": "Joanna"
10 }
11 },
12 {
13 "action": "fetch",
14 "url": "https://example.com/cml/next",
15 "method": "POST"
16 },
17 {
18 "action": "say",
19 "text": "Thank you for your call.",
20 "language": "en",
21 "voicePreferences": {
22 "voiceGender": "FEMALE",
23 "voiceName": "Joanna"
24 }
25 }
26 ]
27}

If the fetch action fails (webhook not available or malformed CML actions returned), the Infobip platform sends the error to your errorUrl (on the CML configuration or as defined in the action). If the errorUrl does not return correct CML actions, the call is hung up.

DTMF capture exception

The captureDtmf action is an exception to the control transfer behavior. Consider the following actions:

json
1{
2 "actions": [
3 {
4 "action": "say",
5 "text": "Hello! This is Smile Dental calling to remind you of your appointment tomorrow at 10 AM.",
6 "language": "en",
7 "voicePreferences": {
8 "voiceGender": "FEMALE",
9 "voiceName": "Joanna"
10 }
11 },
12 {
13 "action": "captureDtmf",
14 "maxLength": 1,
15 "timeout": 6,
16 "terminator": "#",
17 "callback": {
18 "url": "https://example.com/cml/dtmf",
19 "method": "POST"
20 },
21 "say": {
22 "action": "say",
23 "text": "Press 1 to confirm, 2 to reschedule, or 9 to talk to a receptionist.",
24 "language": "en"
25 }
26 },
27 {
28 "action": "hangup"
29 }
30 ]
31}

If the end user does not respond to the DTMF prompt during the defined timeout period and the captureDtmf action does not use the callOnEmpty flag, then the next action runs (in this case, hangup).


Was this page helpful?