Flex Webchats is an endpoint that simplifies orchestrating a Conversation for a guest user: It creates a conversation, adds a randomly generated user identity to this conversation, and configures the Conversation based on the Address SID you provide. To get started with this endpoint, please refer to the web chat React-based demo app.
Webchat 3.0 (currently in Public Beta) provides a secure way to add a Twilio-hosted chat widget to your website. Before deciding to use the Webchat React App, you may want to consider using Webchat 3.0. For a comparison between these apps, see Migrate to Webchat 3.0.
The unique string representing the Conversation resource created.
^CH[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The unique string representing the User created and should be authorized to participate in the Conversation. For more details, see User Identity & Access Tokens.
POST https://flex-api.twilio.com/v2/WebChats
The Ui-Version HTTP request header
application/x-www-form-urlencoded
The SID of the Conversations Address. See Address Configuration Resource for configuration details. When a conversation is created on the Flex backend, the callback URL will be set to the corresponding Studio Flow SID or webhook URL in your address configuration.
The Conversation's friendly name. See the Conversation resource for an example.
The Conversation participant's friendly name. See the Conversation Participant Resource for an example.
The pre-engagement data.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function createWebChannel() {11const webChannel = await client.flexApi.v2.webChannels.create({12addressSid: "IGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",13chatFriendlyName: "Customer Support",14customerFriendlyName: "Alice",15});1617console.log(webChannel.conversationSid);18}1920createWebChannel();
1{2"conversation_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"identity": "seinfeld"4}