Transfer webhook flex-flow to studio flow?

aaron_cl ✭✭✭
edited June 2021 in Studio


I'm finding it's not possible to accomplish some actions in the studio flow, such as waiting longer than 10 seconds for an api to respond.


Configure a flex-flow with webhook integration, do the long-running api calls on remote server, then somehow transfer the chat into a studio flow.

poc testing

The flex flow is created, but when attempting to then send a message with the "send message" widget, I get the following error:

Failure sending message: The 'From' number CHee1727c0f1c64... is not a valid phone number, shortcode, or alphanumeric sender ID.

Does this strategy only work via sms? How can I make this work for webchat messages? Is there a way I can initiate a standard "incoming message" trigger rather than an "api" one?



  • Hey @aaron_cl, I am not sure what's gone wrong with the Send Message widget there. It should be able to respond to chat messages as well as SMS messages. Can you show me a screenshot of how you have set up the Studio flow?

    I just added a Send Message widget in between the trigger and Send to Flex widget for my Webchat flow and it worked:

    You are right that if you are making API calls that will take over 10 seconds that you will have to do them on your own server as Twilio Functions or the HTTP Studio widget will timeout after 10 seconds. Could you do something with a chat service post-event webhook to trigger your server?

  • aaron_cl
    aaron_cl ✭✭✭

    Hey @pnash,
    just to clarify my setup:
    Flexflow points to my server:

    On the server, I perform the long-running process, then create the execution:

    public function flexFlow(Request $request)
            $tw = app(\Twilio\Rest\Client::class);
            $studioFlowSid = 'FWxx';
            $to =  $request->From;
            $fr =  $request->ChannelSid;
            // simulating long-running process
            // creating execution in attempt to hand off execution to studio flow 
                ->create($to, $fr, ['parameters' => $request->all()]);
            return [];

    According the the documentation regarding creating an execution, the task enters via the API trigger, so I configure accordingly:

    To test, use twilio's test webchat page configured with the respective accountSid and flexFlowSid:

    Now, I really would like to be able to make the server webhook stuff transparent and just hand off the task using the "incoming message" trigger, but I've not found any documentation on doing so.

    however, I am aware that properties will need to be accessed somewhat differently because of how they're passed via the API hook, and I've updated that accordingly:

    I'm not sure any of the webhooks would be suitable for my application, because I require the long-running process to occur before the chat is sent into the studio flow. If there's a way to leverage the webhooks to somehow "pause" execution before it reaches the studio flow that would be great, but from what I've seen it's not possible to obtain the "onChannelCreated" webook event when using flex.

  • Hey @aaron_cl, thanks for the extra clarification. I apologise as I hadn't seen that setting for Flex flows before. I know plenty about the APIs around Twilio but still have work to do on learning Flex.

    I also don't know about triggering an execution and having the send message widget work for a chat channel. I am asking about that internally now. If that's not currently possible, could it work for you to avoid Studio for this flow and send messages using the API, then when you're ready create a TaskRouter task that can be assigned to an agent?

  • aaron_cl
    aaron_cl ✭✭✭

    I suppose I could avoid the studio flow for now, but it's a big part of the endgame vision. Allowing on the fly modification of chat routing without requiring a deployment is a hugely beneficial feature. The visual representation of the process flow is intuitive and accessible for non-devs to pick up.

    Thanks for asking around, it's greatly appreciated.

  • I totally get that. It's only when I don't know of a way to use Studio to achieve something that I suggest code. I am still trying to get an answer about starting an execution with chat channel properties and using the send message widget, will update when I find out!

If this is an emergency, please contact Twilio Support. This is not an official Support channel.
Have an urgent question?
Please contact Twilio Support. This is not an official Support channel.
Contact Support