The Service-scoped ConversationWithParticipants resource accepts all the details for a conversation and allows up to 10 participants in one request. This resource is especially helpful for situations where you want to send group texts. It helps prevent issues that might occur with existing conversations when you add participants individually.
Please see the Conversation with Participants Resource for Conversations within the default Conversation Service instance.
All URLs in the reference documentation use the following base URL:
https://conversations.twilio.com/v1
For Conversations applications that build on more than one Conversation Service instance, you will need to specify the Conversation Service SID in the REST API call:
POSt /v1/Services/ISxx/ConversationWithParticipants
The unique ID of the Account responsible for this conversation.
^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The unique ID of the Conversation Service this conversation belongs to.
^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The unique ID of the Messaging Service this conversation belongs to.
^MG[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
A 34 character string that uniquely identifies this resource.
^CH[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The human-readable name of this conversation, limited to 256 characters. Optional.
An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource's sid
in the URL.
An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. Note that if the attributes are not set "{}" will be returned.
Current state of this conversation. Can be either active
, inactive
or closed
and defaults to active
inactive
active
closed
Contains absolute URLs to access the participants, messages and webhooks of this conversation.
An absolute API resource URL for this conversation.
POST https://conversations.twilio.com/v1/Services/{ChatServiceSid}/ConversationWithParticipants
This resource behaves differently than most other Conversations API resources. Here's how it works:
Parameter validation: It validates all conversation and participant parameters and returns various possible conversations errors.
Conversations are created synchronously: If the request is valid, a conversation will be created and returned in the response. This conversation will be in the state initializing
while the participants are added. In this state, the conversation cannot be updated.
Participants are added to the conversation asynchronously: When all participants are added, the conversation state will be set to active
and the conversation can be used. Listening to the onConversationStateUpdated
webhook event and polling the conversations GET
endpoint are both acceptable ways to check if the conversation is ready to be used.
System Errors: If any unexpected errors happen while adding the participants, the conversation state will be set to closed
. Errors from this process will appear in the Console Error Logs, which can also be subscribed via webhooks.
The X-Twilio-Webhook-Enabled HTTP request header
true
false
The SID of the Conversation Service the Conversation resource is associated with.
^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
application/x-www-form-urlencoded
The human-readable name of this conversation, limited to 256 characters. Optional.
An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource's sid
in the URL.
The unique ID of the Messaging Service this conversation belongs to.
^MG[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. Note that if the attributes are not set "{}" will be returned.
Current state of this conversation. Can be either active
, inactive
or closed
and defaults to active
inactive
active
closed
ISO8601 duration when conversation will be switched to inactive
state. Minimum value for this timer is 1 minute.
ISO8601 duration when conversation will be switched to closed
state. Minimum value for this timer is 10 minutes.
The default email address that will be used when sending outbound emails in this conversation.
The default name that will be used when sending outbound emails in this conversation.
The participant to be added to the conversation in JSON format. The parameters are as in Participant Resource. The maximum number of participants that can be added in a single request is 10.
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 createServiceConversationWithParticipants() {11const conversationWithParticipant = await client.conversations.v112.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.conversationWithParticipants.create({14friendlyName: "Friendly Conversation",15participant: [16'{"messaging_binding": {"address": "<External Participant Number>", "proxy_address": "<Your Twilio Number>"}}',17'{"identity": "<Chat User Identity>"}',18],19});2021console.log(conversationWithParticipant.sid);22}2324createServiceConversationWithParticipants();
1{2"sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"chat_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",5"messaging_service_sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",6"friendly_name": "Friendly Conversation",7"unique_name": "unique_name",8"attributes": "{ \"topic\": \"feedback\" }",9"date_created": "2015-12-16T22:18:37Z",10"date_updated": "2015-12-16T22:18:38Z",11"state": "inactive",12"timers": {13"date_inactive": "2015-12-16T22:19:38Z",14"date_closed": "2015-12-16T22:28:38Z"15},16"bindings": {},17"links": {18"participants": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants",19"messages": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages",20"webhooks": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks"21},22"url": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"23}
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 createServiceConversationWithParticipants() {11const conversationWithParticipant = await client.conversations.v112.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.conversationWithParticipants.create({14friendlyName: "Friendly Conversation",15participant: [16'{"messaging_binding": {"address": "<External Participant Number>"}}',17'{"messaging_binding": {"address": "<External Participant Number>"}}',18'{"messaging_binding": {"projected_address": "<Your Twilio Number>"}}',19],20});2122console.log(conversationWithParticipant.sid);23}2425createServiceConversationWithParticipants();
1{2"sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"chat_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",5"messaging_service_sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",6"friendly_name": "Friendly Conversation",7"unique_name": "unique_name",8"attributes": "{ \"topic\": \"feedback\" }",9"date_created": "2015-12-16T22:18:37Z",10"date_updated": "2015-12-16T22:18:38Z",11"state": "inactive",12"timers": {13"date_inactive": "2015-12-16T22:19:38Z",14"date_closed": "2015-12-16T22:28:38Z"15},16"bindings": {},17"links": {18"participants": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants",19"messages": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages",20"webhooks": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks"21},22"url": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"23}