Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

WebChats Resource


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(link takes you to an external page).

(information)

Info

Webchat 3.0 (currently in Public Beta) provides a simple, 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.


WebChannel Properties

webchannel-properties page anchor
Property nameTypePIIDescription
conversation_sidSID<CH>
Not PII

The unique string representing the Conversation resource created.

Pattern: ^CH[0-9a-fA-F]{32}$Min length: 34Max length: 34

identitystring

The unique string representing the User created and should be authorized to participate in the Conversation. For more details, see User Identity & Access Tokens.


Create a WebChannel resource

create-a-webchannel-resource page anchor
POST https://flex.twilio.com/v2/WebChats

Headers

headers page anchor
Property nameTypeRequiredPIIDescription
Ui-VersionstringOptional

The Ui-Version HTTP request header

Property nameTypeRequiredPIIDescription
AddressSidstringrequired

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.


ChatFriendlyNamestringOptional

The Conversation's friendly name. See the Conversation resource for an example.


CustomerFriendlyNamestringOptional

The Conversation participant's friendly name. See the Conversation Participant Resource for an example.


PreEngagementDatastringOptional

The pre-engagement data.

Create a Web Channel

create-a-web-channel page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_20
// Download the helper library from https://www.twilio.com/docs/node/install
_20
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_20
_20
// Find your Account SID and Auth Token at twilio.com/console
_20
// and set the environment variables. See http://twil.io/secure
_20
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_20
const authToken = process.env.TWILIO_AUTH_TOKEN;
_20
const client = twilio(accountSid, authToken);
_20
_20
async function createWebChannel() {
_20
const webChannel = await client.flexApi.v2.webChannels.create({
_20
addressSid: "IGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_20
chatFriendlyName: "Customer Support",
_20
customerFriendlyName: "Alice",
_20
});
_20
_20
console.log(webChannel.conversationSid);
_20
}
_20
_20
createWebChannel();

Output

_10
{
_10
"conversation_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_10
"identity": "seinfeld"
_10
}


Rate this page: