Working with Global Variables

Choreo outputs (typically responses from API requests) are stored as local variables because they only need to exist in memory for the duration of the execution in order to return the result to your application. At times however, you may want to store a response as a global variable because you want to download the result or you want another Choreo execution to be able to access it. This tutorial shows you how to read and write global variables.

Writing Global Variables

Writing to a global variable is pretty straightforward. Here's how to do it.

1In the Vault browser's Action menu, create a New Folder called "MyVariables".

Twyla's Actions menu

2Next, using the Action's menu again, create a New Global Variable. Give your variable a name and click OK.

3Once you've created this global variable, you can refer to it in the Choreo you're building. Here's an example where the response from an API has been stored in a local variable called Response, and we're using an Expression Step to write it to a global variable in the vault called /MyFolder/MyVar:

Writing to a global variable in an Expression Step

That's it. The response value will now be stored in the global variable when you execute the Choreo.

Finally, Twyla's Test pane truncates the value of a variable after 1000 characters (to prevent performance problems that can arise from displaying enormous API responses). Writing the response to a global variable will give you a way to view the entire response in the Twyla variable viewer, or give you the option of downloading the variable (using the download button in the vault browser pane), so writing global variables is a really useful technique to be aware of.

Note: You should be conservative with your Vault storage. Temboo Free accounts have a Vault size limit and will not be allowed to grow indefinitely.

Reading Global Variables

There are many reasons why you might want a Choreo to read from a global variable. A very popular use case is for storing state between Choreo executions.

Here's a quick example. Let's say you want to periodically call our /Library/Twitter/Timelines/HomeTimeline/ Choreo and only retrieve tweets since he last time you checked. To so do you would iterate over the tweets, parse each Tweet ID during the loop, and store the last Tweet ID in a global variable. Each time you call the Choreo you would pass in this global variable as the SinceId in order to only return results with an ID greater than last ID you stored in the previous execution. Here's an example of how you would configure the Launch Step in this scenario:

Reading from a global variable

That's it, another straightforward process, and enough to get you started reading global variables. With the power of persistence you're now in a position to build much more complex Choreos.

Need Help?

We're always happy to help. Just email us at, and we'll answer your questions.