Skip to contentSkip to navigationSkip to topbar
Page toolsOn this page
Looking for more inspiration?Visit the

Quickstart


This quickstart runs the bundled examples from the TAC repositories to connect an AI agent (built with OpenAI) to Twilio's SMS and Voice channels. TAC supports Python and TypeScript — choose the language that fits your development environment.

You'll build a customer service agent that can:

  • Respond to customers through SMS and Voice
  • Retrieve customer context and conversation history by using Twilio Conversation Memory
  • Provide personalized responses based on customer profile

Prerequisites

prerequisites page anchor

Before you begin, gather the following information from the Console(link takes you to an external page):

CredentialWhere to find it
Twilio Account SIDIn the Console Dashboard(link takes you to an external page). Starts with AC.
Twilio Auth TokenIn the Console(link takes you to an external page), go to Develop > API Key & creds > API Keys & auth tokens, go to the Auth Tokens tab. Click to reveal your Primary auth token.
API Key SIDIn the Console(link takes you to an external page), go to Develop > API Key & creds > API Keys & auth tokens, go to the API Keys tab. Click Create API Key and create a standard API key. Copy and store your SID (starts with SK) and Client secret.
API Key SecretShown once when creating the API key. Save it securely.
Twilio Phone NumberIn the Console(link takes you to an external page), go to Products & services > Numbers & senders > Numbers & senders.

You'll also need:

  • Ngrok domain: A public URL for webhooks, for example, your-app.ngrok.app.
  • OpenAI API key: Required for the OpenAI agent used in this quickstart. You can obtain an API key from the OpenAI Console(link takes you to an external page).
  • Python 3.10+ or Node.js 22.13.0+: Depending on your chosen language.

Clone the example repository

clone-the-example-repository page anchor

This quickstart uses the bundled examples from the TAC repository. For your own projects, install the SDK directly from the package registry — see Add TAC to your agent for pip/npm installation instructions.

PythonTypeScript
  1. Clone the TAC repository and navigate to it:

    1
    git clone https://github.com/twilio/twilio-agent-connect-python.git
    2
    cd twilio-agent-connect-python
  2. Install uv, a Python package manager. See the uv installation guide(link takes you to an external page) for instructions.

    1
    # macOS/Linux
    2
    curl -sSL https://install.astral.sh | sh
    3
    # or with Homebrew (macOS)
    4
    brew install uv
    5
    # or with pip
    6
    pip install uv
  3. Install dependencies:

    make sync

Expose your local server with ngrok

expose-your-local-server-with-ngrok page anchor

Twilio needs a public URL to send webhooks to your local server. In the next step, you'll configure your environment with your ngrok domain, so start ngrok first.

Choose one of the following options based on your ngrok plan:

Free ngrok plan (random domain)

free-ngrok-plan-random-domain page anchor
  1. Start ngrok:

    ngrok http 8000
  2. Ngrok generates a random URL (for example, https://abc123xyz.ngrok.app). Copy the domain from the ngrok terminal output (for example, abc123xyz.ngrok.app).

(information)

Info

Each time you restart ngrok on a free plan, it generates a new URL. You'll need to update the ngrok domain in your .env file and in the Console webhook configuration after each restart.

Configure your environment

configure-your-environment page anchor
PythonTypeScript

The Python SDK includes a setup wizard that creates the required Twilio services and generates your environment variables.

  1. In a new terminal window (keep ngrok running), start the setup wizard from the repository root:

    make setup
  2. Open http://localhost:8080 in your browser.

  3. Fill out the form with the following information and click Set Up Services:

    • Twilio Credentials: API Key SID, API Secret, Account SID, Auth Token, and your Twilio phone number.
    • Conversation Orchestrator Configuration: Display name and description for the configuration.
    • Conversation Memory Configuration: Display name and description for the memory store.
    • Optional Configuration: Your ngrok domain (required for voice) and OpenAI API key (required to run the example in this quickstart).
    • Profile Information: Email, phone number, and optionally a first name to create a test customer profile.
  4. Create the .env file in the getting_started/examples folder:

    1
    cd getting_started/examples
    2
    cp .env.example .env
  5. Back in the wizard, click Copy and paste the values into the .env file you just created.


Configure Twilio webhooks

configure-twilio-webhooks page anchor

Use the ngrok domain from the earlier step to configure webhooks in the Console.

  1. In the Console(link takes you to an external page), go to Products & services > Conversation Orchestrator > Conversation Configurations.
  2. Select your conversation configuration.
  3. In the Overview tab, click the Edit button.
  4. Set Webhook > Callback method to https://your-domain.ngrok.app/webhook.
    • Replace your-domain with your actual ngrok domain from the previous section (either the random domain like abc123xyz or your static domain).
  5. Select POST as the HTTP method.
  6. Click Save changes.
  1. In the Console(link takes you to an external page), go to Products & services > Numbers & senders.
  2. Select your Twilio phone number.
  3. Under Configuration details, locate Voice configuration and click Edit details:
    • Select Webhook, TwiML Bin, Function, Studio Flow, Proxy Service as a method.
    • Choose Use Webhooks as the primary method.
    • For the primary webhook URL, enter: https://your-domain.ngrok.app/twiml. You can also set up a secondary webhook URL for if the primary webhook URL fails.
      • Replace your-domain with your actual ngrok domain from the previous section (either the random domain like abc123xyz or your static domain)
    • Select POST as the HTTP method.
  4. Click Save.

PythonTypeScript
  1. In a new terminal window, navigate to the example directory:

    cd getting_started/examples/partners
  2. Start the server:

    uv run python openai_chat_completions.py
  3. You see a message confirming the server is running:

    1
    INFO: Started server process
    2
    INFO: Waiting for application startup.
    3
    INFO: Application startup complete.
    4
    INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)

Now that your server is running, ngrok is exposing it to the internet, and Twilio webhooks are configured, you can test the agent using SMS or voice.

(information)

Info

To confirm memory retrieval, set TWILIO_LOG_LEVEL=debug in your .env file and restart the server. Check your terminal output for memory retrieval log entries.

Send a text message to your Twilio phone number:

"Hi, I need help with my account."

Without memory integration: The agent responds as a generic customer service assistant.

With memory integration: The agent retrieves past interactions and personalizes responses using profile data from Conversation Memory. For name-based personalization (for example, greeting the customer by name), a profile with traits like firstName must be configured in Conversation Memory.

Call your Twilio phone number. The agent will greet you and respond to spoken questions.

With memory integration: The agent uses your profile information to provide context-aware responses throughout the call.

Optional: Monitor with the demo dashboard

optional-monitor-with-the-demo-dashboard page anchor

The Python SDK includes a dashboard example that runs the same agent with a local observation UI for monitoring active conversations, message history, and agent context in real time.

To try it, stop the current server and run the dashboard example from the repository root:

uv run python getting_started/examples/features/dashboard/app.py

The dashboard example includes the same SMS and Voice agent from the previous steps, plus a monitoring interface.

Open http://localhost:8000/dashboard in your browser to view:

  • Active Sessions — Live conversations with message viewer
  • History — Closed conversations from Conversation Orchestrator
  • Agent Context — Profile traits, observations, and summaries from Conversation Memory

Send an SMS or make a voice call to your Twilio number, then watch the dashboard update in real time.

(warning)

Warning

The dashboard has no authentication. Use it for local development and demos only.

For more information about the dashboard, see the dashboard example(link takes you to an external page) in the Python SDK repository.