Variables activities
Last updated
Was this helpful?
Last updated
Was this helpful?
Think of a process you often repeat—like sending a customer update or checking a user profile—and list the types of information that might change each time (e.g., name, date, status). Then, identify which of these could be stored as variables to make the process faster and more consistent. This will help you start recognizing where variables and data aliases can simplify tasks in Rewst.
Exploring the power of variables in JSON responses
Let's explore just how helpful variables can be when working with JSON responses in Rewst workflows!
Whenever Rewst receives a JSON response, it stores it in the context (CTX). Then, to reference a specific piece of information in a workflow, you need to navigate through the JSON structure, specifying each nested level.
If we wanted to reference the user’s email in a workflow, we would write:
CTX.data.user.details.profile.contact.email
That’s pretty long! If we needed to use this reference multiple times, writing out CTX.data.user.details.profile.contact.email repeatedly would be cumbersome. This is where variables come in!
Instead of writing the full reference every time, we can assign a variable as a shortcut.
For example, we can create a simple variable:
CTX.email
instead of CTX.data.user.details.profile.contact.email
Now, whenever we need to reference the user’s email, we can simply write:
CTX.email
This makes our workflow cleaner and easier to manage!
Below is another JSON sample. Your task is to determine the best way to create a variable for more efficient references.
Try to answer each question on your own first, then click the accordion to check your response.
By using variables, we make JSON data easier to access and our workflows much more efficient!
JSON responses are stored in CTX
Referencing deeply nested data can be tedious (CTX.level1.level2.level3...)
Variables provide shortcuts for cleaner and more readable workflows
Once a variable is set, we can use it to reference data more efficiently
Now, think about how you might use variables in automation. How could storing and reusing data make processes more efficient? Jot down an example or discuss it with a partner—soon, you'll be applying these concepts in Rewst!