Skip to content

Instantly share code, notes, and snippets.

@jaypatel512
Created April 11, 2018 01:35
Show Gist options
  • Save jaypatel512/dc52ed0dd69f218afb176cb774665760 to your computer and use it in GitHub Desktop.
Save jaypatel512/dc52ed0dd69f218afb176cb774665760 to your computer and use it in GitHub Desktop.
{
"CheckIfWeHaveFirstAndLastName": {
"name": "GetNameFromContext",
"next": {
"yes": "CheckIfWeHavePhone",
"no": "WelcomeAndAskForFirstName"
}
},
"WelcomeAndAskForFirstName": {
"name": "CollectName",
"key": "first_name",
"incomingMessage": {
"text": "Looks like you are setting up a service appointment. Let me get few details pretty quick. Can I get your first name please ?"
},
"failureMessage": {
"text": "Did not get it. Can you please enter your first name please ?"
},
"next": {
"yes": "CollectLastName",
"no": "WelcomeAndAskForFirstName"
}
},
"CollectLastName": {
"name": "CollectName",
"key": "last_name",
"incomingMessage": {
"text": "Great, can I please get your last name ?"
},
"failureMessage": {
"text": "Did not get it. Can you please enter your last name please ?"
},
"next": {
"yes": "CheckIfWeHavePhone",
"no": "CollectLastName"
}
},
"CheckIfWeHavePhone": {
"name": "PhoneNumberInUserChecker",
"next": {
"yes": "CollectDateAndTime",
"no": "CollectPhone"
}
},
"CollectPhone": {
"name": "GetPhone",
"updateStoreUser": true,
"incomingMessage": {
"text": "Can I please get your phone number ${first_name}? We need the phone number to lookup your records, and book the appointment for you."
},
"failureMessage": {
"text": "It didnt look like a phone number, can you please try again and enter your phone number?"
},
"next": {
"yes": "CheckIfStoreHasBranches",
"no": "CollectPhone"
}
},
"CheckIfStoreHasBranches": {
"name": "CheckIfStoreHasBranches",
"next": {
"yes": "SelectBranch",
"no": "CollectDateAndTime"
}
},
"SelectBranch": {
"name": "SelectBranch",
"incomingMessage": {
"text": "Btw, which location are you looking to book?"
},
"failureMessage": {
"text": "Did not get it. which location are you looking to book?"
},
"next": {
"yes": "CollectDateAndTime",
"no": "SelectBranch"
}
},
"CollectDateAndTime": {
"name": "GetTime",
"offDay": "Sunday",
"startTime": "7",
"endTime": "16",
"retriesAllowed": 10,
"incomingMessage": {
"attachment": {
"type": "template",
"payload": {
"template_type": "button",
"text": "Awesome. Can you please select the appointment date by clicking the button below. We are open ${store_appointment_hours_minified}. Or you can also say something like `2 PM day after tomorrow`",
"buttons": [
{
"type": "web_url",
"url": "https://2fcd931e.ngrok.io/api/fb/calendar?storeId=${store_id}",
"title": "Other Date/Time",
"messenger_extensions": true,
"webview_height_ratio": "tall"
}
]
}
}
},
"failureMessage": {
"text": "Oops. Try something like `2 PM day after tomorrow` with appointment time within the business hours. What time will work for you?"
},
"next": {
"yes": "CollectCarType",
"no": "CollectDateAndTime"
}
},
"CollectCarType": {
"name": "GetVehicle",
"key": "car_type",
"incomingMessage": {
"text": "And what's the car type ${first_name}? You can reply something like 'Toyota Camry 2017'."
},
"next": {
"all": "CollectServiceType"
}
},
"CollectServiceType": {
"name": "CollectReply",
"key": "service_type",
"incomingMessage": {
"text": "Perfect. One last question ${first_name}, what type of service are we planning to do? You can select these options or type if something else.",
"quick_replies": [
{
"content_type": "text",
"title": "Routine Check",
"payload": "Routine Check"
},
{
"content_type": "text",
"title": "Oil Change",
"payload": "Oil Change"
}
]
},
"next": {
"all": "SendEmailToAgent"
}
},
"SendEmailToAgent": {
"name": "SendEmail",
"template": "service-email-template.ftl",
"subject": "Service Appointment Request from BlinkAI",
"values": "car_type,service_type,time_pretty,first_name,last_name,phone",
"next": {
"all": "SendSlackMessage"
}
},
"SendSlackMessage": {
"name": "SendSlackMessage",
"message": "A service appointment was created for ${first_name} ${last_name} (${phone}). Car: ${car_type} for ${service_type} @ ${time_pretty}.",
"next": {
"all": "AddAppointmentReminder"
}
},
"AddAppointmentReminder": {
"name": "AddAppointmentReminder",
"message": {
"attachment": {
"type": "template",
"payload": {
"template_type": "button",
"text": "Hey ${first_name} ${last_name}, just wanted to remind you about your upcoming appointment tomorrow at ${time_only}. \n We are located at: ${store_address}",
"buttons": [
{
"type": "phone_number",
"title": "Call Service Center",
"payload": "${store_service_phone}"
}
]
}
}
},
"next": {
"all": "AppointmentSummary"
}
},
"AppointmentSummary": {
"name": "SendMessage",
"message": {
"attachment": {
"type": "template",
"payload": {
"elements": [
{
"title": "${time_pretty}",
"subtitle": "${first_name}, your apppointment is confirmed for ${time_pretty}. See you then.",
"image_url": "https://s3.amazonaws.com/blinkai/confirmed_appointment.png"
}
],
"template_type": "generic"
}
}
},
"next": {
"all": "end"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment