DEV Community

Cover image for Integrating Twilio Bots into Mobile Workflows with Apple Shortcuts
Matthew Vielkind
Matthew Vielkind

Posted on • Updated on

Integrating Twilio Bots into Mobile Workflows with Apple Shortcuts

Building messaging bots has allowed me to personalize my mobile experience. Where there are no existing services meeting my individual needs I've built bots tailored to my personal requirements, like this one I call Twilio Fit that designs a daily workout that won't get boring. Bots are a great way to deploy custom functionality in a mobile-first manner without having to design a full app, but interactions were limited to the various channel(s) to which the bot was deployed. Incorporating messaging bots into the larger mobile experience was a challenge. That all changed when I stumbled on Apple Shortcuts, which took my Twilio bots to a whole new level.

Discovering Apple Shortcuts.

Apple Shortcuts is an app provided by Apple that allows you to setup workflows on your iPhone. You can design custom workflows triggered by a variety of actions that will pass inputs and outputs to any number of different tasks. Within the app there is an entire gallery of shortcuts available allowing you to get prepped for the morning commute, share your current location via a text message, track how much caffeine you've had today, or help you with those tricky guitar chords among many, many others. After reviewing all the different actions you could take within Apple Shortcuts I thought, what would happen if I hooked this up to one of my bots? Let's find out!

Twilio and Apple Shortcuts is Love.

One bot I frequently use is my SMS Grocery List Bot to convert a screenshot of a recipe into a more useful shopping list. For this bot a screenshot of a recipe is sent to a Twilio SMS messaging bot and the bot returns a list of ingredients in the form of a note to make shopping easier. Without Shortcuts a lot of this process would be manual, finding the bot's number in iMessage, selecting the picture to send, opening Notes and pasting the returned list. With Shortcuts some of these steps can be automated to make the bot more accessible. Let's walkthrough what the workflow looks like in Shortcuts to give you an idea of how Twilio and Shortcuts can improve the mobile experience of your bots. Below are the first 3 steps of the workflow.

enter image description here
In this use case an assumption is made that the last screenshot is the one that has the recipe. Alternatively you can prompt the user to select the screenshot they want to send. There are so many different ways this can get configured! Next, the Send Message section takes the selected screenshot and sends it as a MMS message to the Twilio SMS messaging service, which I've saved as a contact, twilio-sms-shopping-list. Many bots have some kind of wake word to start the conversation. In the Send Message step you can pass that wake word to your SMS bot to start a conversation with a bot quickly. When Send Message is triggered a new message window is opened with your image already populated in the message. All you have to do is click send!

enter image description here
At this point the screenshot has been sent to the bot for processing. Extracting the text and applying the NLP models takes a little bit of time, so the Wait to Return step pauses the rest of the process until there is output to continue. The Wait to Return action allows the user to leave the Shortcut app and will continue when the user returns. After a few seconds the Twilio bot will return the recipe ingredients. When the ingredients are returned the user can open the message and copy the ingredients.

enter image description here
After copying the ingredients the process will continue when the user opens the Shortcuts app again. The last steps will take the ingredients that were copied to the clipboard and create a new Note in the Notes app that will contain the list of ingredients that were copied from the message.

enter image description here
When complete the note that was just created will be opened. Just like that you're ready to go grocery shopping with a list you can actually use! No more forgetting ingredients!

enter image description here
The best part is once the Shortcut has been setup it can be accessed with the click of a button on your home screen! You can even design custom icons for your bots to make them more personal. Now all my bots are accessible with a click of a button from the home screen of my phone!

enter image description here

Wrapping Up

Combining Twilio with Shortcuts creates a new dynamic, which can make your bots more accessible. With the flexibility of the Twilio platform and the number of different services Shortcuts integrates with there are so many different options for testing different integrations of your bots into your mobile experience.

Now that you've seen how you can use Twilio and Apple Shortcuts together here are a couple other tutorials to get you started:

  • Twilio Fit to build your own personal trainer bot.
  • Sous Chef Bot to build a bot that will convert screenshots of your favorite recipe into organized shopping lists.

If you're new to Twilio you can use this referral link for a free $10 to get started!

Happy building!

Top comments (0)