Skip to content

Commit d90641b

Browse files
rrnewtonclaude
andcommitted
Add voice agent setup scripts and update submodules for private voice support
- Add voice_agent/ directory with scripts to create/manage ElevenLabs agents - setup-agent.sh: Idempotent agent creation with client tools configured - list-agents.sh, get-agent.sh, delete-agent.sh: Agent management utilities - system_prompt.md: Voice assistant personality and instructions - Update happy submodule: private voice agent with server-side token generation - Update happy-server submodule: improved voice token error handling Enables self-hosted deployments to configure their own ElevenLabs voice agent. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 4fbd808 commit d90641b

File tree

8 files changed

+458
-2
lines changed

8 files changed

+458
-2
lines changed

happy-server

voice_agent/README.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Happy Voice Agent Setup
2+
3+
Scripts to create and manage the ElevenLabs Conversational AI agent for Happy.
4+
5+
## Prerequisites
6+
7+
1. An ElevenLabs account at https://elevenlabs.io
8+
2. An API key with **Conversational AI** permission enabled
9+
- Go to https://elevenlabs.io/app/settings/api-keys
10+
- Create a new key or edit existing one
11+
- Enable the "Conversational AI" permission
12+
13+
## Quick Start
14+
15+
```bash
16+
# Set your API key
17+
export ELEVENLABS_API_KEY=sk_your_api_key_here
18+
19+
# Create or update the Happy Coding Assistant agent
20+
./setup-agent.sh
21+
```
22+
23+
The script will output the `ELEVENLABS_AGENT_ID` to add to your happy-server environment.
24+
25+
## Scripts
26+
27+
### `setup-agent.sh`
28+
29+
Creates or updates the "Happy Coding Assistant" agent with:
30+
- System prompt from `system_prompt.md`
31+
- `messageClaudeCode` client tool
32+
- `processPermissionRequest` client tool
33+
- Patience settings (no "are you still there?" nagging)
34+
35+
**Idempotent**: Running multiple times is safe - it will update the existing agent.
36+
37+
### `list-agents.sh`
38+
39+
Lists all your ElevenLabs agents with their IDs.
40+
41+
```bash
42+
./list-agents.sh
43+
```
44+
45+
### `get-agent.sh`
46+
47+
Shows detailed configuration for a specific agent.
48+
49+
```bash
50+
./get-agent.sh agent_xxxxx
51+
```
52+
53+
### `delete-agent.sh`
54+
55+
Deletes an agent (with confirmation prompt).
56+
57+
```bash
58+
./delete-agent.sh agent_xxxxx
59+
```
60+
61+
## Client Tools
62+
63+
The agent is configured with two client tools that the Happy app implements:
64+
65+
### `messageClaudeCode`
66+
67+
Sends a message to Claude Code on behalf of the user.
68+
69+
- **Parameter**: `message` (string) - The message to send
70+
- **Returns**: "sent" on success
71+
72+
### `processPermissionRequest`
73+
74+
Handles permission requests from Claude Code.
75+
76+
- **Parameter**: `decision` (string) - Either "allow" or "deny"
77+
- **Returns**: "done" on success
78+
79+
## Environment Variables for happy-server
80+
81+
After running `setup-agent.sh`, add these to your happy-server:
82+
83+
```bash
84+
ELEVENLABS_API_KEY=sk_your_api_key
85+
ELEVENLABS_AGENT_ID=agent_xxxxx # Output from setup-agent.sh
86+
```
87+
88+
## Customization
89+
90+
Edit `system_prompt.md` to customize the assistant's personality and behavior, then run `./setup-agent.sh` again to update the agent.

