Published on

Twilio Studio

Authors

I have used Twilio in a project to send OTPs. In that case, I simply provided a plugin in Rails with the Twilio API key and secret.

Today I had to get more in-depth into the Twilio APIs. The APIs have plenty of excellent documentation and examples. But in my case I wanted to quickly put together a PoC without having to worry about writing the code up, hosting it and linking it to Twilio (via webhooks). For the PoC I had to allow our number to respond to SMSs with a particular word.

After a brief bit of Googling, I came across this. Twilio Studio is a GUI tool to quickly slap together a basic and advanced flow without having to code everything. It is also hosted by Twilio so no need to worry about deploying this anywhere else.

The process was simply:

  • create a new Twilio studio flow
  • Use the widgets to build the needed flow
  • Connect the flow to a number you own
  • Publish the flow

My flow was fairly simple I used the following widgets in the given order:

[Trigger#IncomingMessage]->[SplitBasedOn#BodyKeyword#Contains('desiredWord')]

=> [NoMatches]->[SendMessage('http://my.fallbackLink.example')]
=> [HasMatche]->[SendMessage('http://my.otherlink.example')]

One thing that was not too obvious was how to do more advanced things like uppercase all, lowercase all and regex. This ended up also being really simply by using Twilio Studio's liquid template language.

The Liquid Studio Template language allows you to pipe variables to the helper function you want. So, for example, to downcase (aka lowercase) the body in the UI text field I change Variable to Test from trigger.message.Body to trigger.message.Body | downcase. The GUI value then changes to {{ trigger.message.Body | downcase }}. This allows the user to psycho case the body if they want and we will still pick it up.