# Conversation Orchestrator quickstart

In this quickstart, you'll create a conversation configuration with capture rules. Conversation Orchestrator then observes your existing Twilio traffic and groups matching messages and calls into conversations.

See [Create conversations programmatically](/docs/conversations/orchestrator/guides/active-creation) or [Connect Conversations API (classic)](/docs/conversations/orchestrator/guides/classic-bridge) for other ways to start using Conversation Orchestrator.

> \[!WARNING]
>
> When you use Conversation Orchestrator with the voice channel, Twilio transcribes your calls to populate the conversation. Transcription fees apply. For pricing details, see [Twilio Voice pricing](https://www.twilio.com/voice/pricing).

## Prerequisites

Complete the prerequisites:

* [Create a Twilio account](https://www.twilio.com/try-twilio).
* [Buy a voice- and SMS-enabled phone number](https://1console.twilio.com/phone-numbers/search).
* [Store your Twilio credentials in environment variables](/docs/usage/secure-credentials).

## Create a memory store and conversation configuration

A conversation configuration defines how Conversation Orchestrator groups your interaction traffic. To link conversations with customer profiles, you also need a memory store. Create both using the Console or the API.

## Console

To create a conversation configuration using the Twilio Console, follow these steps:

1. Sign in to the [Twilio Console](https://1console.twilio.com).
2. Go to **Products & services** > **Conversation Orchestrator** > [**Conversation configurations**](https://1console.twilio.com/go?to=/account/__account__/us1/conversation-orchestrator/configurations).
3. Click **Create a Conversation configuration**.
4. On the **Name Configuration** step, enter a name and description, and then click **Next**.
5. On the **Messaging and chat traffic** step, click **Next**. This quickstart uses voice traffic, so no selections are needed here.
6. On the **Voice traffic** step, do the following:
   1. Select the **Set up automatic capture** checkbox.
   2. From the **Voice phone numbers** list, select your Twilio phone number.
   3. Click **Next**.
7. On the **Configure lifecycle** step, accept the default **Basic** lifecycle, select a **"Closed" timeout** value for each active channel, and then click **Next**.
8. On the **Enable Conversation Memory** step, create a memory store:
   1. Click **Create new memory store**.
   2. In the **Memory store name** field, enter a name.
   3. Click **Save**.
9. From the **Memory store** list, select the memory store you just created.
10. Clear the **Turn on observations and summaries** checkbox.
11. Click **Next**.
12. On the **Voice transcription** step, review the transcription summary. If this is your first time using AI features on this account, select the Predictive and Generative AI/ML Features Addendum checkbox to agree to the terms.
13. Click **Next**.
14. On the **Summary** step, review your settings and click **Create Conversation configuration**.
15. Copy the conversation configuration ID for use in the next steps.

## API

To create a conversation configuration programmatically, follow these steps:

1. Create a memory store by sending a `POST` request to the Stores resource:

   Create a memory store

   ```js
   // 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 createStore() {
     const store = await client.memory.v1.stores.create({
       displayName: "MyMemoryStore",
       description: "Memory store for conversations",
     });

     console.log(store.message);
   }

   createStore();
   ```

   ```python
   # Download the helper library from https://www.twilio.com/docs/python/install
   import os
   from twilio.rest import Client
   from twilio.rest.memory.v1 import StoreList

   # 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)

   store = client.memory.v1.stores.create(
       service_request=StoreList.ServiceRequest(
           {
               "displayName": "MyMemoryStore",
               "description": "Memory store for conversations",
           }
       )
   )

   print(store.message)
   ```

   ```csharp
   // Install the C# / .NET helper library from twilio.com/docs/csharp/install

   using System;
   using Twilio;
   using Twilio.Rest.Memory.V1;
   using System.Threading.Tasks;
   using System.Collections.Generic;

   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 store = await StoreResource.CreateAsync(
               serviceRequest: new StoreResource.ServiceRequest.Builder()
                   .WithDisplayName("MyMemoryStore")
                   .WithDescription("Memory store for conversations")
                   .Build());

           Console.WriteLine(store.Message);
       }
   }
   ```

   ```java
   // Install the Java helper library from twilio.com/docs/java/install

   import java.util.HashMap;
   import java.util.Map;
   import com.twilio.Twilio;
   import com.twilio.rest.memory.v1.Store;

   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);

           Store.ServiceRequest serviceRequest =
               Store.ServiceRequest.builder("MyMemoryStore").description("Memory store for conversations").build();

           Store.CreateStoreResponse response = Store.creator(serviceRequest).create();

           System.out.println(response.getMessage());
       }
   }
   ```

   ```ruby
   # Download the helper library from https://www.twilio.com/docs/ruby/install
   require 'twilio-ruby'

   # Find your Account SID and Auth Token at twilio.com/console
   # and set the environment variables. See http://twil.io/secure
   account_sid = ENV['TWILIO_ACCOUNT_SID']
   auth_token = ENV['TWILIO_AUTH_TOKEN']
   @client = Twilio::REST::Client.new(account_sid, auth_token)

   store = @client
           .memory
           .v1
           .stores
           .create(
             service_request: {
               'displayName' => 'MyMemoryStore',
               'description' => 'Memory store for conversations'
             }
           )

   puts store.message
   ```

   ```bash
   SERVICE_REQUEST_OBJ=$(cat << EOF
   {
     "displayName": "MyMemoryStore",
     "description": "Memory store for conversations"
   }
   EOF
   )
   curl -X POST "https://memory.twilio.com/v1/ControlPlane/Stores" \
   --json "$SERVICE_REQUEST_OBJ" \
   -u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
   ```
2. Save the memory store ID from the response. The ID starts with `mem_store_`.
3. Create a conversation configuration by sending a `POST` request to the Configurations endpoint. Replace `YOUR_MEMORY_STORE_ID` with the ID from the previous step and `YOUR_TWILIO_PHONE_NUMBER` with your Twilio phone number in [E.164](/docs/glossary/what-e164) format.

   Create a conversation configuration

   ```js
   // 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 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
   const accountSid = process.env.TWILIO_ACCOUNT_SID;
   const apiKey = process.env.TWILIO_API_KEY;
   const apiSecret = process.env.TWILIO_API_SECRET;
   const client = twilio(apiKey, apiSecret, { accountSid: accountSid });

   async function createConfiguration() {
     const configuration = await client.conversations.v2.configurations.create({
       displayName: "support-conversations",
       description: "Conversation configuration for support interactions",
       conversationGroupingType: "GROUP_BY_PARTICIPANT_ADDRESSES_AND_CHANNEL_TYPE",
       memoryStoreId: "YOUR_MEMORY_STORE_ID",
       channelSettings: {
         SMS: {
           statusTimeouts: {
             inactive: 10,
             closed: 30,
           },
           captureRules: [
             {
               from: "YOUR_TWILIO_PHONE_NUMBER",
               to: "*",
             },
             {
               from: "*",
               to: "YOUR_TWILIO_PHONE_NUMBER",
             },
           ],
         },
         VOICE: {
           statusTimeouts: {
             inactive: 5,
             closed: 30,
           },
           captureRules: [
             {
               from: "YOUR_TWILIO_PHONE_NUMBER",
               to: "*",
             },
             {
               from: "*",
               to: "YOUR_TWILIO_PHONE_NUMBER",
             },
           ],
         },
       },
     });

     console.log(configuration.statusUrl);
   }

   createConfiguration();
   ```

   ```python
   # Download the helper library from https://www.twilio.com/docs/python/install
   import os
   from twilio.rest import Client
   from twilio.rest.conversations.v2 import ConfigurationList

   # 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
   api_key = os.environ["TWILIO_API_KEY"]
   api_secret = os.environ["TWILIO_API_SECRET"]
   account_sid = os.environ["TWILIO_ACCOUNT_SID"]
   client = Client(api_key, api_secret, account_sid)

   configuration = client.conversations.v2.configurations.create(
       create_configuration_request=ConfigurationList.CreateConfigurationRequest(
           {
               "displayName": "support-conversations",
               "description": "Conversation configuration for support interactions",
               "conversationGroupingType": "GROUP_BY_PARTICIPANT_ADDRESSES_AND_CHANNEL_TYPE",
               "memoryStoreId": "YOUR_MEMORY_STORE_ID",
               "channelSettings": {
                   "SMS": ConfigurationList.CreateConfigurationRequestChannelSettingsValue(
                       {
                           "statusTimeouts": ConfigurationList.CreateConfigurationRequestChannelSettingsValueStatusTimeouts(
                               {"inactive": 10, "closed": 30}
                           ),
                           "captureRules": [
                               ConfigurationList.CreateConfigurationRequestChannelSettingsValueCaptureRules(
                                   {"from": "YOUR_TWILIO_PHONE_NUMBER", "to": "*"}
                               ),
                               ConfigurationList.CreateConfigurationRequestChannelSettingsValueCaptureRules(
                                   {"from": "*", "to": "YOUR_TWILIO_PHONE_NUMBER"}
                               ),
                           ],
                       }
                   ),
                   "VOICE": ConfigurationList.CreateConfigurationRequestChannelSettingsValue(
                       {
                           "statusTimeouts": ConfigurationList.CreateConfigurationRequestChannelSettingsValueStatusTimeouts(
                               {"inactive": 5, "closed": 30}
                           ),
                           "captureRules": [
                               ConfigurationList.CreateConfigurationRequestChannelSettingsValueCaptureRules(
                                   {"from": "YOUR_TWILIO_PHONE_NUMBER", "to": "*"}
                               ),
                               ConfigurationList.CreateConfigurationRequestChannelSettingsValueCaptureRules(
                                   {"from": "*", "to": "YOUR_TWILIO_PHONE_NUMBER"}
                               ),
                           ],
                       }
                   ),
               },
           }
       )
   )

   print(configuration.status_url)
   ```

   ```csharp
   // Install the C# / .NET helper library from twilio.com/docs/csharp/install

   using System;
   using Twilio;
   using Twilio.Rest.Conversations.V2;
   using System.Threading.Tasks;
   using System.Collections.Generic;

   class Program {
       public static async Task Main(string[] args) {
           // 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
           string apiKey = Environment.GetEnvironmentVariable("TWILIO_API_KEY");
           string apiSecret = Environment.GetEnvironmentVariable("TWILIO_API_SECRET");
           string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");

           TwilioClient.Init(apiKey, apiSecret, accountSid);

           var configuration = await ConfigurationResource.CreateAsync(new CreateConfigurationOptions() {
               CreateConfigurationRequest =
                   new ConfigurationResource.CreateConfigurationRequest.Builder()
                       .WithDisplayName("support-conversations")
                       .WithDescription("Conversation configuration for support interactions")
                       .WithConversationGroupingType("GROUP_BY_PARTICIPANT_ADDRESSES_AND_CHANNEL_TYPE")
                       .WithMemoryStoreId("YOUR_MEMORY_STORE_ID")
                       .WithChannelSettings(new Dictionary<
                                            string,
                                            ConfigurationResource
                                                .CreateConfigurationRequestChannelSettingsValue>() {
                           { "SMS",
                             new ConfigurationResource.CreateConfigurationRequestChannelSettingsValue
                                 .Builder()
                                 .WithStatusTimeouts(
                                     new ConfigurationResource
                                         .CreateConfigurationRequestChannelSettingsValueStatusTimeouts
                                         .Builder()
                                         .WithInactive(10)
                                         .WithClosed(30)
                                         .Build())
                                 .WithCaptureRules(
                                     new List<
                                         ConfigurationResource
                                             .CreateConfigurationRequestChannelSettingsValueCaptureRules> {
                                         new ConfigurationResource
                                             .CreateConfigurationRequestChannelSettingsValueCaptureRules
                                             .Builder()
                                             .WithFrom("YOUR_TWILIO_PHONE_NUMBER")
                                             .WithTo("*")
                                             .Build(),
                                         new ConfigurationResource
                                             .CreateConfigurationRequestChannelSettingsValueCaptureRules
                                             .Builder()
                                             .WithFrom("*")
                                             .WithTo("YOUR_TWILIO_PHONE_NUMBER")
                                             .Build()
                                     })
                                 .Build() },
                           { "VOICE",
                             new ConfigurationResource.CreateConfigurationRequestChannelSettingsValue
                                 .Builder()
                                 .WithStatusTimeouts(
                                     new ConfigurationResource
                                         .CreateConfigurationRequestChannelSettingsValueStatusTimeouts
                                         .Builder()
                                         .WithInactive(5)
                                         .WithClosed(30)
                                         .Build())
                                 .WithCaptureRules(
                                     new List<
                                         ConfigurationResource
                                             .CreateConfigurationRequestChannelSettingsValueCaptureRules> {
                                         new ConfigurationResource
                                             .CreateConfigurationRequestChannelSettingsValueCaptureRules
                                             .Builder()
                                             .WithFrom("YOUR_TWILIO_PHONE_NUMBER")
                                             .WithTo("*")
                                             .Build(),
                                         new ConfigurationResource
                                             .CreateConfigurationRequestChannelSettingsValueCaptureRules
                                             .Builder()
                                             .WithFrom("*")
                                             .WithTo("YOUR_TWILIO_PHONE_NUMBER")
                                             .Build()
                                     })
                                 .Build() }
                       })
                       .Build()
           });

           Console.WriteLine(configuration.StatusUrl);
       }
   }
   ```

   ```java
   // Install the Java helper library from twilio.com/docs/java/install

   import java.util.Arrays;
   import java.util.HashMap;
   import java.util.Map;
   import com.twilio.Twilio;
   import com.twilio.rest.conversations.v2.Configuration;

   public class Example {
       // 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
       public static final String API_KEY = System.getenv("TWILIO_API_KEY");
       public static final String API_SECRET = System.getenv("TWILIO_API_SECRET");
       public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");

       public static void main(String[] args) {
           Twilio.init(API_KEY, API_SECRET, ACCOUNT_SID);

           Configuration.CreateConfigurationRequest createConfigurationRequest =
               Configuration.CreateConfigurationRequest
                   .builder("support-conversations",
                       "Conversation configuration for support interactions",
                       Configuration.ConversationGroupingType.GROUP_BY_PARTICIPANT_ADDRESSES_AND_CHANNEL_TYPE,
                       "YOUR_MEMORY_STORE_ID")
                   .channelSettings(new HashMap<String, Map<String, Object>>() {
                       {
                           put("SMS", new HashMap<String, Map<String, Object>>() {
                               {
                                   put("statusTimeouts", new HashMap<String, Object>() {
                                       {
                                           put("inactive", 10);
                                           put("closed", 30);
                                       }
                                   });
                                   put("captureRules",
                                       Arrays.asList(
                                           new HashMap<String, Object>() {
                                               {
                                                   put("from", "YOUR_TWILIO_PHONE_NUMBER");
                                                   put("to", "*");
                                               }
                                           },
                                           new HashMap<String, Object>() {
                                               {
                                                   put("from", "*");
                                                   put("to", "YOUR_TWILIO_PHONE_NUMBER");
                                               }
                                           }

                                           ));
                               }
                           });
                           put("VOICE", new HashMap<String, Map<String, Object>>() {
                               {
                                   put("statusTimeouts", new HashMap<String, Object>() {
                                       {
                                           put("inactive", 5);
                                           put("closed", 30);
                                       }
                                   });
                                   put("captureRules",
                                       Arrays.asList(
                                           new HashMap<String, Object>() {
                                               {
                                                   put("from", "YOUR_TWILIO_PHONE_NUMBER");
                                                   put("to", "*");
                                               }
                                           },
                                           new HashMap<String, Object>() {
                                               {
                                                   put("from", "*");
                                                   put("to", "YOUR_TWILIO_PHONE_NUMBER");
                                               }
                                           }

                                           ));
                               }
                           });
                       }
                   })
                   .build();

           Configuration.CreateConfigurationResponse response =
               Configuration.creator().setCreateConfigurationRequest(createConfigurationRequest).create();

           System.out.println(response.getStatusUrl());
       }
   }
   ```

   ```ruby
   # Download the helper library from https://www.twilio.com/docs/ruby/install
   require 'twilio-ruby'

   # 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
   api_key = ENV['TWILIO_API_KEY']
   api_secret = ENV['TWILIO_API_SECRET']
   account_sid = ENV['TWILIO_ACCOUNT_SID']
   @client = Twilio::REST::Client.new(api_key, api_secret, account_sid)

   configuration = @client
                   .conversations
                   .v2
                   .configurations
                   .create(
                     create_configuration_request: {
                       'displayName' => 'support-conversations',
                       'description' => 'Conversation configuration for support interactions',
                       'conversationGroupingType' => 'GROUP_BY_PARTICIPANT_ADDRESSES_AND_CHANNEL_TYPE',
                       'memoryStoreId' => 'YOUR_MEMORY_STORE_ID',
                       'channelSettings' => {
                         'SMS' => {
                           'statusTimeouts' => {
                             'inactive' => 10,
                             'closed' => 30
                           },
                           'captureRules' => [
                             {
                               'from' => 'YOUR_TWILIO_PHONE_NUMBER',
                               'to' => '*'
                             },
                             {
                               'from' => '*',
                               'to' => 'YOUR_TWILIO_PHONE_NUMBER'
                             }
                           ]
                         },
                         'VOICE' => {
                           'statusTimeouts' => {
                             'inactive' => 5,
                             'closed' => 30
                           },
                           'captureRules' => [
                             {
                               'from' => 'YOUR_TWILIO_PHONE_NUMBER',
                               'to' => '*'
                             },
                             {
                               'from' => '*',
                               'to' => 'YOUR_TWILIO_PHONE_NUMBER'
                             }
                           ]
                         }
                       }
                     }
                   )

   puts configuration.status_url
   ```

   ```bash
   CREATE_CONFIGURATION_REQUEST_OBJ=$(cat << EOF
   {
     "displayName": "support-conversations",
     "description": "Conversation configuration for support interactions",
     "conversationGroupingType": "GROUP_BY_PARTICIPANT_ADDRESSES_AND_CHANNEL_TYPE",
     "memoryStoreId": "YOUR_MEMORY_STORE_ID",
     "channelSettings": {
       "SMS": {
         "statusTimeouts": {
           "inactive": 10,
           "closed": 30
         },
         "captureRules": [
           {
             "from": "YOUR_TWILIO_PHONE_NUMBER",
             "to": "*"
           },
           {
             "from": "*",
             "to": "YOUR_TWILIO_PHONE_NUMBER"
           }
         ]
       },
       "VOICE": {
         "statusTimeouts": {
           "inactive": 5,
           "closed": 30
         },
         "captureRules": [
           {
             "from": "YOUR_TWILIO_PHONE_NUMBER",
             "to": "*"
           },
           {
             "from": "*",
             "to": "YOUR_TWILIO_PHONE_NUMBER"
           }
         ]
       }
     }
   }
   EOF
   )
   curl -X POST "https://conversations.twilio.com/v2/ControlPlane/Configurations" \
   --json "$CREATE_CONFIGURATION_REQUEST_OBJ" \
   -u $TWILIO_API_KEY:$TWILIO_API_SECRET
   ```
4. Save the conversation configuration ID from the response for use in the next steps.

## Send a test SMS

Send an SMS from your Twilio phone number using the [Programmable Messaging API](/docs/messaging/api):

Send an SMS message

```js
// 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 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
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const apiKey = process.env.TWILIO_API_KEY;
const apiSecret = process.env.TWILIO_API_SECRET;
const client = twilio(apiKey, apiSecret, { accountSid: accountSid });

async function createMessage() {
  const message = await client.messages.create({
    body: "Hello there",
    from: "TWILIO_PHONE_NUMBER",
    to: "TEST_PHONE_NUMBER",
  });

  console.log(message.body);
}

createMessage();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# 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
api_key = os.environ["TWILIO_API_KEY"]
api_secret = os.environ["TWILIO_API_SECRET"]
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
client = Client(api_key, api_secret, account_sid)

message = client.messages.create(
    from_="TWILIO_PHONE_NUMBER", to="TEST_PHONE_NUMBER", body="Hello there"
)

print(message.body)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // 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
        string apiKey = Environment.GetEnvironmentVariable("TWILIO_API_KEY");
        string apiSecret = Environment.GetEnvironmentVariable("TWILIO_API_SECRET");
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");

        TwilioClient.Init(apiKey, apiSecret, accountSid);

        var message = await MessageResource.CreateAsync(
            from: new Twilio.Types.PhoneNumber("TWILIO_PHONE_NUMBER"),
            to: new Twilio.Types.PhoneNumber("TEST_PHONE_NUMBER"),
            body: "Hello there");

        Console.WriteLine(message.Body);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.type.PhoneNumber;
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.Message;

public class Example {
    // 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
    public static final String API_KEY = System.getenv("TWILIO_API_KEY");
    public static final String API_SECRET = System.getenv("TWILIO_API_SECRET");
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");

    public static void main(String[] args) {
        Twilio.init(API_KEY, API_SECRET, ACCOUNT_SID);
        Message message = Message
                              .creator(new com.twilio.type.PhoneNumber("TEST_PHONE_NUMBER"),
                                  new com.twilio.type.PhoneNumber("TWILIO_PHONE_NUMBER"),
                                  "Hello there")
                              .create();

        System.out.println(message.getBody());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	api "github.com/twilio/twilio-go/rest/api/v2010"
	"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 := &api.CreateMessageParams{}
	params.SetFrom("TWILIO_PHONE_NUMBER")
	params.SetTo("TEST_PHONE_NUMBER")
	params.SetBody("Hello there")

	resp, err := client.Api.CreateMessage(params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.Body != nil {
			fmt.Println(*resp.Body)
		} else {
			fmt.Println(resp.Body)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// 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
$apiKey = getenv("TWILIO_API_KEY");
$apiSecret = getenv("TWILIO_API_SECRET");
$sid = getenv("TWILIO_ACCOUNT_SID");
$twilio = new Client($apiKey, $apiSecret, $sid);

$message = $twilio->messages->create(
    "TEST_PHONE_NUMBER", // To
    [
        "from" => "TWILIO_PHONE_NUMBER",
        "body" => "Hello there",
    ]
);

print $message->body;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# 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
api_key = ENV['TWILIO_API_KEY']
api_secret = ENV['TWILIO_API_SECRET']
account_sid = ENV['TWILIO_ACCOUNT_SID']
@client = Twilio::REST::Client.new(api_key, api_secret, account_sid)

message = @client
          .api
          .v2010
          .messages
          .create(
            from: 'TWILIO_PHONE_NUMBER',
            to: 'TEST_PHONE_NUMBER',
            body: 'Hello there'
          )

puts message.body
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:core:messages:create \
   --from TWILIO_PHONE_NUMBER \
   --to TEST_PHONE_NUMBER \
   --body "Hello there"
```

```bash
curl -X POST "https://api.twilio.com/2010-04-01/Accounts/$TWILIO_ACCOUNT_SID/Messages.json" \
--data-urlencode "From=TWILIO_PHONE_NUMBER" \
--data-urlencode "To=TEST_PHONE_NUMBER" \
--data-urlencode "Body=Hello there" \
-u $TWILIO_API_KEY:$TWILIO_API_SECRET
```

Replace *TWILIO\_PHONE\_NUMBER* with your Twilio phone number and *TEST\_PHONE\_NUMBER* with a test phone number. Conversation Orchestrator detects the message, creates a conversation, adds customer and agent participants, and records the message as a communication.

## Make a test voice call

Conversation Orchestrator captures voice calls the same way it captures SMS messages.

1. From your test phone number, call your Twilio phone number.
2. When the call connects, say a few words so the call has content to transcribe.
3. End the call.

## See your conversations

Use the Conversation Orchestrator API to verify that your test communications are in a conversation.

### List conversations

To retrieve all your conversations, send a `GET` request:

List conversations

```js
// 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 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
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const apiKey = process.env.TWILIO_API_KEY;
const apiSecret = process.env.TWILIO_API_SECRET;
const client = twilio(apiKey, apiSecret, { accountSid: accountSid });

async function listConversationByAccount() {
  const conversations = await client.conversations.v2.conversations.list({
    limit: 20,
  });

  conversations.forEach((c) => console.log(c.id));
}

listConversationByAccount();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# 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
api_key = os.environ["TWILIO_API_KEY"]
api_secret = os.environ["TWILIO_API_SECRET"]
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
client = Client(api_key, api_secret, account_sid)

conversations = client.conversations.v2.conversations.list(limit=20)

for record in conversations:
    print(record.id)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Conversations.V2;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // 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
        string apiKey = Environment.GetEnvironmentVariable("TWILIO_API_KEY");
        string apiSecret = Environment.GetEnvironmentVariable("TWILIO_API_SECRET");
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");

        TwilioClient.Init(apiKey, apiSecret, accountSid);

        var conversations = await ConversationResource.ReadAsync(limit: 20);

        foreach (var record in conversations) {
            Console.WriteLine(record.Id);
        }
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.conversations.v2.Conversation;
import com.twilio.base.ResourceSet;

public class Example {
    // 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
    public static final String API_KEY = System.getenv("TWILIO_API_KEY");
    public static final String API_SECRET = System.getenv("TWILIO_API_SECRET");
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");

    public static void main(String[] args) {
        Twilio.init(API_KEY, API_SECRET, ACCOUNT_SID);
        ResourceSet<Conversation.ListConversationResponse> conversations = Conversation.reader().limit(20).read();

        for (Conversation.ListConversationResponse conversation : conversations) {
            System.out.println(conversation.getId());
        }
    }
}
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# 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
api_key = ENV['TWILIO_API_KEY']
api_secret = ENV['TWILIO_API_SECRET']
account_sid = ENV['TWILIO_ACCOUNT_SID']
@client = Twilio::REST::Client.new(api_key, api_secret, account_sid)

conversations = @client
                .conversations
                .v2
                .conversations
                .list(limit: 20)

conversations.each do |record|
   puts record.id
end
```

```bash
curl -X GET "https://conversations.twilio.com/v2/Conversations?PageSize=20" \
-u $TWILIO_API_KEY:$TWILIO_API_SECRET
```

The response includes a list of conversations. Note the `id` of the conversation you want to inspect.

### Inspect participants

To retrieve the list of participants in a conversation, send a `GET` request to the Participants endpoint:

List participants in a conversation

```js
// 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 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
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const apiKey = process.env.TWILIO_API_KEY;
const apiSecret = process.env.TWILIO_API_SECRET;
const client = twilio(apiKey, apiSecret, { accountSid: accountSid });

async function listParticipantByConversation() {
  const participants = await client.conversations.v2
    .participants("CONVERSATION_ID")
    .list({ limit: 20 });

  participants.forEach((p) => console.log(p.id));
}

listParticipantByConversation();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# 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
api_key = os.environ["TWILIO_API_KEY"]
api_secret = os.environ["TWILIO_API_SECRET"]
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
client = Client(api_key, api_secret, account_sid)

participants = client.conversations.v2.participants("CONVERSATION_ID").list(
    limit=20
)

for record in participants:
    print(record.id)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Conversations.V2;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // 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
        string apiKey = Environment.GetEnvironmentVariable("TWILIO_API_KEY");
        string apiSecret = Environment.GetEnvironmentVariable("TWILIO_API_SECRET");
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");

        TwilioClient.Init(apiKey, apiSecret, accountSid);

        var participants =
            await ParticipantResource.ReadAsync(pathConversationSid: "CONVERSATION_ID", limit: 20);

        foreach (var record in participants) {
            Console.WriteLine(record.Id);
        }
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.conversations.v2.Participant;
import com.twilio.base.ResourceSet;

public class Example {
    // 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
    public static final String API_KEY = System.getenv("TWILIO_API_KEY");
    public static final String API_SECRET = System.getenv("TWILIO_API_SECRET");
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");

    public static void main(String[] args) {
        Twilio.init(API_KEY, API_SECRET, ACCOUNT_SID);
        ResourceSet<Participant.ListParticipantResponse> participants =
            Participant.reader("CONVERSATION_ID").limit(20).read();

        for (Participant.ListParticipantResponse participant : participants) {
            System.out.println(participant.getId());
        }
    }
}
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# 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
api_key = ENV['TWILIO_API_KEY']
api_secret = ENV['TWILIO_API_SECRET']
account_sid = ENV['TWILIO_ACCOUNT_SID']
@client = Twilio::REST::Client.new(api_key, api_secret, account_sid)

participants = @client
               .conversations
               .v2
               .participants('CONVERSATION_ID')
               .list(limit: 20)

participants.each do |record|
   puts record.id
end
```

```bash
curl -X GET "https://conversations.twilio.com/v2/Conversations/CONVERSATION_ID/Participants?PageSize=20" \
-u $TWILIO_API_KEY:$TWILIO_API_SECRET
```

Replace *CONVERSATION\_ID* with your conversation ID.

### Inspect communications

To see the messages in a conversation, send a `GET` request to the Communications endpoint:

List messages in a conversation

```js
// 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 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
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const apiKey = process.env.TWILIO_API_KEY;
const apiSecret = process.env.TWILIO_API_SECRET;
const client = twilio(apiKey, apiSecret, { accountSid: accountSid });

async function listCommunicationByConversation() {
  const communications = await client.conversations.v2
    .communications("CONVERSATION_ID")
    .list({ limit: 20 });

  communications.forEach((c) => console.log(c.id));
}

listCommunicationByConversation();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# 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
api_key = os.environ["TWILIO_API_KEY"]
api_secret = os.environ["TWILIO_API_SECRET"]
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
client = Client(api_key, api_secret, account_sid)

communications = client.conversations.v2.communications("CONVERSATION_ID").list(
    limit=20
)

for record in communications:
    print(record.id)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Conversations.V2;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // 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
        string apiKey = Environment.GetEnvironmentVariable("TWILIO_API_KEY");
        string apiSecret = Environment.GetEnvironmentVariable("TWILIO_API_SECRET");
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");

        TwilioClient.Init(apiKey, apiSecret, accountSid);

        var communications = await CommunicationResource.ReadAsync(
            pathConversationSid: "CONVERSATION_ID", limit: 20);

        foreach (var record in communications) {
            Console.WriteLine(record.Id);
        }
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.conversations.v2.Communication;
import com.twilio.base.ResourceSet;

public class Example {
    // 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
    public static final String API_KEY = System.getenv("TWILIO_API_KEY");
    public static final String API_SECRET = System.getenv("TWILIO_API_SECRET");
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");

    public static void main(String[] args) {
        Twilio.init(API_KEY, API_SECRET, ACCOUNT_SID);
        ResourceSet<Communication.ListCommunicationResponse> communications =
            Communication.reader("CONVERSATION_ID").limit(20).read();

        for (Communication.ListCommunicationResponse communication : communications) {
            System.out.println(communication.getId());
        }
    }
}
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# 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
api_key = ENV['TWILIO_API_KEY']
api_secret = ENV['TWILIO_API_SECRET']
account_sid = ENV['TWILIO_ACCOUNT_SID']
@client = Twilio::REST::Client.new(api_key, api_secret, account_sid)

communications = @client
                 .conversations
                 .v2
                 .communications('CONVERSATION_ID')
                 .list(limit: 20)

communications.each do |record|
   puts record.id
end
```

```bash
curl -X GET "https://conversations.twilio.com/v2/Conversations/CONVERSATION_ID/Communications?PageSize=20" \
-u $TWILIO_API_KEY:$TWILIO_API_SECRET
```

Replace *CONVERSATION\_ID* with your conversation ID.

This endpoint returns a list of communications. The `content` property of each communication contains a transcription of your voice call or the body of your text message.

## Next steps

* [Core concepts](/docs/conversations/orchestrator/concepts/core): Learn about the main objects in Conversation Orchestrator.
* [Create conversations programmatically](/docs/conversations/orchestrator/guides/active-creation): Build conversations with the API or TwiML instead of capture rules.
* [Troubleshooting](/docs/conversations/orchestrator/troubleshooting): Resolve common errors.
* [Conversation Memory](/docs/conversations/memory): Use customer profiles to personalize interactions.
* [Conversation Intelligence](/docs/conversations/intelligence): Analyze your conversations with language operators.
