3 ms·
The Twilio Erlang library has a built in Extended TWIML library that is compiles to a human readable statement of the state machine and the state machine that i
by gordonguthrie 13y ago
The Twilio Erlang library has a built in Extended TWIML library that is compiles to a human readable statement of the state machine and the state machine that implements it. It also guarantees that the state machine doesn't hang for the user.
So for example you write:
SAY1 = #say{text = "My you are looking swish"},
RESPONSE1 = #response_EXT{title = "Praise", response = "1", body = [SAY1]},
SAY2 = #say{text = "What you looking at, fannybaws?", language = "en-gb"},
RESPONSE2 = #response_EXT{title = "Abuse", response = "2", body = [SAY2]},
SAYD = #say{text = "can you no use a phone, bawbag?", language = "de"},
DEFAULT = #default_EXT{title = "a slagging", body = [SAYD]},
% now put them all together
[#gather{numDigits = 1, autoMenu_EXT = true, after_EXT = [RESPONSE1,
RESPONSE2,
DEFAULT]}];
and it compiles to:
1 - GATHER (request Keypad Input)
1.1 - SAY "Press 1 for PRAISE. Press 2 for ABUSE. Do nothing for A SLAGGING"
1.2 - end of Gather (wait for response)
1.3 - Response 1 : PRAISE
1.3.1 - SAY "My you are looking swish"
1.3.2 - HANGUP
1.4 - Response 2 : ABUSE
1.4.1 - SAY "What you looking at, fannybaws?" en-gb
1.4.2 - HANGUP
1.5 - Default : A SLAGGING
1.5.1 - SAY "can you no use a phone, bawbag?" de
1.5.2 - HANGUP
Disclaimer: I wrote it...