Menu

Expand
Rate this page:

Studio Flow Definition

To represent the complex structure and requirements of a Studio Flow and its widget configurations, the Flow definition is expressed as a JSON schema. Thus, when creating or updating Flows via the REST API, the JSON sent in the Definition parameter must pass validation against that schema.

Below are sample Flow and widget definitions you can copy and paste into your application. Alternatively, use the Studio editor in Twilio Console to automatically create valid definitions and export them from the API to save them locally or to add them to version control. Refer to the JSON schemas for full details of widgets and properties.

Standalone Definitions

The following sample definitions can be used as standalone starters for your application. Include the complete JSON as the Definition parameter in your POST to the API.

Loading Code Sample...
        
        
        Simple Flow for handling Incoming Message, Incoming Call and REST API triggered Executions

        Simple Flow Definition

        Simple Flow for handling Incoming Message, Incoming Call and REST API triggered Executions
        Loading Code Sample...
              
              
              Blank Flow with no widgets attached to the Trigger

              Trigger

              Blank Flow with no widgets attached to the Trigger

              Widget Snippets

              Widgets are defined as "states" that the Studio workflow engine transitions to in response to events. The following JSON snippets can be used to add individual widgets as states to an existing Flow definition.

              Add each widget snippet as a new item in the states array:

              {
                "states": [
                    // ADD WIDGET SNIPPETS HERE
                  ],
                "initial_state": "Trigger",
                "flags": {
                    "allow_concurrent_calls": true
                },
                "description": "A New Flow"
              }
              
              Loading Code Sample...
                    
                    
                    Snippet of JSON to add a TwiML redirect

                    Add TwiML Redirect

                    Snippet of JSON to add a TwiML redirect
                    Loading Code Sample...
                          
                          
                          Snippet of JSON to capture payments

                          Capture Payments

                          Snippet of JSON to capture payments
                          Loading Code Sample...
                                
                                
                                Snippet of JSON to connect the caller to another number

                                Connect Call To

                                Snippet of JSON to connect the caller to another number
                                Loading Code Sample...
                                      
                                      
                                      Snippet of JSON to enqueue the call

                                      Enqueue Call

                                      Snippet of JSON to enqueue the call
                                      Loading Code Sample...
                                            
                                            
                                            Snippet of JSON to fork the audio stream to another endpoint

                                            Fork Stream

                                            Snippet of JSON to fork the audio stream to another endpoint
                                            Loading Code Sample...
                                                  
                                                  
                                                  Snippet of JSON to gather digits or speech input

                                                  Gather Input On Call

                                                  Snippet of JSON to gather digits or speech input
                                                  Loading Code Sample...
                                                        
                                                        
                                                        Snippet of JSON to make an HTTP request to another API

                                                        Make HTTP Request

                                                        Snippet of JSON to make an HTTP request to another API
                                                        Loading Code Sample...
                                                              
                                                              
                                                              Snippet of JSON to initiate an outbound call

                                                              Make Outgoing Call

                                                              Snippet of JSON to initiate an outbound call
                                                              Loading Code Sample...
                                                                    
                                                                    
                                                                    Snippet of JSON to record an inbound call

                                                                    Record Call

                                                                    Snippet of JSON to record an inbound call
                                                                    Loading Code Sample...
                                                                          
                                                                          
                                                                          Snippet of JSON to record voicemail from the caller

                                                                          Record Voicemail

                                                                          Snippet of JSON to record voicemail from the caller
                                                                          Loading Code Sample...
                                                                                
                                                                                
                                                                                Snippet of JSON to run a Twilio Function

                                                                                Run Function

                                                                                Snippet of JSON to run a Twilio Function
                                                                                Loading Code Sample...
                                                                                      
                                                                                      
                                                                                      Snippet of JSON to say a message to the caller

                                                                                      Say/Play

                                                                                      Snippet of JSON to say a message to the caller
                                                                                      Loading Code Sample...
                                                                                            
                                                                                            
                                                                                            Snippet of JSON to send a text message and wait for a reply

                                                                                            Send & Wait For Reply

                                                                                            Snippet of JSON to send a text message and wait for a reply
                                                                                            Loading Code Sample...
                                                                                                  
                                                                                                  
                                                                                                  Snippet of JSON to send a text message

                                                                                                  Send Message

                                                                                                  Snippet of JSON to send a text message
                                                                                                  Loading Code Sample...
                                                                                                        
                                                                                                        
                                                                                                        Snippet of JSON to send to an Autopilot Assistant

                                                                                                        Send to Autopilot

                                                                                                        Snippet of JSON to send to an Autopilot Assistant
                                                                                                        Loading Code Sample...
                                                                                                              
                                                                                                              
                                                                                                              Snippet of JSON to route the contact to a Flex agent

                                                                                                              Send to Flex

                                                                                                              Snippet of JSON to route the contact to a Flex agent
                                                                                                              Loading Code Sample...
                                                                                                                    
                                                                                                                    
                                                                                                                    Snippet of JSON to set Execution-level variables

                                                                                                                    Set Variables

                                                                                                                    Snippet of JSON to set Execution-level variables
                                                                                                                    Loading Code Sample...
                                                                                                                          
                                                                                                                          
                                                                                                                          Snippet of JSON to add branching logic

                                                                                                                          Split Based On

                                                                                                                          Snippet of JSON to add branching logic
                                                                                                                          Rate this page:

                                                                                                                          Need some help?

                                                                                                                          We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.

                                                                                                                          Loading Code Sample...
                                                                                                                                
                                                                                                                                
                                                                                                                                

                                                                                                                                Thank you for your feedback!

                                                                                                                                Please select the reason(s) for your feedback. The additional information you provide helps us improve our documentation:

                                                                                                                                Sending your feedback...
                                                                                                                                🎉 Thank you for your feedback!
                                                                                                                                Something went wrong. Please try again.

                                                                                                                                Thanks for your feedback!

                                                                                                                                thanks-feedback-gif