Skip to content

Instantly share code, notes, and snippets.

@crienzo
Created January 30, 2024 14:54
Show Gist options
  • Save crienzo/90d1239f73821f6c4c30e8ab58a0b192 to your computer and use it in GitHub Desktop.
Save crienzo/90d1239f73821f6c4c30e8ab58a0b192 to your computer and use it in GitHub Desktop.
SignalWire follow me w/ voicemail example
{ "sections": {
"main": [
{ "set": { "time_of_day": "%{new Date().getHours()}" } },
{ "cond": [
{ "when": "vars.time_of_day < 12", "then": [ { "transfer": "after_hours" } ] },
{ "when": "call.to === 'EXTENSION_2_DIRECT_NUMBER'", "then": [ { "transfer": "extension_2" } ] }
] },
"answer",
{ "play": "silence:1" },
{ "set": { "greeting": "say:Thank you for calling. If you know your parties extension please press it now." } },
{ "label": "top_level" },
{ "prompt": "%{vars.greeting}" },
{ "cond": [
{ "when": "vars.prompt_value == '2'", "then": [ { "transfer": "extension_2" } ] }
] },
{ "set": { "greeting": "say:If you know your parties extension please press it now." } },
{ "goto": { "label": "top_level", "max": 4 } },
{ "play": [ "silence:1", "say:Goodbye", "silence:1" ] },
"hangup"
],
"after_hours": [
{ "play": [ "say:Thank you for calling. We are currently closed. Please stay on the line if you'd like to leave a message." ] },
{ "transfer": "voicemail" }
],
"extension_2": [
{ "connect": {
"timeout": 20,
"from": "OPTIONAL_YOUR_EXTENSION_PHONE_NUMBER",
"parallel": [
{ "to": "YOUR_SIP_URI_OR_PHONE_NUMBER" },
{ "to": "ANOTHER_SIP_URI_OR_PHONE_NUMBER",
"confirm": [
{ "prompt": { "play": [ "say:<speak>SignalWire call from <say-as interpret-as=\"telephone\">%{call.from}</say-as>. Press one to accept or two to hang up</speak>", "silence:2", "say:<speak>SignalWire call from <say-as interpret-as=\"telephone\">%{call.from}</say-as>. Press one to accept or two to hang up</speak>", "silence:2", "say:<speak>SignalWire call from <say-as interpret-as=\"telephone\">%{call.from}</say-as>. Press one to accept or two to hang up</speak>" ] } },
{ "cond": [
{ "when": "vars.prompt_value != '1'", "then": [ "hangup" ] }
] }
]
}
]
} },
{ "cond": [
{ "when": "vars.connect_result != 'connected'", "then": [ { "transfer": "voicemail" } ] }
] },
{ "play": [ "say:goodbye", "silence:1" ] },
"hangup"
],
"voicemail": [
{ "play": "say:Please leave a message after the beep." },
{ "record": { "beep": true } },
{ "play": [ "silence:1", "say:Goodbye", "silence:1" ] },
"hangup"
]
} }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment