0

I need to programmatically invoke the same functionality as the "Send to Flex" Widget (and also must keep the Studio Flow in place to serve other conditions).

According to the docs, the widget calls the Interactions API, which I have successfully been able to replicate:

//using deno, so `twilioFetch` is a custom function that just handles auth and content-type
twilioFetch(
    "https://flex-api.twilio.com/v1/Interactions",
    { method: "POST" },
    {
      Channel: JSON.stringify({
        type: "web",
        initiated_by: "customer",
        properties: {
          media_channel_sid: conversation.sid,
        },
      }),
      Routing: JSON.stringify({
        properties: {
          workspace_sid: "WS04d48e8442116ea47b7496cd95959ea8",
          workflow_sid: "WW1c2700752bae7dc8ceecba04ea3ae121",
          task_channel_sid: "TC0a7998d085c2d1e82e64b90bc6856fb3",
          // might need to set attributes, but in my testing it doesn't have any impact on the Studio Flow continuing to run
        },
      }),
    }
  );

This request results in the Conversation showing up in the Flex Console as expected, but unlike the "Send to Flex" widget, new messages sent in the conversation (by either the customer or flex agent) continue to cause the flow to run!

Seems like "Send to Flex" must be doing something else behind the scenes?

Is there a programmatic way to replicate this behavior? (IE: Prevent the conversation from continuing to fire the Flow).

NSjonas
  • 10,693
  • 9
  • 66
  • 92
  • Looks like Flex is using `ConversationScopedWebhook`. "Send to Flex" removes this webhook, so calling the ["Delete a ConversationScopedWebhook"](https://www.twilio.com/docs/conversations/api/conversation-scoped-webhook-resource#delete-a-conversationscopedwebhook-resource) API should give me the same behavior. – NSjonas Jun 07 '23 at 13:50

0 Answers0