0

I'm in the process of creating a basic SMS flow within Twilio Studio. The intent of the app is to return some information about a work site. The information is being obtained via an external REST API (HTTP GET Widget) and returned as JSON.

The problem is, the results that I want to parse are within a JSON array which contains multiple objects with identical names. Example;

 "site": [
      {
        "length_ft": 14572,
        "width_ft": 150,
        "ident1": "A",
        "ident2": "B"
      },
      {
        "length_ft": 11351,
        "width_ft": 150,
        "ident1": "D",
        "ident2": "E"
      },
      {
        "length_ft": 10000,
        "width_ft": 150,
        "ident1": "F",
        "ident2": "G"
      }
    ]

I understand that within Twilio studio, the an example variable automatically created from that response body would be: {{widget.widget_name.parsed.site.length_ft}}

The result for that variable is being returned blank. My guess is because there are multiple "length_ft" objects and Twilio Studio can't differentiate.

Does anyone know how Twilio handles this type of JSON response as a variable within Twilio Studio?

1 Answers1

0

I’ve managed to work this out. For other people experiencing this, here is the solution.

Each object stored within the “site” array must be identified using its key.

Example;

{{widget.widget_name.parsed.site[0].length_ft}}
{{widget.widget_name.parsed.site[1]length_ft}}
{{widget.widget_name.parsed.site[2].length_ft}}

The above would be your Twilio Studio automatic variables for the JSON response body.