---
title: "How to Orchestrate Multi-Call Conversations with an LLM and Twilio Conversation Memory in Python"
description: "The tutorial builds a Python FastAPI voice service that preserves caller context, preferences, and action history across separate inbound calls using Twilio Conversation Memory. It connects a Twilio phone number to a /voice webhook and /ws WebSocket through Conversation Relay, then uses an asynchronous OpenAI client with gpt-4o-mini to generate streamed responses. A memory service retrieves stored information by caller number, while each completed call is summarized and written back to the configured memory store. The example uses an auto-repair assistant whose system prompt incorporates prior context before the next call, and the test procedure checks that a second call recalls details from the first. The setup requires Python 3.11 or later, Twilio and OpenAI credentials, a memory-store and configuration ID, and ngrok for exposing local webhooks."
---

# How to Orchestrate Multi-Call Conversations with an LLM and Twilio Conversation Memory in Python

[Twilio](https://yomu.fyi/company/twilio) · Amanda Lange, Dylan Frankcom · Sep 14, 2026

**Type:** Tutorial

## Summary

The tutorial builds a Python FastAPI voice service that preserves caller context, preferences, and action history across separate inbound calls using Twilio Conversation Memory. It connects a Twilio phone number to a /voice webhook and /ws WebSocket through Conversation Relay, then uses an asynchronous OpenAI client with gpt-4o-mini to generate streamed responses. A memory service retrieves stored information by caller number, while each completed call is summarized and written back to the configured memory store. The example uses an auto-repair assistant whose system prompt incorporates prior context before the next call, and the test procedure checks that a second call recalls details from the first. The setup requires Python 3.11 or later, Twilio and OpenAI credentials, a memory-store and configuration ID, and ngrok for exposing local webhooks.

## Context

The example is an auto-repair phone agent, but the text says the same Conversation Memory pattern could also support scenarios such as tech support and travel. Conversation Memory uses machine learning and is not intended for sensitive information.

## Approach / What changed

Create a FastAPI project with Twilio, OpenAI, httpx, and environment-variable support; configure a Twilio Conversation Memory Store; expose /voice and /ws routes; connect calls through Conversation Relay; stream gpt-4o-mini responses over the WebSocket; retrieve prior caller context; and summarize completed calls back into the memory store.

## Takeaways

- Conversation Memory persists context between separate calls, allowing a returning caller to continue without repeating previously shared details.
- The service uses a /voice TwiML webhook, a Conversation Relay WebSocket, and streamed responses from gpt-4o-mini through an asynchronous OpenAI client.
- The tutorial requires a Twilio Main API key, memory-store and configuration IDs, an OpenAI API key, a voice-capable number, and ngrok for local webhook exposure.

## FAQ

### How does the agent recall information after a call ends?

The application retrieves stored information associated with the caller number and adds it to the OpenAI system prompt as prior customer context. A summary and conversation details are saved in the configured Twilio Memory Store.

### How can the multi-call behavior be tested?

Make one call and discuss a repair issue with details such as the vehicle’s make and model. Hang up, call again from the same number, and verify that the agent remembers those details without prompting.

### Is Twilio Conversation Memory suitable for sensitive information?

The tutorial warns that Conversation Memory uses machine learning and is not intended for sensitive information. It also notes that Conversation products are available only in the new Twilio Console.

**Tags:** [FastAPI](https://yomu.fyi/topic/fastapi), [OpenAI API](https://yomu.fyi/topic/openai-api), [Python](https://yomu.fyi/topic/python), [Twilio](https://yomu.fyi/topic/twilio)

- Source: [Twilio](https://www.twilio.com/en-us/blog/developers/tutorials/product/orchestrate-multi-call-conversations-with-llm-twilio-conversation-memory-python)
- Source URL: https://www.twilio.com/en-us/blog/developers/tutorials/product/orchestrate-multi-call-conversations-with-llm-twilio-conversation-memory-python
- Ingested by Yomu: 2026-09-15T12:02:12.107Z

[Read original post](https://www.twilio.com/en-us/blog/developers/tutorials/product/orchestrate-multi-call-conversations-with-llm-twilio-conversation-memory-python)
