elevenlabs-twilio-memory-bridge
Personalization webhook service for ElevenLabs + Twilio voice agents with persistent caller memory.
What It Does
When a call arrives on your Twilio number, ElevenLabs' native integration triggers this webhook. The bridge looks up the caller's history, loads long-term memory facts and daily context notes, combines them with a customizable soul/personality template, and returns everything as a system prompt override so your agent greets each caller with full context.
Architecture
- - No audio proxying - ElevenLabs and Twilio handle media directly
- Webhook only - called once per inbound call to inject context
- File-based persistence - JSON files in
./data/, zero external dependencies - OpenClaw compatible - works with any OpenAI-compatible LLM endpoint
Endpoints
| Endpoint | Method | Purpose |
|---|
| INLINECODE1 | POST | ElevenLabs calls this on inbound call |
| INLINECODE2 |
POST | Optional post-call cleanup |
|
/api/memory/{phone_hash} | POST | Add long-term fact about a caller |
|
/api/notes | POST | Add global or caller-scoped context note |
|
/health | GET | Health check |
Setup
- 1. Clone repo, INLINECODE6
- Copy
.env.example to .env, fill in secrets - Configure ElevenLabs agent with Custom LLM pointing to your OpenClaw instance
- Enable system prompt + first message overrides in agent Security settings
- Add webhook URL
https://your-domain/webhook/personalize in ElevenLabs settings - Import Twilio number in ElevenLabs dashboard
- Run: INLINECODE10
Required Environment Variables
- -
ELEVENLABS_API_KEY - scoped ElevenLabs key - INLINECODE12 - your agent ID
- INLINECODE13 - your OpenClaw instance URL
- INLINECODE14 - publicly reachable URL of this service
Security
- - All caller phone numbers are SHA-256 hashed before storage/logging
- Secrets loaded exclusively from environment variables
- Optional HMAC webhook signature verification
- Safe for public GitHub repos, no secrets in source
elevenlabs-twilio-memory-bridge
用于ElevenLabs + Twilio语音代理的个性化Webhook服务,具备持久化呼叫者记忆功能。
功能说明
当电话到达您的Twilio号码时,ElevenLabs的原生集成会触发此Webhook。该桥接服务会查询呼叫者的历史记录,加载长期记忆事实和每日上下文笔记,将其与可定制的灵魂/个性模板相结合,并以系统提示覆盖的形式返回所有内容,使您的代理能够在完整上下文中问候每位呼叫者。
架构
- - 无音频代理 - ElevenLabs和Twilio直接处理媒体流
- 仅Webhook - 每次入站呼叫调用一次以注入上下文
- 基于文件的持久化 - JSON文件存储在./data/目录,零外部依赖
- 兼容OpenClaw - 可与任何兼容OpenAI的LLM端点配合使用
端点
| 端点 | 方法 | 用途 |
|---|
| /webhook/personalize | POST | ElevenLabs在入站呼叫时调用 |
| /webhook/post-call |
POST | 可选的呼叫后清理 |
| /api/memory/{phone_hash} | POST | 添加关于呼叫者的长期记忆事实 |
| /api/notes | POST | 添加全局或呼叫者范围的上下文笔记 |
| /health | GET | 健康检查 |
设置步骤
- 1. 克隆仓库,执行 pip install -r requirements.txt
- 复制 .env.example 为 .env,填写密钥信息
- 配置ElevenLabs代理,使用指向您OpenClaw实例的自定义LLM
- 在代理安全设置中启用系统提示和首条消息覆盖
- 在ElevenLabs设置中添加Webhook URL https://your-domain/webhook/personalize
- 在ElevenLabs控制面板中导入Twilio号码
- 运行:uvicorn app:app --host 0.0.0.0 --port 8000
必需的环境变量
- - ELEVENLABSAPIKEY - 限定范围的ElevenLabs密钥
- ELEVENLABSAGENTID - 您的代理ID
- OPENCLAWAPIBASEURL - 您的OpenClaw实例URL
- PUBLICBASE_URL - 此服务的公网可访问URL
安全性
- - 所有呼叫者电话号码在存储/记录前均经过SHA-256哈希处理
- 密钥完全从环境变量加载
- 可选的HMAC Webhook签名验证
- 适用于公开GitHub仓库,源代码中不包含任何密钥