Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Send Appointment Reminders with Twilio Studio


Appointment reminders are a breeze with Twilio Studio! Let's look at how to build a Flow that hooks into your application via REST API and sends a reminder SMS with a confirmation message.


Create Your Flow

create-your-flow page anchor

We'll start with a fresh Twilio Studio Flow. Log into your Twilio account and navigate to the Studio Dashboard(link takes you to an external page), then tap the + icon to create a new Flow. You can name your Flow anything you like — this guide will use Appointment Reminder. Click on the Next button.

Appointment Reminder Flow.

You'll notice that the Studio Canvas comes with a Widget already in place. The Trigger (Start) Widget starts the Flow when the trigger you specify is fired. In this case, the REST API trigger will be used to start the Flow's Execution. See the REST API section of the Studio User Guide to learn how to make these calls.

Twilio Studio Tutorial Appointment Reminders arrow pointing to REST API trigger within the Trigger (Start) Widget.

Start by adding a Send & Wait For Reply Widget to the Canvas and connecting it to the REST API trigger by dragging the red dot to the grey dot in the corner of the new Widget. You can use this Widget to send an SMS to the user and wait for a response message. In this case, you will use a value (time) that was passed in using the REST API trigger. You can reference values passed in from a REST API trigger using the Liquid variable {{flow.data.<valueName>}}.

Under the MESSAGE BODY field of the Widget, input "Your appointment is coming up on {{flow.data.appointment_time}}. Please reply 1 to confirm and 2 to cancel." Studio supports the Liquid template language(link takes you to an external page), which is a fancy way of saying "a way to help you load dynamic content throughout your Flow." You are telling Studio that you would like it to dynamically interpret the text between the two curly braces based on something. In this case, the appointment_time value that was passed in from your REST API request will be dynamically interpreted.

Twilio Studio Tutorial Appointment Reminders confirm_appt Widget shown with configuration panel to the right. The REST API trigger is connected to the confirm_appt Widget.

Assume the user replies to the text message to confirm or cancel their appointment. You need to add some logic that will help us know which choice the user would like to make. Use the Split Based On… Widget to help handle that. Drag it onto the Canvas and connect it to the dangling Reply dot from your Send & Wait For Reply Widget.

Twilio Studio Tutorial Appointment Reminders Split Based On... Widget placed on Canvas that will evaluate the response to the Send & Wait For Reply Widget.

First, you'll need to configure the variable the Split Based On... Widget will evaluate. In this case, you are concerned with the user's reply, so select confirm_appt and then inbound.Body from the dropdown in the configuration panel (yours may have a different name if your Send & Wait For Reply Widget is not called confirm_appt). This variable represents the incoming response message sent by the user.

Twilio Studio Tutorial Appointment Reminders Split Based On Confirmation Configuration.

Set Transition Conditions

set-transition-conditions page anchor

Next, you'll need to declare the choices you're looking for in those text replies — the digits 1 and 2. Click the red New button at the bottom of the Split Widget to reveal the Transition On… dropdown menu. Select Condition Matches to create a new condition.

Twilio Studio Tutorial Appointment Reminders Split Based On Confirmation Add Condition.

In the right sidebar, find the new condition that you just created, and select Equal To from the dropdown. Set the value to 1 to confirm the appointment. Save the new condition and it will appear on the Widget as a transition. Rename the condition to 1.

Twilio Studio Tutorial Appointment Reminders Split Based On Confirmation Set 1 Condition.

Next, you'll need a condition for if the user has pressed 2 to cancel the appointment. Just as with the first condition, click New on the Split Based On... Widget and select Condition Matches. Then set the value equal to 2 in the sidebar, click Save, and rename to 2. Your Split Based On... Widget should now have the transitions No Condition Matches, 1, and 2 dangling from the bottom.

Twilio Studio Tutorial Appointment Reminders Split Based On Confirmation All Transitions.

Next, you are going to want to handle the appointment confirmation by making a request back to your servers. You can do this by dragging an Make HTTP Request Widget onto the Canvas and filling in the required Request Method and Request URL fields in the right sidebar. In this example, http://example.com will be used but you'll want to set the Request URL to the appropriate endpoint for your application. If you'd like to send a request body or parameters, you may set those in the configuration for the Make HTTP Request Widget as well.

Twilio Studio Tutorial Appointment Reminders Confirm HTTP Request Widget on Canvas.

When the request successfully completes, you want to text the user with a thank you. Drag a Send Message Widget onto the Canvas and populate the Message Body field with your note for the user.

Twilio Studio Tutorial Appointment Reminders Thank You Send Message Widget.

Now it's time to do the same steps over again, but this time for the cancellation. Drag a Make HTTP Request Widget onto the Canvas and hook it to the dangling 2 from the Split Based On... Widget, make a request to your cancellation endpoint, and send an acknowledgment message to the user.

Twilio Studio Tutorial Appointment Reminders full Widget layout shown after connecting both 1 and 2 to respective HTTP Widgets.

But what if the user enters text besides 1 or 2 (the confirmation and cancellation conditions)? We can take advantage of the built-in No Condition Matches condition and prompt the user with the reminder again. Drag a Send Message Widget onto the Canvas and connect it to the No Condition Matches dot, then enter the error message of your choosing. You can then re-prompt the user with the original appointment reminder by dragging the Sent dot on the Send Message widget to the original Send & Wait For Reply Widget.

Twilio Studio Tutorial Appointment Reminders No Condition Send Message Widget then redirects back to the Send & Wait For Reply Widget.

The final state of the Canvas is that a Trigger (Start) Widget takes a REST API request, prompts the user to confirm or cancel with a Send & Wait For Reply Widget, routes responses through a Split Based On… Widget, uses HTTP Request widgets to POST cancellations and confirmations back to your own endpoint, and uses Send Message Widgets to acknowledge the user's response.

Twilio Studio Tutorial Appointment Reminders Entire Flow on the Canvas.

Time to test it out! You can make a request from your API to Studio and kick off this appointment reminder flow, then text back to confirm or cancel. You can use the following curl command to trigger this flow:


_10
curl -X POST "https://studio.twilio.com/v1/Flows/FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Executions" -d "To=${MY_PHONE_NUMBER}" -d "From=${FROM_NUMBER}" -d "Parameters={\"appointment_time\": \"Tuesday at 6PM\"}" -u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN

For more information about parameters, and other example of curl requests, see the REST API section of the Studio User Guide. Get ready to have your calendar perfectly synced with your clients!


Rate this page: