API Recipes

Chat Setup Flow

This recipe was an interactive walkthrough in the previous portal. Each step below names the API call it makes; open it in the API Reference to try it.

Overview

Interactive Chat Setup Flow

Welcome to the Twilio Conversations API quickstart recipe! This guide will walk you through the essential steps required to establish a functional chat environment.

🚀 What's Inside?

Through this interactive flow, you will:

  • Create a Conversation: Provision a new communication channel (with a unique identity).
  • Add a Participant: Link a user identity to the conversation to enable messaging.
  • Send a Welcome Message: Dispatch the first message to greet your participants.

🛠 Prerequisites

Ensure you have your Twilio Account SID and Auth Token configured in the portal settings to execute these requests successfully.


Ready to start building? Proceed to Step 1 to initialize your conversation channel!

Step 1: Create Conversation

Create a new conversation service instance.

API call: CreateConversation

Example arguments:

{
            UniqueName: `recipe-chat-${Date.now()}`,
            body: {
              FriendlyName: "Recipe Chat Room",
              UniqueName: `recipe-chat-${Date.now()}` // Ensure uniqueness
            }
          }

Step 2: Add Participant

Add a chat participant to the conversation.

API call: CreateConversationParticipant

Example arguments:

{
            ConversationSid: conversationSid,
            Identity: userID, // Using account SID or UniqueName as Identity for demonstration
            body: {
              Identity: "RecipeGuest", 
            },
          }

Step 3: Send Welcome Message

Send a welcome message to the conversation.

API call: CreateConversationMessage

Example arguments:

{
            ConversationSid: conversationSid,
            Body: "Welcome to Twilio Developer Portal by APIMatic!"
          }

On this page