0

I am trying to add multiple languages to my studio flow. 1 - English, 2 - Spanish, 3 - French.

When the user selects the language I am saving the selected lang in {{flow.variables.lang}}. Based on the selected lang, I then load the respective translations.

I have multiple strings which use values set in the previous widget. I am not understanding how to set these values dynamically.

For Example:

String: "Welcome to Studio flow, we found your information in our system with zip code {{widgets.User_Information.parsed.zipCode}}"

In the translation file, I have this string set to key "User_Zip_Code".

In the widget "Gather Input on call" I added {{widgets.Translation_Function.parsed.User_Zip_Code}} in the text to say field. But when the voice reads it out, I expected Twilio would parse the and insert the dynamic value, but it just read it out as is. Is there a way to dynamically insert these flow variables in the string dynamically?

One way I could think of is to call a function and have that function return the string after replacing the values, but for some reason, there are a lot of gaps that I am seeing when the flow moves from one function to another, so I am trying to avoid function calls.

EDIT:

Adding the data shown in the Widget & Flow Properties

 "User_Information": {
      "status_code": 200,
      "content_type": "application/json",
      "parsed": {
        "zipCode": 201010
      },
}
    "Translation_Function": {
      "status_code": 200,
      "content_type": "application/json",
      "parsed": {
          "User_Zip_Code": "Welcome to Studio flow, we found your information in our system with zip code {{widgets.User_Information.parsed.zipCode}}. Press pound to continue.”
    },
}

Thanks in advance

Jilna
  • 190
  • 1
  • 13

1 Answers1

1

It should work as you explained. Are you sure the reference in the liquid syntax is indeed correct, for example: {{widgets.User_Information.parsed.zipCode}} ?

Try looking at the Studio Flow Execution Logs (under Logs) to see the path you must refer to in the liquid syntax is correct/

enter image description here

Update:

It appears you are nesting Liquid Syntax expressions. What I mean by that is your Gather Input on Call Widget is referencing parsed JSON from an earlier Widget and that JSON has a liquid syntax expression in it.

Example JSON:

"FT_Fee_Information": "We found your account in our XX payment system. As a reminder, payments processed through this system are subject to a $x.xx convenience fee. Payments without a fee can be made through the My Account portal on our website at example.com. If you would like to use the stored payment information to make a payment on account ending in {{widgets.Validate_Number.parsed.accountNumber}}. Please enter the 5 digit zip code associated with this account. If you would like to pay on a different account press the pound key.

I am pretty sure that is the reason for your issue, you can't nest these liquid syntax expression. Instead, can you pass in the Studio data to the Function calling the JSON so that Function can pre-populate this information (static data) into JSON (instead of using a liquid expression) before returning the JSON blob to Studio?

Alan
  • 10,465
  • 2
  • 8
  • 9
  • Hi @Alan, I cross checked again and the liquid syntax is correct. Earlier the flow had the string "Welcome to Studio flow, we found your information in our system with zip code {{widgets.User_Information.parsed.zipCode}}" directly placed in the "Gather input on Call" widget and it was working as expected. But now after making the changes to support translations, somehow the liquid syntax doesn't seem to work. – Jilna Apr 14 '22 at 04:36
  • Do you have the structure of the JSON file you are reading in handy to post in your question? When Twilio reads out the liquid syntax itself, it is having some issue parsing it. I’ve seen this when referring to elements in an array as gather `Digits` (when collecting DTMF is a string that must be converted to a number if using it to refer to an element inside an array). Reference: https://support.twilio.com/hc/en-us/articles/4413699936411-How-do-I-use-Liquid-with-Twilio-Studio- – Alan Apr 14 '22 at 10:11
  • Hi @Alan, I have updated the question to add the JSON structure that I see in the Widget & Flow Properties section. I am not using an array in the flow, but everything is an object. – Jilna Apr 14 '22 at 11:49
  • Just noticed one the working one is using widgets and the non-working one widget. Try fixing that and see if it works. Always the little things that get us! – Alan Apr 14 '22 at 14:58
  • Hi Alan, sorry but did not understand your suggestion. Can you please explain again? – Jilna Apr 14 '22 at 15:45
  • So change: `{{widget.Translation_Function.parsed.User_Zip_Code}}` to `{{widgets.Translation_Function.parsed.User_Zip_Code}}` – Alan Apr 14 '22 at 15:50
  • Ah.. sorry. It is `widgets` in the studio flow. Sorry, it was a typo. – Jilna Apr 14 '22 at 16:17
  • Updated my response, I believe the nested liquid syntax is the issue. – Alan Apr 14 '22 at 18:30
  • Thank you @Alan. That makes sense now. I cannot populate these values when I load these translations as these are populated at various points in the flow. I think the only solution is to call a function and return the parsed value. – Jilna Apr 18 '22 at 05:10