Twilio Studio

Twilio Studio enables you to create interactive messaging scenarios between your platform and your users.

Getting Started with Studio

If you are completely unfamiliar with Studio, here's a great place to get started.

Unique Identifiers

Twilio refers to it's unique identifiers as an SID. You will need to use different types of SIDs when creating a Studio flow

Account SID

The account SID can be found in the Twilio Console of your account. This will be used along with the Auth Token to provide authentication for your Api requests: HTTP Basic Authentication

Flow SID

The flow SID is located in your Studio Dashboard to the right of the flow name. This is used in the POST URL to identify the flow you are executing.

Triggering a Studio Flow from Bubble

A studio flow execution can be triggered by an incoming message, an incoming call, or by making an HTTP POST request from your application.
To trigger a new execution of your Flow via the REST API, make an HTTP POST request from Bubble to:[FlowSid]/Executions
In the API connector set up your Twilio API like this:
Get your Account SID and Auth Token from your Twilio Console
Your POST request to trigger a new execution should be set up like this. Note that you CAN remove the private checkmark from the flowID value and use the same call to trigger more than one flow, however each flow is unique enough in Studio that it's easier to set this up individually for each flow.
And the body of your request needs to passed as a string like this:
Only 'To' and 'From' are required in this request. The 'Parameters' option is there for passing unique data through for each flow and should be formatted as a valid JSON string.
These parameters are not defined in Studio and can be empty
The data sent through these parameters are accessible in your Studio flow using the {{*}} variable.
For instance, if you pass in 'Parameters={"customer":"John"} then inside a widget you can reference the variable {{}} which will return the string "John".

Sending Data to my application

You can send data to your application from within a Studio flow at any point by using the MAKE HTTP REQUEST widget and sending the data as JSON to an endpoint you set up in your application.
MAKE HTTP REQUEST widget setup in Studio
Pass unique IDs from your platform when initially triggering a new flow and those can be sent back to your application from Studio. This makes it possible to find the correct records to update.

Manipulating data using a Function

Some data manipulation can be done directly in the Studio flow using the Liquid Template Language (more here)
You can also use functions using the Run Function widget. To send data to the function, choose the function from the list of function in your Run Function widget and add function parameters to pass through.
Running a function and sending an 'amount' parameter
You will have to create the function first before it will show up in your list. This video shows you how to create a function.
In this function we were using some simple regex to strip the symbol from a currency value. You can access the value for any parameter you pass to your function in the 'event' object. In our case, we needed the 'event.amount' value.
Back in the Studio flow then, we can access the response using this variable format {{widgets.fn_extract_currency.parsed.amount}}. Replace 'fn_extract_currency' with the name of your Run Function widget.

Configuring your number for your flow

Your number must be configured to interact with your Studio flow or it will not engage. Learn how to do that here