### Run the script Source: https://www.twilio.com/docs/conversations-classic/javascript/push-notifications-web Calls the initializeAppWithPush function to start the push notification setup. ```javascript // Run the script initializeAppWithPush(); ``` -------------------------------- ### Install twilio-cli on Linux with apt Source: https://www.twilio.com/docs/conversations-classic/android/exploring-conversations-android-quickstart Installs twilio-cli on Linux using apt. Adds the Twilio repository and installs the twilio package. ```bash wget -qO- https://twilio-cli-prod.s3.amazonaws.com/twilio_pub.asc \ | sudo apt-key add - sudo touch /etc/apt/sources.list.d/twilio.list echo 'deb https://twilio-cli-prod.s3.amazonaws.com/apt/ /' \ | sudo tee /etc/apt/sources.list.d/twilio.list sudo apt update sudo apt install -y twilio ``` -------------------------------- ### Install twilio-cli on Windows with Scoop Source: https://www.twilio.com/docs/conversations-classic/android/exploring-conversations-android-quickstart Installs twilio-cli on Windows using Scoop. First adds the twilio-scoop bucket, then installs the app. PowerShell must be run as an administrator to avoid permission issues. ```powershell scoop bucket add twilio-scoop https://github.com/twilio/scoop-twilio-cli ``` ```powershell scoop install twilio ``` -------------------------------- ### Install SDK with pod install Source: https://www.twilio.com/docs/conversations-classic/ios/exploring-conversations-swift-quickstart Installs the Conversations (classic) SDK and sets up the Xcode Workspace for the Quickstart app. ```bash pod install ``` -------------------------------- ### Create Service with Go Source: https://www.twilio.com/docs/conversations-classic/api/service-resource Go example using the Twilio helper library to create a conversation service. Requires TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN environment variables. ```go // Download the helper library from https://www.twilio.com/docs/go/install package main import ( "fmt" "github.com/twilio/twilio-go" conversations "github.com/twilio/twilio-go/rest/conversations/v1" "os" ) func main() { // Find your Account SID and Auth Token at twilio.com/console // and set the environment variables. See http://twil.io/secure // Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment client := twilio.NewRestClient() params := &conversations.CreateServiceParams{} params.SetFriendlyName("FriendlyName") resp, err := client.ConversationsV1.CreateService(params) if err != nil { fmt.Println(err.Error()) os.Exit(1) } else { if resp.AccountSid != nil { fmt.Println(*resp.AccountSid) } else { fmt.Println(resp.AccountSid) } } } ``` -------------------------------- ### GET /v1/Conversations Source: https://www.twilio.com/docs/conversations-classic/api/conversation-resource This snippet documents the GET /v1/Conversations endpoint for listing conversations, including query parameters and a curl request example. ```APIDOC ## [GET] /v1/Conversations ### Description Retrieves a list of conversations in the Conversations API. This endpoint supports pagination and returns a collection of conversation records. ### Method GET ### Endpoint https://conversations.twilio.com/v1/Conversations ### Parameters #### Query Parameters - **PageSize** (integer) - Optional - The number of records to return per page. Example: 20. ### Request Example ``` curl -X GET "https://conversations.twilio.com/v1/Conversations?PageSize=20" -u $TWILIO_API_KEY:$TWILIO_API_SECRET ``` ### Response #### Success Response (200) - **conversations** (array) - List of conversation records. - **account_sid** (string) - The SID of the account associated with the conversation. #### Response Example ``` { "conversations": [ { "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" } ] } ``` ``` -------------------------------- ### Fetch ServiceConfiguration with Twilio Go Source: https://www.twilio.com/docs/conversations-classic/api/service-configuration-resource Go example using the Twilio helper library to fetch a ServiceConfiguration resource. Requires TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN environment variables. Prints the ChatServiceSid or exits on error. ```go // Download the helper library from https://www.twilio.com/docs/go/install package main import ( "fmt" "github.com/twilio/twilio-go" "os" ) func main() { // Find your Account SID and Auth Token at twilio.com/console // and set the environment variables. See http://twil.io/secure // Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment client := twilio.NewRestClient() resp, err := client.ConversationsV1.FetchServiceConfiguration("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") if err != nil { fmt.Println(err.Error()) os.Exit(1) } else { if resp.ChatServiceSid != nil { fmt.Println(*resp.ChatServiceSid) } else { fmt.Println(resp.ChatServiceSid) } } } ``` -------------------------------- ### GET /v1/Services Source: https://www.twilio.com/docs/conversations-classic/api/service-resource This snippet documents the GET /v1/Services endpoint for listing Conversation Services. It includes the query parameter, request example, and response structure. ```APIDOC ## GET /v1/Services ### Description Retrieves a list of Conversation Services associated with the account. This endpoint supports pagination via the PageSize query parameter. ### Method GET ### Endpoint https://conversations.twilio.com/v1/Services ### Parameters #### Query Parameters - **PageSize** (integer) - Optional - The number of Service resources to return per page. Default is 50. ### Request Example ``` curl -X GET "https://conversations.twilio.com/v1/Services?PageSize=20" \ -u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN ``` ### Response #### Success Response (200) - **services** (array) - List of Service resources. - **meta** (object) - Pagination metadata. #### Response Example ```json { "services": [ { "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Home Service", "date_created": "2015-12-16T22:18:37Z", "date_updated": "2015-12-16T22:18:38Z", "url": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "conversations": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations", "users": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users", "roles": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles", "bindings": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings", "configuration": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Configuration", "participant_conversations": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ParticipantConversations", "conversation_with_participants": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ConversationWithParticipants" } } ], "meta": { "page": 0, "page_size": 50, "first_page_url": "https://conversations.twilio.com/v1/Services?PageSize=50&Page=0", "previous_page_url": null, "url": "https://conversations.twilio.com/v1/Services?PageSize=50&Page=0", "next_page_url": null, "key": "services" } } ``` ``` -------------------------------- ### Fetch ServiceBinding in Go Source: https://www.twilio.com/docs/conversations-classic/api/service-binding-resource Go example using the Twilio helper library to fetch a ServiceBinding. Requires TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN environment variables. Prints the binding's Sid or error. ```go // Download the helper library from https://www.twilio.com/docs/go/install package main import ( "fmt" "github.com/twilio/twilio-go" "os" ) func main() { // Find your Account SID and Auth Token at twilio.com/console // and set the environment variables. See http://twil.io/secure // Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment client := twilio.NewRestClient() resp, err := client.ConversationsV1.FetchServiceBinding("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") if err != nil { fmt.Println(err.Error()) os.Exit(1) } else { if resp.Sid != nil { fmt.Println(*resp.Sid) } else { fmt.Println(resp.Sid) } } } ``` -------------------------------- ### GET /v1/Conversations/{ConversationSid}/Participants Source: https://www.twilio.com/docs/conversations-classic/api/conversation-participant-resource This snippet documents the HTTP GET endpoint for listing conversation participants, including the curl example and the supported query parameter. ```APIDOC ## [GET] /v1/Conversations/{ConversationSid}/Participants ### Description Retrieves a list of participants in a specific conversation. This endpoint supports pagination via the PageSize query parameter. ### Method GET ### Endpoint https://conversations.twilio.com/v1/Conversations/{ConversationSid}/Participants ### Parameters #### Path Parameters - **ConversationSid** (string) - Required - The unique identifier of the conversation (e.g., CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX). #### Query Parameters - **PageSize** (integer) - Optional - The number of participant records to return per page (e.g., 20). ### Request Example ``` curl -X GET "https://conversations.twilio.com/v1/Conversations/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Participants?PageSize=20" \ -u $TWILIO_API_KEY:$TWILIO_API_SECRET ``` ### Response #### Success Response (200) - **participants** (array) - A list of participant objects, each containing fields such as `account_sid`. #### Response Example ```json { "participants": [ { "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" } ] } ``` ``` -------------------------------- ### GET /v1/Conversations/{ConversationSid}/Webhooks Source: https://www.twilio.com/docs/conversations-classic/api/conversation-scoped-webhook-resource This snippet documents the HTTP GET endpoint for listing conversation-scoped webhooks, including the path, query parameters, and a curl example. ```APIDOC ## GET /v1/Conversations/{ConversationSid}/Webhooks ### Description Lists all webhooks associated with a specific conversation. This endpoint retrieves the webhook resources for a given conversation SID. ### Method GET ### Endpoint `https://conversations.twilio.com/v1/Conversations/{ConversationSid}/Webhooks` ### Parameters #### Path Parameters - **ConversationSid** (string) - Required - The unique identifier of the conversation whose webhooks are to be listed. #### Query Parameters - **PageSize** (integer) - Optional - The number of webhook records to return per page. In the example, `PageSize=5` is used. ### Request Example ``` curl -X GET "https://conversations.twilio.com/v1/Conversations/ConversationSid/Webhooks?PageSize=5" \ -u $TWILIO_API_KEY:$TWILIO_API_SECRET ``` ### Response #### Success Response (200) - **webhooks** (array) - A list of webhook objects. Each webhook object contains a `sid` field. - **sid** (string) - The unique identifier of the webhook. #### Response Example ```json { "webhooks": [ { "sid": "WH..." } ] } ``` ``` -------------------------------- ### Create Service with C# Source: https://www.twilio.com/docs/conversations-classic/api/service-resource C# example using the Twilio helper library to create a conversation service. Requires TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN environment variables. ```csharp // Install the C# / .NET helper library from twilio.com/docs/csharp/install using System; using Twilio; using Twilio.Rest.Conversations.V1; using System.Threading.Tasks; class Program { public static async Task Main(string[] args) { // Find your Account SID and Auth Token at twilio.com/console // and set the environment variables. See http://twil.io/secure string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID"); string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN"); TwilioClient.Init(accountSid, authToken); var service = await ServiceResource.CreateAsync(friendlyName: "FriendlyName"); Console.WriteLine(service.AccountSid); } } ``` -------------------------------- ### GET /v1/Credentials Source: https://www.twilio.com/docs/conversations-classic/api/credential-resource This snippet documents the GET /v1/Credentials endpoint for listing credentials. It includes the endpoint URL, query parameters, request example, and response schema. ```APIDOC ## [GET] /v1/Credentials ### Description Lists all credentials associated with the account. This endpoint returns a paginated list of credential resources. ### Method GET ### Endpoint https://conversations.twilio.com/v1/Credentials ### Parameters #### Query Parameters - **PageSize** (integer) - Optional - The number of records to return per page. Default is 50. ### Request Example ``` curl -X GET "https://conversations.twilio.com/v1/Credentials?PageSize=20" \ -u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN ``` ### Response #### Success Response (200) - **credentials** (array) - List of credential objects. - **sid** (string) - The unique string that identifies the credential resource. - **account_sid** (string) - The SID of the Account that created the credential resource. - **friendly_name** (string) - The string that you assigned to describe the credential. - **type** (string) - The type of push-notification service the credential is for. - **sandbox** (string) - Whether the credential is sandboxed. - **date_created** (string) - The date and time in GMT when the resource was created. - **date_updated** (string) - The date and time in GMT when the resource was last updated. - **url** (string) - The absolute URL of the credential resource. - **meta** (object) - Metadata about the response. - **page** (integer) - The current page number. - **page_size** (integer) - The number of records per page. - **first_page_url** (string) - The URL for the first page of results. - **previous_page_url** (string) - The URL for the previous page of results. - **url** (string) - The URL for the current page. - **next_page_url** (string) - The URL for the next page of results. - **key** (string) - The key for the list of credentials. #### Response Example ```json { "credentials": [ { "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Test slow create", "type": "apn", "sandbox": "False", "date_created": "2015-10-07T17:50:01Z", "date_updated": "2015-10-07T17:50:01Z", "url": "https://conversations.twilio.com/v1/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "meta": { "page": 0, "page_size": 50, "first_page_url": "https://conversations.twilio.com/v1/Credentials?PageSize=50&Page=0", "previous_page_url": null, "url": "https://conversations.twilio.com/v1/Credentials?PageSize=50&Page=0", "next_page_url": null, "key": "credentials" } } ``` ``` -------------------------------- ### List Credentials with Go Source: https://www.twilio.com/docs/conversations-classic/api/credential-resource Uses the Twilio Go helper library to list credentials. Requires the twilio-go package and environment variables TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN. The example lists up to 20 credentials and prints each SID. ```go // Download the helper library from https://www.twilio.com/docs/go/install package main import ( "fmt" "github.com/twilio/twilio-go" conversations "github.com/twilio/twilio-go/rest/conversations/v1" "os" ) func main() { // Find your Account SID and Auth Token at twilio.com/console // and set the environment variables. See http://twil.io/secure // Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment client := twilio.NewRestClient() params := &conversations.ListCredentialParams{} params.SetLimit(20) resp, err := client.ConversationsV1.ListCredential(params) if err != nil { fmt.Println(err.Error()) os.Exit(1) } else { for record := range resp { if resp[record].Sid != nil { fmt.Println(*resp[record].Sid) } else { fmt.Println(resp[record].Sid) } } } } ``` -------------------------------- ### Fetch ServiceBinding in C# Source: https://www.twilio.com/docs/conversations-classic/api/service-binding-resource C# example using the Twilio helper library to fetch a ServiceBinding. Requires TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN environment variables. Prints the binding's Sid. ```csharp // Install the C# / .NET helper library from twilio.com/docs/csharp/install using System; using Twilio; using Twilio.Rest.Conversations.V1.Service; using System.Threading.Tasks; class Program { public static async Task Main(string[] args) { // Find your Account SID and Auth Token at twilio.com/console // and set the environment variables. See http://twil.io/secure string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID"); string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN"); TwilioClient.Init(accountSid, authToken); var binding = await BindingResource.FetchAsync( pathChatServiceSid: "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", pathSid: "BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); Console.WriteLine(binding.Sid); } } ``` -------------------------------- ### GET /v1/Services/{ChatServiceSid}/Conversations/{ConversationSid}/Participants Source: https://www.twilio.com/docs/conversations-classic/api/service-participant-resource This snippet documents the HTTP GET endpoint for listing participants in a conversation. It includes the endpoint URL, parameters, and a response example. ```APIDOC ## GET /v1/Services/{ChatServiceSid}/Conversations/{ConversationSid}/Participants ### Description Retrieves a list of participants in a specific conversation within a chat service. ### Method GET ### Endpoint `https://conversations.twilio.com/v1/Services/{ChatServiceSid}/Conversations/{ConversationSid}/Participants` ### Parameters #### Path Parameters - **ChatServiceSid** (string) - Required - The SID of the Chat Service. - **ConversationSid** (string) - Required - The SID of the Conversation. #### Query Parameters - **PageSize** (integer) - Optional - The number of participants to return per page. ### Request Example ``` curl -X GET "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/ConversationSid/Participants?PageSize=20" \ -u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN ``` ### Response #### Success Response (200) - **meta** (object) - Pagination metadata. - **participants** (array) - List of participant objects. #### Response Example ```json { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants?PageSize=50&Page=0", "previous_page_url": null, "url": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants?PageSize=50&Page=0", "next_page_url": null, "key": "participants" }, "participants": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "chat_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "conversation_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": null, "attributes": "{ \"role\": \"driver\" }", "messaging_binding": { "type": "sms", "address": "+15558675310", "proxy_address": "+15017122661" }, "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-03-24T21:05:50Z", "date_updated": "2016-03-24T21:05:50Z", "url": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "last_read_message_index": null, "last_read_timestamp": null }, { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "chat_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "conversation_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "IDENTITY", "attributes": "{ \"role\": \"driver\" }", "messaging_binding": null, "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-03-24T21:05:50Z", "date_updated": "2016-03-24T21:05:50Z", "url": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "last_read_message_index": null, "last_read_timestamp": null } ] } ``` ``` -------------------------------- ### Create Service with PHP Source: https://www.twilio.com/docs/conversations-classic/api/service-resource PHP example using the Twilio helper library to create a conversation service. Requires TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN environment variables. ```php conversations->v1->services->create( "FriendlyName", // FriendlyName ); print $service->accountSid; ``` -------------------------------- ### Update ServiceWebhookConfiguration request body example Source: https://www.twilio.com/docs/conversations-classic/api/per-service-webhook-resource Example request body for updating a ServiceWebhookConfiguration resource. Sets PreWebhookUrl and PostWebhookUrl to example.com URLs, Filters to onMessageRemoved and onParticipantAdded, and Method to GET. ```json { "PreWebhookUrl": "https://www.example.com/pre", "PostWebhookUrl": "https://www.example.com/post", "Filters": [ "onMessageRemoved", "onParticipantAdded" ], "Method": "GET" } ``` -------------------------------- ### GET request with Service SID Source: https://www.twilio.com/docs/conversations-classic/api/service-delivery-receipt-resource Example REST API call that specifies the Conversation Service SID for service-scoped resources. ```bash GET /v1/Services/ISxx/Conversations/CHxx/Messages ``` -------------------------------- ### Create Service with Java Source: https://www.twilio.com/docs/conversations-classic/api/service-resource Java example using the Twilio helper library to create a conversation service. Requires TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN environment variables. ```java // Install the Java helper library from twilio.com/docs/java/install import com.twilio.Twilio; import com.twilio.rest.conversations.v1.Service; public class Example { // Find your Account SID and Auth Token at twilio.com/console // and set the environment variables. See http://twil.io/secure public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID"); public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN"); public static void main(String[] args) { Twilio.init(ACCOUNT_SID, AUTH_TOKEN); Service service = Service.creator("FriendlyName").create(); System.out.println(service.getAccountSid()); } } ``` -------------------------------- ### Update Credential with twilio-cli Source: https://www.twilio.com/docs/conversations-classic/api/credential-resource Uses the twilio-cli to update a Credential resource. Requires the twilio-cli to be installed. The example sets the type to apn for the specified Credential SID. ```bash # Install the twilio-cli from https://twil.io/cli twilio api:conversations:v1:credentials:update \ --sid CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \ --type apn ``` -------------------------------- ### Update Configuration with Python Source: https://www.twilio.com/docs/conversations-classic/api/configuration-resource Python example using the Twilio helper library to update the global configuration. Requires TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN environment variables. ```python # Download the helper library from https://www.twilio.com/docs/python/install import os from twilio.rest import Client # Find your Account SID and Auth Token at twilio.com/console # and set the environment variables. See http://twil.io/secure account_sid = os.environ["TWILIO_ACCOUNT_SID"] auth_token = os.environ["TWILIO_AUTH_TOKEN"] client = Client(account_sid, auth_token) configuration = client.conversations.v1.configuration().update( default_chat_service_sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ) print(configuration.account_sid) ``` -------------------------------- ### Update ConfigurationWebhook request body Source: https://www.twilio.com/docs/conversations-classic/api/webhook-configuration-resource Example request body for updating a ConfigurationWebhook resource. Sets pre- and post-webhook URLs, HTTP method GET, a filter for onConversationUpdated, and target webhook. ```json { "PreWebhookUrl": "https://example.com/pre", "PostWebhookUrl": "https://example.com/post", "Method": "GET", "Filters": [ "onConversationUpdated" ], "Target": "webhook" } ``` -------------------------------- ### Fetch ServiceBinding in PHP Source: https://www.twilio.com/docs/conversations-classic/api/service-binding-resource PHP example using the Twilio helper library to fetch a ServiceBinding. Requires TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN environment variables. Prints the binding's sid. ```php conversations->v1 ->services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") ->bindings("BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") ->fetch(); print $binding->sid; ``` -------------------------------- ### Create User with Go Helper Library Source: https://www.twilio.com/docs/conversations-classic/api/user-resource Uses the Twilio Go helper library to create a user. Requires environment variables TWILIO_ACCOUNT_SID, TWILIO_API_KEY, and TWILIO_API_SECRET. Outputs the new user's SID or an error message. ```go // Download the helper library from https://www.twilio.com/docs/go/install package main import ( "fmt" "github.com/twilio/twilio-go" conversations "github.com/twilio/twilio-go/rest/conversations/v1" "os" ) func main() { // Find your Account SID at twilio.com/console // Provision API Keys at twilio.com/console/runtime/api-keys // and set the environment variables. See http://twil.io/secure // For local testing, you can use your Account SID and Auth token accountSid := os.Getenv("TWILIO_ACCOUNT_SID") apiKey := os.Getenv("TWILIO_API_KEY") apiSecret := os.Getenv("TWILIO_API_SECRET") client := twilio.NewRestClientWithParams(twilio.ClientParams{ Username: apiKey, Password: apiSecret, AccountSid: accountSid, }) params := &conversations.CreateUserParams{} params.SetIdentity("RedgrenGrumbholdt") resp, err := client.ConversationsV1.CreateUser(params) if err != nil { fmt.Println(err.Error()) os.Exit(1) } else { if resp.Sid != nil { fmt.Println(*resp.Sid) } else { fmt.Println(resp.Sid) } } } ``` -------------------------------- ### Update service notification configuration with Twilio CLI Source: https://www.twilio.com/docs/conversations-classic/api/service-notification-resource Updates the notification configuration for a Conversations service using the Twilio CLI. Requires the twilio-cli to be installed. The example disables logging by default (the command does not include a log-enabled flag). ```bash # Install the twilio-cli from https://twil.io/cli twilio api:conversations:v1:services:configuration:notifications:update \ --chat-service-sid ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ``` -------------------------------- ### Create conversation webhook with twilio-cli Source: https://www.twilio.com/docs/conversations-classic/api/conversation-scoped-webhook-resource Uses the twilio-cli to create a conversation-scoped webhook. Requires the twilio-cli to be installed. The command specifies the conversation SID, target 'webhook', method GET, filters onMessageAdded and onConversationRemoved, and URL https://example.com. ```bash # Install the twilio-cli from https://twil.io/cli twilio api:conversations:v1:conversations:webhooks:create \ --conversation-sid ConversationSid \ --target webhook \ --configuration.method get \ --configuration.filters onMessageAdded onConversationRemoved \ --configuration.url https://example.com ``` -------------------------------- ### Configuration resource response Source: https://www.twilio.com/docs/conversations-classic/api/configuration-resource Example response from fetching the Configuration resource. Shows the account SID, default service SIDs, timers, and resource URLs. ```json { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_chat_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_messaging_service_sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_inactive_timer": "PT1M", "default_closed_timer": "PT10M", "url": "https://conversations.twilio.com/v1/Configuration", "links": { "service": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Configuration", "webhooks": "https://conversations.twilio.com/v1/Configuration/Webhooks" } } ``` -------------------------------- ### Request body parameters for updating a service-scoped conversation-scoped webhook Source: https://www.twilio.com/docs/conversations-classic/api/service-scoped-conversation-scoped-webhook-resource JSON schema for the request body, including optional properties Configuration.Url, Configuration.Method (enum: get, post), Configuration.Filters, Configuration.Triggers, and Configuration.FlowSid. The example shows a request with Configuration.Url, Configuration.Method set to 'post', and Configuration.Triggers. ```json {"schema":{"type":"object","title":"UpdateServiceConversationScopedWebhookRequest","properties":{"Configuration.Url":{"type":"string","description":"The absolute url the webhook request should be sent to."},"Configuration.Method":{"type":"string","enum":["get","post"],"refName":"service_conversation_scoped_webhook_enum_method","modelName":"service_conversation_scoped_webhook_enum_method"},"Configuration.Filters":{"type":"array","description":"The list of events, firing webhook event for this Conversation.","items":{"type":"string"}},"Configuration.Triggers":{"type":"array","description":"The list of keywords, firing webhook event for this Conversation.","items":{"type":"string"}},"Configuration.FlowSid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^FW[0-9a-fA-F]{32}$","description":"The studio flow SID, where the webhook should be sent to."}}},"examples":{"update":{"value":{"lang":"json","value":"{\n \"Configuration.Url\": \"https://example.com\",\n \"Configuration.Method\": \"post\",\n \"Configuration.Triggers\": [\n \"keyword1\",\n \"keyword2\"\n ]\n}","meta":"","code":"{\n \"Configuration.Url\": \"https://example.com\",\n \"Configuration.Method\": \"post\",\n \"Configuration.Triggers\": [\n \"keyword1\",\n \"keyword2\"\n ]\n}","tokens":[["{","#C9D1D9"],"\n ",["\"Configuration.Url\"","#7EE787"],[":","#C9D1D9"]," ",["\"https://example.com\"","#A5D6FF"],[",","#C9D1D9"],"\n ",["\"Configuration.Method\"","#7EE787"],[":","#C9D1D9"]," ",["\"post\"","#A5D6FF"],[",","#C9D1D9"],"\n ",["\"Configuration.Triggers\"","#7EE787"],[": [","#C9D1D9"],"\n ",["\"keyword1\"","#A5D6FF"],[",","#C9D1D9"],"\n ",["\"keyword2\"","#A5D6FF"],"\n ",["]","#C9D1D9"],"\n",["}","#C9D1D9"]],"annotations":[],"themeName":"github-dark","style":{"color":"#c9d1d9","background":"#0d1117","colorScheme":"dark"}}},"encodingType":"application/x-www-form-urlencoded","conditionalParameterMap":{}} ``` -------------------------------- ### Fetch ServiceBinding in Java Source: https://www.twilio.com/docs/conversations-classic/api/service-binding-resource Java example using the Twilio helper library to fetch a ServiceBinding. Requires TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN environment variables. Prints the binding's Sid. ```java // Install the Java helper library from twilio.com/docs/java/install import com.twilio.Twilio; import com.twilio.rest.conversations.v1.service.Binding; public class Example { // Find your Account SID and Auth Token at twilio.com/console // and set the environment variables. See http://twil.io/secure public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID"); public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN"); public static void main(String[] args) { Twilio.init(ACCOUNT_SID, AUTH_TOKEN); Binding binding = Binding.fetcher("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch(); System.out.println(binding.getSid()); } } ``` -------------------------------- ### Get detailed information from the Receipts Resource - JSON response Source: https://www.twilio.com/docs/conversations-classic/delivery-receipts Example response from the Receipts Resource showing a list of delivery receipts. Each receipt includes fields such as sid, account_sid, conversation_sid, message_sid, channel_message_sid, status, error_code, participant_sid, and timestamps. The status is "failed" with error_code 3000 in this sample. ```json { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Receipts?PageSize=50&Page=0", "previous_page_url": null, "url": "https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Receipts?PageSize=50&Page=0", "next_page_url": null, "key": "delivery_receipts" }, "delivery_receipts": [ { "sid": "DYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "conversation_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "message_sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_message_sid": "SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "failed", "error_code": 3000, "participant_sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-03-24T20:37:57Z", "date_updated": "2016-03-24T20:37:57Z", "url": "https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Receipts/DYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, { "sid": "DYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "conversation_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "message_sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_message_sid": "SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "failed", "error_code": 3000, "participant_sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-03-24T20:37:57Z", "date_updated": "2016-03-24T20:37:57Z", "url": "https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Receipts/DYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, { "sid": "DYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "conversation_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "message_sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_message_sid": "SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "failed", "error_code": 3000, "participant_sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-03-24T20:37:57Z", "date_updated": "2016-03-24T20:37:57Z", "url": "https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Receipts/DYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ``` -------------------------------- ### Create Service with Python Source: https://www.twilio.com/docs/conversations-classic/api/service-resource Python example using the Twilio helper library to create a conversation service. Requires TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN environment variables. ```python # Download the helper library from https://www.twilio.com/docs/python/install import os from twilio.rest import Client # Find your Account SID and Auth Token at twilio.com/console # and set the environment variables. See http://twil.io/secure account_sid = os.environ["TWILIO_ACCOUNT_SID"] auth_token = os.environ["TWILIO_AUTH_TOKEN"] client = Client(account_sid, auth_token) service = client.conversations.v1.services.create(friendly_name="FriendlyName") print(service.account_sid) ``` -------------------------------- ### Fetch ServiceBinding in Python Source: https://www.twilio.com/docs/conversations-classic/api/service-binding-resource Python example using the Twilio helper library to fetch a ServiceBinding. Requires TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN environment variables. Prints the binding's sid. ```python # Download the helper library from https://www.twilio.com/docs/python/install import os from twilio.rest import Client # Find your Account SID and Auth Token at twilio.com/console # and set the environment variables. See http://twil.io/secure account_sid = os.environ["TWILIO_ACCOUNT_SID"] auth_token = os.environ["TWILIO_AUTH_TOKEN"] client = Client(account_sid, auth_token) binding = ( client.conversations.v1.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") .bindings("BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") .fetch() ) print(binding.sid) ``` -------------------------------- ### Install twilio-cli on macOS with Homebrew Source: https://www.twilio.com/docs/conversations-classic/android/exploring-conversations-android-quickstart Installs twilio-cli on macOS using Homebrew. Requires Homebrew to be installed first. ```bash brew tap twilio/brew && brew install twilio ``` -------------------------------- ### Fetch ServiceConfiguration with Twilio C# Source: https://www.twilio.com/docs/conversations-classic/api/service-configuration-resource C# / .NET example using the Twilio helper library to fetch a ServiceConfiguration resource. Requires TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN environment variables. Prints the ChatServiceSid. ```csharp // Install the C# / .NET helper library from twilio.com/docs/csharp/install using System; using Twilio; using Twilio.Rest.Conversations.V1.Service; using System.Threading.Tasks; class Program { public static async Task Main(string[] args) { // Find your Account SID and Auth Token at twilio.com/console // and set the environment variables. See http://twil.io/secure string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID"); string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN"); TwilioClient.Init(accountSid, authToken); var configuration = await ConfigurationResource.FetchAsync( pathChatServiceSid: "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); Console.WriteLine(configuration.ChatServiceSid); } } ``` -------------------------------- ### Fetch ServiceConfiguration with Twilio Python Source: https://www.twilio.com/docs/conversations-classic/api/service-configuration-resource Python example using the Twilio helper library to fetch a ServiceConfiguration resource. Requires TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN environment variables. Prints the chat_service_sid. ```python # Download the helper library from https://www.twilio.com/docs/python/install import os from twilio.rest import Client # Find your Account SID and Auth Token at twilio.com/console # and set the environment variables. See http://twil.io/secure account_sid = os.environ["TWILIO_ACCOUNT_SID"] auth_token = os.environ["TWILIO_AUTH_TOKEN"] client = Client(account_sid, auth_token) configuration = ( client.conversations.v1.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") .configuration() .fetch() ) print(configuration.chat_service_sid) ``` -------------------------------- ### Fetch ServiceBinding in Node.js Source: https://www.twilio.com/docs/conversations-classic/api/service-binding-resource Node.js example using the Twilio helper library to fetch a ServiceBinding. Requires TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN environment variables. Prints the binding's sid. ```javascript // Download the helper library from https://www.twilio.com/docs/node/install const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio"; // Find your Account SID and Auth Token at twilio.com/console // and set the environment variables. See http://twil.io/secure const accountSid = process.env.TWILIO_ACCOUNT_SID; const authToken = process.env.TWILIO_AUTH_TOKEN; const client = twilio(accountSid, authToken); async function fetchServiceBinding() { const binding = await client.conversations.v1 .services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") .bindings("BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") .fetch(); console.log(binding.sid); } fetchServiceBinding(); ``` -------------------------------- ### GET /v1/Services/{ChatServiceSid}/Configuration/Webhooks Source: https://www.twilio.com/docs/conversations-classic/api/per-service-webhook-resource This snippet documents the GET endpoint to fetch a ServiceWebhookConfiguration resource. ```APIDOC ## GET /v1/Services/{ChatServiceSid}/Configuration/Webhooks ### Description Fetches the ServiceWebhookConfiguration resource for a given Conversation Service. ### Method GET ### Endpoint https://conversations.twilio.com/v1/Services/{ChatServiceSid}/Configuration/Webhooks ### Parameters #### Path Parameters - **ChatServiceSid** (string) - Required - The unique ID of the Conversation Service this conversation belongs to. Must match pattern ^IS[0-9a-fA-F]{32}$ and be 34 characters long. ### Request Example No request body is required for this GET request. ### Response #### Success Response (200) Returns the ServiceWebhookConfiguration resource. The response includes the `accountSid` property, as shown in the code examples. #### Response Example ```json { "accountSid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" } ``` ```