Menu

Expand
Rate this page:

Create a Conversation

Create your first Conversation

You can create your first Conversation using the Twilio CLI or directly from your Customer details page.

First, let's make a Conversation using the Twilio CLI:

twilio api:conversations:v1:conversations:create \
  --friendly-name "My First Conversation"

Copy down the Conversation SID — it starts with CHXXX. Now, use it to fetch the new Conversation:

twilio api:conversations:v1:conversations:fetch \
  --sid CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

You’ll use the Conversation SID in the next few steps when we add participants to the Conversation.

Add a Chat participant to the Conversation

You’ve created a Conversation, which you can think of as a virtual space that users can join using a channel of their choice.

Add yourself as a chat participant. The following code sample does this for you. You will need to replace the following information:

  • CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX — the Conversation SID.
  • <YOUR_CHAT_USER_IDENTITY> — the identity of your Twilio Frontline user. To get this, go to the Twilio Chat console, click on the Default Conversations Service chat service, navigate to the Users page, and locate your chat user.
twilio api:conversations:v1:conversations:participants:create \
  --conversation-sid CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
  --identity "<YOUR_CHAT_USER_IDENTITY>"

Now open the app again, you should see a new conversation, the one that you created and where you added yourself as a participant. You need one more participant to have a real conversation, so let’s add an SMS participant.

Add an SMS participant to the Conversation

The second participant is someone connecting to the Conversation with an SMS-enabled phone number. Hint: Use the number that you purchased up above.

For the following code sample, replace the placeholder values:

  • CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX — the Conversation SID.
  • <YOUR_PERSONAL_NUMBER> — your own mobile number in E.164 format.
  • <YOUR_PURCASHED_TWILIO_PHONE_NUMBER> — the Twilio number you purchased in E.164 format.
twilio api:conversations:v1:conversations:participants:create \
  --conversation-sid CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
  --messaging-binding.address "<YOUR_PERSONAL_NUMBER>" \
  --messaging-binding.proxy-address "<YOUR_PURCASHED_TWILIO_PHONE_NUMBER>"

Open the app again and try to send a text message there. Your phone number should receive an SMS message almost immediately — just respond to it.

As mentioned before, you can also create your first conversation using your own CRM. To do this we need first to go to Callbacks in the Frontline console and add the Outgoing Conversations Callback URL:

set-oubound-conversations-callback-url.png

Now open the app again and click on a customer's phone number. Great! You will now be able to start a new conversation.

outbound-conversation.png


Rate this page:

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.

        
        
        

        Thank you for your feedback!

        Please select the reason(s) for your feedback. The additional information you provide helps us improve our documentation:

        Sending your feedback...
        🎉 Thank you for your feedback!
        Something went wrong. Please try again.

        Thanks for your feedback!

        Refer us and get $10 in 3 simple steps!

        Step 1

        Get link

        Get a free personal referral link here

        Step 2

        Give $10

        Your user signs up and upgrade using link

        Step 3

        Get $10

        1,250 free SMSes
        OR 1,000 free voice mins
        OR 12,000 chats
        OR more