Skip to content

Instantly share code, notes, and snippets.

@Eclairemoy
Last active February 12, 2021 23:38
Show Gist options
  • Save Eclairemoy/75983296ae71be1bbb93d24d32138608 to your computer and use it in GitHub Desktop.
Save Eclairemoy/75983296ae71be1bbb93d24d32138608 to your computer and use it in GitHub Desktop.
sms_appointment_reminder.json
{
"description": "sms_appointment_reminder",
"states": [
{
"name": "Trigger",
"type": "trigger",
"transitions": [
{
"event": "incomingMessage"
},
{
"next": "gather_greeting",
"event": "incomingCall"
},
{
"next": "send_initial_confirmation",
"event": "incomingRequest"
}
],
"properties": {
"offset": {
"x": -180,
"y": -320
}
}
},
{
"name": "send_initial_confirmation",
"type": "send-and-wait-for-reply",
"transitions": [
{
"next": "split_confirmation",
"event": "incomingMessage"
},
{
"event": "timeout"
},
{
"event": "deliveryFailure"
}
],
"properties": {
"offset": {
"x": 90,
"y": -100
},
"from": "{{flow.channel.address}}",
"body": "{{flow.data.patient_name}} has an appt on {{flow.data.appointment_date}} @ {{flow.data.appointment_time}}. Confirm w/YES. Cancel w/NO. Reschedule w/RSCH. Call the office w/ CALL. Stop w/ STOP.",
"timeout": "3600"
}
},
{
"name": "split_confirmation",
"type": "split-based-on",
"transitions": [
{
"event": "noMatch"
},
{
"next": "confirm_appointment",
"event": "match",
"conditions": [
{
"friendly_name": "1",
"arguments": [
"{{widgets.send_initial_confirmation.inbound.Body}}"
],
"type": "matches_any_of",
"value": "YES, yes, y"
}
]
},
{
"next": "cancel_appointment",
"event": "match",
"conditions": [
{
"friendly_name": "2",
"arguments": [
"{{widgets.send_initial_confirmation.inbound.Body}}"
],
"type": "matches_any_of",
"value": "No, NO, n"
}
]
},
{
"next": "reschedule_appt",
"event": "match",
"conditions": [
{
"friendly_name": "If value matches RSCH",
"arguments": [
"{{widgets.send_initial_confirmation.inbound.Body}}"
],
"type": "matches_any_of",
"value": "RSCH, r, Reschedule, reschedule, R"
}
]
},
{
"next": "connect_to_office",
"event": "match",
"conditions": [
{
"friendly_name": "If value matches call",
"arguments": [
"{{widgets.send_initial_confirmation.inbound.Body}}"
],
"type": "matches_any_of",
"value": "Call, call, c"
}
]
}
],
"properties": {
"input": "{{widgets.send_initial_confirmation.inbound.Body}}",
"offset": {
"x": 100,
"y": 120
}
}
},
{
"name": "send_confirmation_sms",
"type": "send-message",
"transitions": [
{
"event": "sent"
},
{
"event": "failed"
}
],
"properties": {
"offset": {
"x": -560,
"y": 710
},
"from": "{{flow.channel.address}}",
"to": "{{contact.channel.address}}",
"body": "Confirmed. Arrive or join if televisit by My Health Online. For questions regarding this appt call {{flow.channel.address}}"
}
},
{
"name": "send_cancellation_sms",
"type": "send-message",
"transitions": [
{
"next": "check_waitlist",
"event": "sent"
},
{
"event": "failed"
}
],
"properties": {
"offset": {
"x": -200,
"y": 700
},
"from": "{{flow.channel.address}}",
"to": "{{contact.channel.address}}",
"body": "Your appt has been cancelled. Please text back RSCH to reschedule or give us a call at {{flow.channel.address}}"
}
},
{
"name": "reschedule_appt",
"type": "send-and-wait-for-reply",
"transitions": [
{
"next": "split_reschedule",
"event": "incomingMessage"
},
{
"event": "timeout"
},
{
"event": "deliveryFailure"
}
],
"properties": {
"offset": {
"x": 360,
"y": 410
},
"from": "{{flow.channel.address}}",
"body": "Sure, we can help you with re-scheduling your appointment. Here are the next 3 available slots:\n1. Feb 25 @ 1pm\n2. Feb 26 @ 2:30pm\n3. Feb 27 @ 4pm\n\nConfirm w/ appointment # or speak with the doctor's office w/CALL",
"timeout": "3600"
}
},
{
"name": "reschedule_confirmation",
"type": "send-message",
"transitions": [
{
"event": "sent"
},
{
"event": "failed"
}
],
"properties": {
"offset": {
"x": 250,
"y": 1410
},
"from": "{{flow.channel.address}}",
"to": "{{contact.channel.address}}",
"body": "Your appointment has been rescheduled."
}
},
{
"name": "split_reschedule",
"type": "split-based-on",
"transitions": [
{
"event": "noMatch"
},
{
"next": "option_1",
"event": "match",
"conditions": [
{
"friendly_name": "Value is 1",
"arguments": [
"{{widgets.reschedule_appt.inbound.Body}}"
],
"type": "equal_to",
"value": "1"
}
]
},
{
"next": "connect_to_office",
"event": "match",
"conditions": [
{
"friendly_name": "Value is Call",
"arguments": [
"{{widgets.reschedule_appt.inbound.Body}}"
],
"type": "equal_to",
"value": "CALL"
}
]
},
{
"next": "option_2",
"event": "match",
"conditions": [
{
"friendly_name": "Value is 2",
"arguments": [
"{{widgets.reschedule_appt.inbound.Body}}"
],
"type": "equal_to",
"value": "2"
}
]
},
{
"next": "option_3",
"event": "match",
"conditions": [
{
"friendly_name": "Value is 3",
"arguments": [
"{{widgets.reschedule_appt.inbound.Body}}"
],
"type": "equal_to",
"value": "3"
}
]
}
],
"properties": {
"input": "{{widgets.reschedule_appt.inbound.Body}}",
"offset": {
"x": 190,
"y": 660
}
}
},
{
"name": "connect_to_office",
"type": "send-message",
"transitions": [
{
"next": "make_call_to_patient",
"event": "sent"
},
{
"event": "failed"
}
],
"properties": {
"offset": {
"x": 970,
"y": 420
},
"service": "{{trigger.message.InstanceSid}}",
"channel": "{{trigger.message.ChannelSid}}",
"from": "{{flow.channel.address}}",
"to": "{{contact.channel.address}}",
"body": "You will now receive a call that will connect you with your doctor's office."
}
},
{
"name": "confirm_appointment",
"type": "run-function",
"transitions": [
{
"next": "send_confirmation_sms",
"event": "success"
},
{
"next": "send_confirmation_sms",
"event": "fail"
}
],
"properties": {
"service_sid": "ZScf0200d9d882eaa565a23d1b89076d9f",
"environment_sid": "ZEd8e3956cfcc1e828f2b63cec3916d83f",
"offset": {
"x": -440,
"y": 380
},
"function_sid": "ZH1f69ce174fb17f5201b133a307a1f6bc",
"parameters": [
{
"value": "{{flow.data.airtable_record_id}}",
"key": "record_id"
},
{
"value": "Confirmed",
"key": "appt_status"
}
],
"url": "https://appt-5108.twil.io/update-airtable"
}
},
{
"name": "cancel_appointment",
"type": "run-function",
"transitions": [
{
"next": "send_cancellation_sms",
"event": "success"
},
{
"next": "send_cancellation_sms",
"event": "fail"
}
],
"properties": {
"service_sid": "ZScf0200d9d882eaa565a23d1b89076d9f",
"environment_sid": "ZEd8e3956cfcc1e828f2b63cec3916d83f",
"offset": {
"x": -60,
"y": 420
},
"function_sid": "ZH1f69ce174fb17f5201b133a307a1f6bc",
"parameters": [
{
"value": "{{flow.data.airtable_record_id}}",
"key": "record_id"
},
{
"value": "Cancelled",
"key": "appt_status"
}
],
"url": "https://appt-5108.twil.io/update-airtable"
}
},
{
"name": "option_1",
"type": "run-function",
"transitions": [
{
"next": "reschedule_confirmation",
"event": "success"
},
{
"next": "reschedule_error",
"event": "fail"
}
],
"properties": {
"service_sid": "ZScf0200d9d882eaa565a23d1b89076d9f",
"environment_sid": "ZEd8e3956cfcc1e828f2b63cec3916d83f",
"offset": {
"x": -20,
"y": 980
},
"function_sid": "ZH1f69ce174fb17f5201b133a307a1f6bc",
"parameters": [
{
"value": "{{flow.data.airtable_record_id}}",
"key": "record_id"
},
{
"value": "Confirmed",
"key": "appt_status"
},
{
"value": "02/25/2021",
"key": "date"
},
{
"value": "1:00PM",
"key": "time"
}
],
"url": "https://appt-5108.twil.io/update-airtable"
}
},
{
"name": "split_key_press",
"type": "split-based-on",
"transitions": [
{
"event": "noMatch"
},
{
"next": "make_appointment",
"event": "match",
"conditions": [
{
"friendly_name": "If value equal_to 1",
"arguments": [
"{{widgets.gather_greeting.Digits}}"
],
"type": "equal_to",
"value": "1"
}
]
},
{
"next": "reschedule_appointment",
"event": "match",
"conditions": [
{
"friendly_name": "If value equal_to 2",
"arguments": [
"{{widgets.gather_greeting.Digits}}"
],
"type": "equal_to",
"value": "2"
}
]
},
{
"next": "other_inquiry",
"event": "match",
"conditions": [
{
"friendly_name": "If value equal_to 3",
"arguments": [
"{{widgets.gather_greeting.Digits}}"
],
"type": "equal_to",
"value": "3"
}
]
}
],
"properties": {
"input": "{{widgets.gather_greeting.Digits}}",
"offset": {
"x": -840,
"y": 100
}
}
},
{
"name": "gather_greeting",
"type": "gather-input-on-call",
"transitions": [
{
"next": "split_key_press",
"event": "keypress"
},
{
"event": "speech"
},
{
"event": "timeout"
}
],
"properties": {
"speech_timeout": "auto",
"offset": {
"x": -300,
"y": -100
},
"loop": 1,
"finish_on_key": "#",
"say": "Thank you for calling Owl Health. If you would like to make an appointment for a vaccine please press 1. If you would like to reschedule an appointment for a vaccine, please press 2. For all other inquiries, please press 3.",
"stop_gather": true,
"gather_language": "en",
"profanity_filter": "true",
"timeout": 5
}
},
{
"name": "owl_health_voicemail",
"type": "record-voicemail",
"transitions": [
{
"event": "recordingComplete"
},
{
"event": "noAudio"
},
{
"event": "hangup"
}
],
"properties": {
"transcribe": false,
"offset": {
"x": -1170,
"y": 780
},
"trim": "trim-silence",
"play_beep": "true",
"timeout": 5,
"max_length": 3600
}
},
{
"name": "make_appointment",
"type": "say-play",
"transitions": [
{
"next": "owl_health_voicemail",
"event": "audioComplete"
}
],
"properties": {
"offset": {
"x": -1570,
"y": 450
},
"loop": 1,
"say": "Thank you for calling to make a vaccine appointment. Please leave your name and number and we will call you back to schedule."
}
},
{
"name": "reschedule_appointment",
"type": "say-play",
"transitions": [
{
"next": "owl_health_voicemail",
"event": "audioComplete"
}
],
"properties": {
"offset": {
"x": -1200,
"y": 450
},
"loop": 1,
"say": "We're happy to help you reschedule an appointment. Please leave your name and phone number and we'll return your call to reschedule your appointment."
}
},
{
"name": "other_inquiry",
"type": "say-play",
"transitions": [
{
"next": "owl_health_voicemail",
"event": "audioComplete"
}
],
"properties": {
"offset": {
"x": -840,
"y": 450
},
"loop": 1,
"say": "We are currently experiencing a high volume of calls. Please leave your name, phone number, and a brief description of what you are calling about. We will return your call as soon as possible. Thank you for your patience."
}
},
{
"name": "make_call_to_patient",
"type": "make-outgoing-call-v2",
"transitions": [
{
"next": "owl_health_greeting",
"event": "answered"
},
{
"event": "busy"
},
{
"event": "noAnswer"
},
{
"event": "failed"
}
],
"properties": {
"machine_detection_speech_threshold": "2400",
"detect_answering_machine": false,
"offset": {
"x": 980,
"y": 650
},
"recording_channels": "mono",
"timeout": 60,
"machine_detection": "Enable",
"trim": "do-not-trim",
"record": false,
"machine_detection_speech_end_threshold": "1200",
"machine_detection_timeout": "30",
"from": "{{flow.channel.address}}",
"to": "{{contact.channel.address}}",
"machine_detection_silence_timeout": "5000"
}
},
{
"name": "owl_health_greeting",
"type": "say-play",
"transitions": [
{
"next": "connect_to_provider",
"event": "audioComplete"
}
],
"properties": {
"offset": {
"x": 990,
"y": 890
},
"loop": 1,
"say": "Thanks for choosing Owl Health. Please wait one moment while we connect you to the scheduler."
}
},
{
"name": "connect_to_provider",
"type": "connect-call-to",
"transitions": [
{
"event": "callCompleted"
},
{
"event": "hangup"
}
],
"properties": {
"offset": {
"x": 1010,
"y": 1130
},
"caller_id": "{{contact.channel.address}}",
"noun": "conference",
"to": "Owl Health Conference Line",
"timeout": 30
}
},
{
"name": "option_2",
"type": "run-function",
"transitions": [
{
"next": "reschedule_confirmation",
"event": "success"
},
{
"next": "reschedule_error",
"event": "fail"
}
],
"properties": {
"service_sid": "ZScf0200d9d882eaa565a23d1b89076d9f",
"environment_sid": "ZEd8e3956cfcc1e828f2b63cec3916d83f",
"offset": {
"x": 310,
"y": 980
},
"function_sid": "ZH1f69ce174fb17f5201b133a307a1f6bc",
"parameters": [
{
"value": "{{flow.data.airtable_record_id}}",
"key": "record_id"
},
{
"value": "Confirmed",
"key": "appt_status"
},
{
"value": "02/26/2021",
"key": "date"
},
{
"value": "2:30PM",
"key": "time"
}
],
"url": "https://appt-5108.twil.io/update-airtable"
}
},
{
"name": "reschedule_error",
"type": "send-message",
"transitions": [
{
"event": "sent"
},
{
"event": "failed"
}
],
"properties": {
"offset": {
"x": 600,
"y": 1330
},
"service": "{{trigger.message.InstanceSid}}",
"channel": "{{trigger.message.ChannelSid}}",
"from": "{{flow.channel.address}}",
"to": "{{contact.channel.address}}",
"body": "Sorry! Something went wrong. Please give us a call at {{flow.channel.address}}"
}
},
{
"name": "option_3",
"type": "run-function",
"transitions": [
{
"next": "reschedule_confirmation",
"event": "success"
},
{
"next": "reschedule_error",
"event": "fail"
}
],
"properties": {
"service_sid": "ZScf0200d9d882eaa565a23d1b89076d9f",
"environment_sid": "ZEd8e3956cfcc1e828f2b63cec3916d83f",
"offset": {
"x": 650,
"y": 980
},
"function_sid": "ZH1f69ce174fb17f5201b133a307a1f6bc",
"parameters": [
{
"value": "{{flow.data.airtable_record_id}}",
"key": "record_id"
},
{
"value": "Confirmed",
"key": "appt_status"
},
{
"value": "02/27/2021",
"key": "date"
},
{
"value": "4:00PM",
"key": "time"
}
],
"url": "https://appt-5108.twil.io/update-airtable"
}
},
{
"name": "check_waitlist",
"type": "run-function",
"transitions": [
{
"next": "send_new_option",
"event": "success"
},
{
"event": "fail"
}
],
"properties": {
"service_sid": "ZScf0200d9d882eaa565a23d1b89076d9f",
"environment_sid": "ZEd8e3956cfcc1e828f2b63cec3916d83f",
"offset": {
"x": -420,
"y": 980
},
"function_sid": "ZHac6a232f8f2f1686c5480554cd9825be",
"url": "https://appt-5108.twil.io/check-waitlist"
}
},
{
"name": "send_new_option",
"type": "send-and-wait-for-reply",
"transitions": [
{
"next": "split_2",
"event": "incomingMessage"
},
{
"event": "timeout"
},
{
"event": "deliveryFailure"
}
],
"properties": {
"offset": {
"x": -410,
"y": 1250
},
"service": "{{trigger.message.InstanceSid}}",
"channel": "{{trigger.message.ChannelSid}}",
"from": "{{flow.channel.address}}",
"body": "Hi {{widgets.check_waitlist.parsed.new_name}}, an earlier vaccine appointment opened up. Right now your appointment is {{widgets.check_waitlist.parsed.new_date}} @ {{widgets.check_waitlist.parsed.new_time}} . \nWould you like to change it to {{flow.data.appointment_date}} @ {{flow.data.appointment_time}}? Please confirm w/Yes if you would like to accept this spot instead.",
"timeout": "3600"
}
},
{
"name": "split_2",
"type": "split-based-on",
"transitions": [
{
"next": "do_not_update",
"event": "noMatch"
},
{
"next": "confirm_waitlist_reschedule",
"event": "match",
"conditions": [
{
"friendly_name": "If value matches_any_of Yes, yes, Y",
"arguments": [
"{{widgets.send_new_option.inbound.Body}}"
],
"type": "matches_any_of",
"value": "Yes, yes, Y"
}
]
}
],
"properties": {
"input": "{{widgets.send_new_option.inbound.Body}}",
"offset": {
"x": -450,
"y": 1510
}
}
},
{
"name": "confirm_waitlist_reschedule",
"type": "run-function",
"transitions": [
{
"next": "reschedule_confirmation",
"event": "success"
},
{
"event": "fail"
}
],
"properties": {
"service_sid": "ZScf0200d9d882eaa565a23d1b89076d9f",
"environment_sid": "ZEd8e3956cfcc1e828f2b63cec3916d83f",
"offset": {
"x": -180,
"y": 1770
},
"function_sid": "ZH1f69ce174fb17f5201b133a307a1f6bc",
"parameters": [
{
"value": "{{widgets.check_waitlist.parsed.new_record_id}}",
"key": "record_id"
},
{
"value": "Confirmed",
"key": "appt_status"
},
{
"value": "{{flow.data.appointment_date}}",
"key": "date"
},
{
"value": "{{flow.data.appointment_time}}",
"key": "time"
},
{
"value": "null",
"key": "waitlist"
}
],
"url": "https://appt-5108.twil.io/update-airtable"
}
},
{
"name": "do_not_update",
"type": "send-message",
"transitions": [
{
"event": "sent"
},
{
"event": "failed"
}
],
"properties": {
"offset": {
"x": -550,
"y": 1770
},
"service": "{{trigger.message.InstanceSid}}",
"channel": "{{trigger.message.ChannelSid}}",
"from": "{{flow.channel.address}}",
"to": "{{contact.channel.address}}",
"body": "Okay, we kept your same appointment time. See you then."
}
}
],
"initial_state": "Trigger",
"flags": {
"allow_concurrent_calls": true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment