Twilio Studio

Hi there,

I hope you are well.

I want to know if it is possible to get the user's last message or last interaction on Twilio Studio.

Thanks,

Tagged:

Answers

  • @Rustam Would you provide a little more information on the scenario you're needing to handle?

    Be aware that when the studio flow is entered, it's populated via the initial onMessageSent event. This could potentially cover your case; you could access the message body via liquid like this: {{trigger.message.Body}}.

    However, if you're wanting to obtain a response that occurs during the course of a studio flow process, say a "send and wait for reply", you can reference the widget by name to access the response parameters: {{widgets.widget_name_here.inbound.Body}}.

    If you're needing to handle more dynamic situations, you'll have to opt for a serverless function. You can fetch the Channel messages using the programmable chat api.

  • Hi, @aaron_cl . This is not a solution for my case. I need the last response of the user to check it in different splits. I can not check {{widgets.widget_name_here.inbound.Body}} in different split widgets.

  • @Rustam I'm assuming this is a scenario where you've split into two different possible widgets, and you're wanting to consolidate the splits back into a single widget.

    solution A

    I've run into a similar scenario before and luckily we can leverage liquid to work around the issue. say you have widget_a and widget_b that you're both routing back into your conditional check. You could do something like this:

    {{widgets.widget_a.inbound.Body | default:  widgets.widget_b.inbound.Body}}
    

    and just keep going for how many widgets you need.

    I get that it's not the most elegant solution, but it saves maintaining a serverless function and the costs associated with that.

    solution B

    A slightly more verbose but less liquid-y solution would be to set the same variable after each step, then reference that variable. This may be the superior solution in terms of being able to follow and readability.

    Note:
    If this doesn't address your issue, please provide a template json or a screenshot POC demonstrating your scenario.

  • @aaron_cl, if I have 50 different "send and wait for reply" widgets, will A solution work? If yes, how? Could you please explain?

  • At that point it probably would make more sense to opt for solution B, and have a "set variable" widget after each of the 50 "send and wait for reply" widgets. Otherwise you're going to end up with a massive and difficult to maintain liquid expression.

    Another option from both of these might be subflows, but I've not messed much with those. to know if they provide a way to unify a reference to the child widgets.

    At the point of 50 widgets though, it might be worth it to look into autopilot, or defer to a serverless function.

    That being said, twilio needs to address this issue and realize it's a common situation. I proposed a solution recently, but I'm not sure if their developers frequent this forum.

  • @aaron_cl, I will try this solution. Thank you for your support.