Phone Agent Skill
Runs a local FastAPI server that acts as a real-time voice bridge.
Architecture
CODEBLOCK0
Prerequisites
- 1. Twilio Account: Phone number + TwiML App.
- Deepgram API Key: For fast speech-to-text.
- OpenAI API Key: For the conversation logic.
- ElevenLabs API Key: For realistic text-to-speech.
- Ngrok (or similar): To expose your local port 8080 to Twilio.
Setup
- 1. Install Dependencies:
CODEBLOCK1
- 2. Set Environment Variables (in
~/.moltbot/.env, ~/.clawdbot/.env, or export):
CODEBLOCK2
- 3. Start the Server:
CODEBLOCK3
- 4. Expose to Internet:
CODEBLOCK4
- 5. Configure Twilio:
- Go to your Phone Number settings.
- Set "Voice & Fax" -> "A Call Comes In" to
Webhook.
- URL:
https://<your-ngrok-url>.ngrok.io/incoming
- Method: INLINECODE3
Usage
Call your Twilio number. The agent should answer, transcribe your speech, think, and reply in a natural voice.
Customization
- - System Prompt: Edit
SYSTEM_PROMPT in scripts/server.py to change the persona. - Voice: Change
ELEVENLABS_VOICE_ID to use different voices. - Model: Switch
gpt-4o-mini to gpt-4 for smarter (but slower) responses.
电话代理技能
运行一个本地FastAPI服务器,作为实时语音桥接器。
架构
Twilio(电话)<--> WebSocket(音频)<--> [本地服务器] <--> Deepgram(语音转文字)
|
+--> OpenAI(大语言模型)
+--> ElevenLabs(文字转语音)
前置条件
- 1. Twilio账户:电话号码 + TwiML应用。
- Deepgram API密钥:用于快速语音转文字。
- OpenAI API密钥:用于对话逻辑。
- ElevenLabs API密钥:用于逼真的文字转语音。
- Ngrok(或类似工具):将本地8080端口暴露给Twilio。
设置
- 1. 安装依赖:
bash
pip install -r scripts/requirements.txt
- 2. 设置环境变量(在~/.moltbot/.env、~/.clawdbot/.env中,或通过export命令):
bash
export DEEPGRAM
APIKEY=your_key
export OPENAI
APIKEY=your_key
export ELEVENLABS
APIKEY=your_key
export TWILIO
ACCOUNTSID=your_sid
export TWILIO
AUTHTOKEN=your_token
export PORT=8080
- 3. 启动服务器:
bash
python3 scripts/server.py
- 4. 暴露到互联网:
bash
ngrok http 8080
- 5. 配置Twilio:
- 进入你的电话号码设置。
- 将语音与传真 -> 来电时设置为
Webhook。
- URL:https://
.ngrok.io/incoming
- 方法:POST
使用方法
拨打你的Twilio号码。代理应会接听,转录你的语音,进行思考,并以自然语音回复。
自定义设置
- - 系统提示词:编辑scripts/server.py中的SYSTEMPROMPT以更改角色设定。
- 语音:更改ELEVENLABSVOICE_ID以使用不同的语音。
- 模型:将gpt-4o-mini切换为gpt-4以获得更智能(但较慢)的回复。