Menu

Expand
Rate this page:

Thanks for rating this page!

We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

Studio Flow Definition

BETA

This Twilio product is currently available as a beta release. Some features are not yet implemented and others may be changed before the product is declared as Generally Available. Beta products are not covered by a Twilio SLA. Learn more about beta product support.

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.

        
        
        
        
        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
              
              
              
              
              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"
              }
              
                    
                    
                    
                    
                    Snippet of JSON to add a TwiML redirect

                    Add TwiML Redirect

                    Snippet of JSON to add a TwiML redirect
                          
                          
                          
                          
                          Snippet of JSON to capture payments

                          Capture Payments

                          Snippet of JSON to capture payments
                                
                                
                                
                                
                                Snippet of JSON to connect the caller to another number

                                Connect Call To

                                Snippet of JSON to connect the caller to another number
                                      
                                      
                                      
                                      
                                      Snippet of JSON to enqueue the call

                                      Enqueue Call

                                      Snippet of JSON to enqueue the call
                                            
                                            
                                            
                                            
                                            Snippet of JSON to fork the audio stream to another endpoint

                                            Fork Stream

                                            Snippet of JSON to fork the audio stream to another endpoint
                                                  
                                                  
                                                  
                                                  
                                                  Snippet of JSON to gather digits or speech input

                                                  Gather Input On Call

                                                  Snippet of JSON to gather digits or speech input
                                                        
                                                        
                                                        
                                                        
                                                        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
                                                              
                                                              
                                                              
                                                              
                                                              Snippet of JSON to initiate an outbound call

                                                              Make Outgoing Call

                                                              Snippet of JSON to initiate an outbound call
                                                                    
                                                                    
                                                                    
                                                                    
                                                                    Snippet of JSON to record an inbound call

                                                                    Record Call

                                                                    Snippet of JSON to record an inbound call
                                                                          
                                                                          
                                                                          
                                                                          
                                                                          Snippet of JSON to record voicemail from the caller

                                                                          Record Voicemail

                                                                          Snippet of JSON to record voicemail from the caller
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                Snippet of JSON to run a Twilio Function

                                                                                Run Function

                                                                                Snippet of JSON to run a Twilio Function
                                                                                      
                                                                                      
                                                                                      
                                                                                      
                                                                                      Snippet of JSON to say a message to the caller

                                                                                      Say/Play

                                                                                      Snippet of JSON to say a message to the caller
                                                                                            
                                                                                            
                                                                                            
                                                                                            
                                                                                            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
                                                                                                  
                                                                                                  
                                                                                                  
                                                                                                  
                                                                                                  Snippet of JSON to send a text message

                                                                                                  Send Message

                                                                                                  Snippet of JSON to send a text message
                                                                                                        
                                                                                                        
                                                                                                        
                                                                                                        
                                                                                                        Snippet of JSON to send to an Autopilot Assistant

                                                                                                        Send to Autopilot

                                                                                                        Snippet of JSON to send to an Autopilot Assistant
                                                                                                              
                                                                                                              
                                                                                                              
                                                                                                              
                                                                                                              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
                                                                                                                    
                                                                                                                    
                                                                                                                    
                                                                                                                    
                                                                                                                    Snippet of JSON to set Execution-level variables

                                                                                                                    Set Variables

                                                                                                                    Snippet of JSON to set Execution-level variables
                                                                                                                          
                                                                                                                          
                                                                                                                          
                                                                                                                          
                                                                                                                          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 browsing the Twilio tag on Stack Overflow.