voice_agent/delete-agent.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
#
3+
# Delete an ElevenLabs Conversational AI agent
4+
#
5+
# Usage: ./delete-agent.sh <agent_id>
6+
#
7+
# Required environment variable:
8+
# ELEVENLABS_API_KEY - Your ElevenLabs API key
9+
#
10+
11+
set -e
12+
13+
if [ -z "$ELEVENLABS_API_KEY" ]; then
14+
echo "Error: ELEVENLABS_API_KEY environment variable is not set"
15+
exit 1
16+
fi
17+
18+
if [ -z "$1" ]; then
19+
echo "Usage: ./delete-agent.sh <agent_id>"
20+
echo ""
21+
echo "Run ./list-agents.sh to see available agent IDs"
22+
exit 1
23+
fi
24+
25+
AGENT_ID="$1"
26+
27+
echo "Are you sure you want to delete agent $AGENT_ID? [y/N]"
28+
read -r CONFIRM
29+
30+
if [ "$CONFIRM" != "y" ] && [ "$CONFIRM" != "Y" ]; then
31+
echo "Aborted."
32+
exit 0
33+
fi
34+
35+
echo "Deleting agent $AGENT_ID..."
36+
37+
RESPONSE=$(curl -s -w "\n%{http_code}" -X DELETE "https://api.elevenlabs.io/v1/convai/agents/$AGENT_ID" \
38+
-H "xi-api-key: $ELEVENLABS_API_KEY" \
39+
-H "Accept: application/json")
40+
41+
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
42+
BODY=$(echo "$RESPONSE" | sed '$d')
43+
44+
if [ "$HTTP_CODE" = "200" ] || [ "$HTTP_CODE" = "204" ]; then
45+
echo "Agent deleted successfully."
46+
else
47+
echo "Error deleting agent (HTTP $HTTP_CODE):"
48+
echo "$BODY" | jq -r '.detail.message // .detail // .' 2>/dev/null || echo "$BODY"
49+
exit 1
50+
fi

voice_agent/get-agent.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
#
3+
# Get detailed configuration for an ElevenLabs agent
4+
#
5+
# Usage: ./get-agent.sh <agent_id>
6+
#
7+
# Required environment variable:
8+
# ELEVENLABS_API_KEY - Your ElevenLabs API key
9+
#
10+
11+
set -e
12+
13+
if [ -z "$ELEVENLABS_API_KEY" ]; then
14+
echo "Error: ELEVENLABS_API_KEY environment variable is not set"
15+
exit 1
16+
fi
17+
18+
if [ -z "$1" ]; then
19+
echo "Usage: ./get-agent.sh <agent_id>"
20+
echo ""
21+
echo "Run ./list-agents.sh to see available agent IDs"
22+
exit 1
23+
fi
24+
25+
AGENT_ID="$1"
26+
27+
echo "Fetching agent $AGENT_ID..."
28+
echo ""
29+
30+
RESPONSE=$(curl -s -X GET "https://api.elevenlabs.io/v1/convai/agents/$AGENT_ID" \
31+
-H "xi-api-key: $ELEVENLABS_API_KEY" \
32+
-H "Accept: application/json")
33+
34+
if echo "$RESPONSE" | grep -q '"detail"'; then
35+
echo "Error from ElevenLabs API:"
36+
echo "$RESPONSE" | jq -r '.detail.message // .detail // .'
37+
exit 1
38+
fi
39+
40+
echo "$RESPONSE" | jq .

voice_agent/list-agents.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
#
3+
# List all ElevenLabs Conversational AI agents
4+
#
5+
# Usage: ./list-agents.sh
6+
#
7+
# Required environment variable:
8+
# ELEVENLABS_API_KEY - Your ElevenLabs API key
9+
#
10+
11+
set -e
12+
13+
if [ -z "$ELEVENLABS_API_KEY" ]; then
14+
echo "Error: ELEVENLABS_API_KEY environment variable is not set"
15+
exit 1
16+
fi
17+
18+
echo "Fetching agents..."
19+
echo ""
20+
21+
RESPONSE=$(curl -s -X GET "https://api.elevenlabs.io/v1/convai/agents" \
22+
-H "xi-api-key: $ELEVENLABS_API_KEY" \
23+
-H "Accept: application/json")
24+
25+
if echo "$RESPONSE" | grep -q '"detail"'; then
26+
echo "Error from ElevenLabs API:"
27+
echo "$RESPONSE" | jq -r '.detail.message // .detail // .'
28+
exit 1
29+
fi
30+
31+
AGENT_COUNT=$(echo "$RESPONSE" | jq '.agents | length')
32+
33+
if [ "$AGENT_COUNT" = "0" ]; then
34+
echo "No agents found."
35+
exit 0
36+
fi
37+
38+
echo "Found $AGENT_COUNT agent(s):"
39+
echo ""
40+
41+
echo "$RESPONSE" | jq -r '.agents[] | " Name: \(.name)\n ID: \(.agent_id)\n"'

0 commit comments

Comments
 (0)