twiliotwilio-studio

Twilio Studio - Issues with clearing variables


I'm developing an IVR using the Twilio platform. Currently, I'm facing some issues with clearing a specific variable. To better understand, I'll detail the flow path for clarity.

Flow:

  1. Widget Gather Input on Call [Inicio] - The user will enter their CPF or CNPJ.

  2. Widget Split Based On [capturaCpfCnpj] - variable to test = widgets.Inicio.Digits

  3. Widget Run Function [validaCpfCnpj] - The function responsible for standardizing the document (e.g., 123.456.789-00) has a function parameter with the key = document and value = {{widgets.Inicio.Digits}}

  4. Widget Split based on [documentoFormatado] - Responsible for checking if the function's return value is equal to "success."

  5. Widget Say/Play [voceDigitou] - Responsible for stating in line the document number that the client entered.

  6. Widget Gather input on call [confirmaCpf] - Asks the client if the information is valid, press 1; otherwise, press 2.

  7. Widget Split Based On [opcaoSelecionada] - Checks the option that the client selected. In my case, it would be option 2.

  8. Widget Gather Input on call [Gather_1] - In this widget, it requests the client's documentation again.

Starting from Widget above[8], the client's document should have been corrected and informed to him again in Widget 5. However, I can't clear the variable in any way. I don't know if I did something wrong during the flow development. I need the widget.Inicio.Digits to be cleared to receive the new information, how do I do that? I've tried using the Set Variables Widget, but it still doesn't work. Could someone give me an insight on how to solve this case?

As you can see, my flow is set up like this: between the gather input on call and split based on, I've set the 'Set Variables' widget [set_variables_1] as follows. After that, it continues to capture the client's document. In the blue widget, the client is asked if the information is correct; if they enter '2', it means it's incorrect and they'll have another chance. After the split based on, I've set another 'Set Variables' widget [set_variables_2] with the key {{widget.Inicio.Digits}} and a value of null to reset the value. In the gather input widget where they enter the corrected document, I direct them back to [set_variables_1]

Below are some screenshots that might help.

Flow1

Flow2

Debugging1

Dubugging2

NewDocument


Solution

  • I think I see what's wrong. In "widget [set_variables_2]" you try to set the key {{widget.Inicio.Digits}}. However, you cannot set properties of other widgets. Instead you need to set the same variable you defined earlier in "'Set Variables' widget [set_variables_1]" cpfCnpj.

    Also make sure you only read {{flow.variables.cpfCnpj}} and not {{widget.Inicio.Digits}}.