elevenlabs-voice-agent-mcp 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +23 -0
- package/.env.example +3 -0
- package/AGENTS.md +37 -0
- package/CLAUDE.md +233 -0
- package/README.md +9 -30
- package/call-exact-format.ts +66 -0
- package/call-wait-null.ts +71 -0
- package/create-agent-simple.ts +84 -0
- package/create-new-agent.ts +98 -0
- package/demo-agent-system-prompt.xml +166 -0
- package/dist/index.js +0 -0
- package/elevenlabs-voice-agent-mcp-1.0.0.tgz +0 -0
- package/em_positive_leads.csv +25 -0
- package/list-resources.ts +93 -0
- package/make-call-now.ts +66 -0
- package/make-test-call.ts +80 -0
- package/openapi.json +3238 -0
- package/package.json +3 -33
- package/src/constants.ts +62 -0
- package/src/index.ts +143 -0
- package/src/schemas/agent-schemas.ts +193 -0
- package/src/schemas/batch-calling-schemas.ts +96 -0
- package/src/schemas/common-schemas.ts +83 -0
- package/src/schemas/conversation-schemas.ts +44 -0
- package/src/schemas/outbound-schemas.ts +70 -0
- package/src/schemas/phone-number-schemas.ts +140 -0
- package/src/schemas/tool-schemas.ts +161 -0
- package/src/services/elevenlabs-api.ts +113 -0
- package/src/services/formatters.ts +623 -0
- package/src/tools/agent-tools.ts +425 -0
- package/src/tools/batch-calling-tools.ts +237 -0
- package/src/tools/conversation-tools.ts +167 -0
- package/src/tools/knowledge-tools.ts +73 -0
- package/src/tools/outbound-tools.ts +95 -0
- package/src/tools/phone-number-tools.ts +346 -0
- package/src/tools/tool-tools.ts +195 -0
- package/src/tools/utility-tools.ts +147 -0
- package/src/types.ts +327 -0
- package/src/utils/error-handlers.ts +98 -0
- package/src/utils/truncation.ts +97 -0
- package/test-call-wait-for-hello.ts +76 -0
- package/test-call.json +5 -0
- package/tsconfig.json +21 -0
- package/LICENSE +0 -21
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conversation retrieval tools
|
|
3
|
+
*
|
|
4
|
+
* MCP tools for accessing conversation histories, transcripts, and analytics.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { getRequest } from "../services/elevenlabs-api.js";
|
|
8
|
+
import { formatResponse } from "../services/formatters.js";
|
|
9
|
+
import { ConversationMetadata, PaginatedResponse } from "../types.js";
|
|
10
|
+
import {
|
|
11
|
+
GetConversationSchema,
|
|
12
|
+
ListConversationsSchema
|
|
13
|
+
} from "../schemas/conversation-schemas.js";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Retrieves a single conversation with full transcript
|
|
17
|
+
*/
|
|
18
|
+
export const elevenlabs_get_conversation = {
|
|
19
|
+
name: "elevenlabs_get_conversation",
|
|
20
|
+
description: `Retrieve complete details and transcript for a specific conversation.
|
|
21
|
+
|
|
22
|
+
This tool fetches full conversation details including the complete transcript, tool calls made, analysis metrics, and metadata. Use this to review past conversations, debug issues, or analyze agent performance.
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
- conversation_id (string): Unique conversation identifier
|
|
26
|
+
- response_format ('markdown' | 'json'): Output format
|
|
27
|
+
|
|
28
|
+
Returns:
|
|
29
|
+
Complete conversation object with:
|
|
30
|
+
- Conversation metadata (status, timestamps, duration)
|
|
31
|
+
- Full transcript with user and agent messages
|
|
32
|
+
- Tool calls made during the conversation
|
|
33
|
+
- Analysis data (sentiment, performance, key topics)
|
|
34
|
+
|
|
35
|
+
Examples:
|
|
36
|
+
- Use when: "Show me the transcript for conversation conv_xyz789"
|
|
37
|
+
- Use when: "What did the agent say in this conversation?"
|
|
38
|
+
- Use when: "Review the conversation that failed"
|
|
39
|
+
- Don't use when: You want to list multiple conversations (use elevenlabs_list_conversations)
|
|
40
|
+
|
|
41
|
+
Error Handling:
|
|
42
|
+
- Returns "Error: Conversation not found" if conversation_id doesn't exist
|
|
43
|
+
- Returns "Error: Invalid API key" if authentication fails`,
|
|
44
|
+
|
|
45
|
+
zodSchema: GetConversationSchema,
|
|
46
|
+
|
|
47
|
+
annotations: {
|
|
48
|
+
readOnlyHint: true,
|
|
49
|
+
destructiveHint: false,
|
|
50
|
+
idempotentHint: true,
|
|
51
|
+
openWorldHint: true
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
handler: async (args: unknown) => {
|
|
55
|
+
const parsed = GetConversationSchema.parse(args);
|
|
56
|
+
|
|
57
|
+
const conversation = await getRequest<ConversationMetadata>(
|
|
58
|
+
`/convai/conversations/${parsed.conversation_id}`
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
content: [
|
|
63
|
+
{
|
|
64
|
+
type: "text",
|
|
65
|
+
text: formatResponse(conversation, parsed.response_format, "conversation")
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Lists conversations with filtering and pagination
|
|
74
|
+
*/
|
|
75
|
+
export const elevenlabs_list_conversations = {
|
|
76
|
+
name: "elevenlabs_list_conversations",
|
|
77
|
+
description: `List conversations with optional filtering by agent, status, and date range.
|
|
78
|
+
|
|
79
|
+
This tool retrieves a paginated list of conversations. You can filter by agent ID, conversation status, or date range to find specific conversations. Use this for monitoring, analytics, or reviewing agent interactions.
|
|
80
|
+
|
|
81
|
+
Args:
|
|
82
|
+
- agent_id (string): Optional - filter by specific agent
|
|
83
|
+
- status ('in_progress' | 'completed' | 'failed'): Optional - filter by status
|
|
84
|
+
- date_range (object): Optional - filter by date range with:
|
|
85
|
+
- start (string): Start date in ISO 8601 format
|
|
86
|
+
- end (string): End date in ISO 8601 format
|
|
87
|
+
- limit (number): Maximum conversations to return (1-100, default: 20)
|
|
88
|
+
- offset (number): Number to skip for pagination (default: 0)
|
|
89
|
+
- response_format ('markdown' | 'json'): Output format
|
|
90
|
+
|
|
91
|
+
Returns:
|
|
92
|
+
For JSON format: Object with total count, items array, offset, has_more, and next_offset
|
|
93
|
+
For Markdown format: Formatted list of conversations with key details and pagination guidance
|
|
94
|
+
|
|
95
|
+
Examples:
|
|
96
|
+
- Use when: "Show me all conversations from yesterday"
|
|
97
|
+
- Use when: "List failed conversations for agent ag_abc123"
|
|
98
|
+
- Use when: "Get the last 50 conversations"
|
|
99
|
+
- Use when: "Show conversations that are still in progress"
|
|
100
|
+
- Don't use when: You want full transcript (use elevenlabs_get_conversation)
|
|
101
|
+
|
|
102
|
+
Error Handling:
|
|
103
|
+
- Returns empty list if no conversations match filters
|
|
104
|
+
- Returns "Error: Invalid date format" if date_range is malformed`,
|
|
105
|
+
|
|
106
|
+
zodSchema: ListConversationsSchema,
|
|
107
|
+
|
|
108
|
+
annotations: {
|
|
109
|
+
readOnlyHint: true,
|
|
110
|
+
destructiveHint: false,
|
|
111
|
+
idempotentHint: true,
|
|
112
|
+
openWorldHint: true
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
handler: async (args: unknown) => {
|
|
116
|
+
const parsed = ListConversationsSchema.parse(args);
|
|
117
|
+
|
|
118
|
+
const params: Record<string, unknown> = {
|
|
119
|
+
limit: parsed.limit,
|
|
120
|
+
offset: parsed.offset
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
if (parsed.agent_id) {
|
|
124
|
+
params.agent_id = parsed.agent_id;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (parsed.status) {
|
|
128
|
+
params.status = parsed.status;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (parsed.date_range) {
|
|
132
|
+
if (parsed.date_range.start) {
|
|
133
|
+
params.start_date = parsed.date_range.start;
|
|
134
|
+
}
|
|
135
|
+
if (parsed.date_range.end) {
|
|
136
|
+
params.end_date = parsed.date_range.end;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const response = await getRequest<{ conversations: ConversationMetadata[] }>(
|
|
141
|
+
"/convai/conversations",
|
|
142
|
+
params
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
const conversations = response.conversations || [];
|
|
146
|
+
const total = conversations.length;
|
|
147
|
+
const hasMore = conversations.length === parsed.limit;
|
|
148
|
+
|
|
149
|
+
const paginatedResponse: PaginatedResponse<ConversationMetadata> = {
|
|
150
|
+
total,
|
|
151
|
+
count: conversations.length,
|
|
152
|
+
offset: parsed.offset,
|
|
153
|
+
items: conversations,
|
|
154
|
+
has_more: hasMore,
|
|
155
|
+
next_offset: hasMore ? parsed.offset + conversations.length : undefined
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
return {
|
|
159
|
+
content: [
|
|
160
|
+
{
|
|
161
|
+
type: "text",
|
|
162
|
+
text: formatResponse(paginatedResponse, parsed.response_format, "conversation_list")
|
|
163
|
+
}
|
|
164
|
+
]
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Knowledge base management tools
|
|
3
|
+
*
|
|
4
|
+
* MCP tools for adding documents and URLs to agent knowledge bases.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { postRequest } from "../services/elevenlabs-api.js";
|
|
8
|
+
import { formatResponse } from "../services/formatters.js";
|
|
9
|
+
import { ResponseFormat } from "../types.js";
|
|
10
|
+
import { AddKnowledgeBaseSchema } from "../schemas/tool-schemas.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Adds documents to an agent's knowledge base
|
|
14
|
+
*/
|
|
15
|
+
export const elevenlabs_add_knowledge_base = {
|
|
16
|
+
name: "elevenlabs_add_knowledge_base",
|
|
17
|
+
description: `Add documents or URLs to an agent's knowledge base.
|
|
18
|
+
|
|
19
|
+
This tool enables agents to reference custom knowledge when responding to users. You can add text documents or URLs that will be fetched and indexed. The agent will automatically use this information when relevant to the conversation.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
- agent_id (string): Agent identifier to add knowledge to
|
|
23
|
+
- documents (array): Array of document objects with:
|
|
24
|
+
- type ('text' | 'url'): Type of document
|
|
25
|
+
- content (string): For 'text': the actual text. For 'url': the URL to fetch
|
|
26
|
+
- metadata (object): Optional key-value metadata about the document
|
|
27
|
+
- response_format ('markdown' | 'json'): Output format
|
|
28
|
+
|
|
29
|
+
Returns:
|
|
30
|
+
Confirmation message indicating successful knowledge base update.
|
|
31
|
+
|
|
32
|
+
Examples:
|
|
33
|
+
- Use when: "Add this FAQ document to the agent's knowledge base"
|
|
34
|
+
- Use when: "Index the company policy page at https://example.com/policies"
|
|
35
|
+
- Use when: "Give the agent access to product documentation"
|
|
36
|
+
- Don't use when: You want to add webhook tools (use elevenlabs_create_webhook_tool)
|
|
37
|
+
|
|
38
|
+
Error Handling:
|
|
39
|
+
- Returns "Error: Agent not found" if agent_id doesn't exist
|
|
40
|
+
- Returns "Error: Invalid URL" if URL document is not accessible
|
|
41
|
+
- Returns "Error: Document too large" if content exceeds size limits`,
|
|
42
|
+
|
|
43
|
+
zodSchema: AddKnowledgeBaseSchema,
|
|
44
|
+
|
|
45
|
+
annotations: {
|
|
46
|
+
readOnlyHint: false,
|
|
47
|
+
destructiveHint: false,
|
|
48
|
+
idempotentHint: false,
|
|
49
|
+
openWorldHint: true
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
handler: async (args: unknown) => {
|
|
53
|
+
const parsed = AddKnowledgeBaseSchema.parse(args);
|
|
54
|
+
|
|
55
|
+
const result = await postRequest(
|
|
56
|
+
`/convai/agents/${parsed.agent_id}/knowledge-base`,
|
|
57
|
+
{ documents: parsed.documents }
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const message = `Successfully added ${parsed.documents.length} document(s) to agent ${parsed.agent_id}'s knowledge base.`;
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
content: [
|
|
64
|
+
{
|
|
65
|
+
type: "text",
|
|
66
|
+
text: parsed.response_format === ResponseFormat.JSON
|
|
67
|
+
? formatResponse({ success: true, message, documents_added: parsed.documents.length }, parsed.response_format, "generic")
|
|
68
|
+
: message
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outbound calling tools
|
|
3
|
+
*
|
|
4
|
+
* MCP tool for initiating single outbound phone calls via Twilio.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { postRequest } from "../services/elevenlabs-api.js";
|
|
8
|
+
import { formatResponse } from "../services/formatters.js";
|
|
9
|
+
import { OutboundCallResponse } from "../types.js";
|
|
10
|
+
import { StartOutboundCallSchema } from "../schemas/outbound-schemas.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Starts a single outbound call via Twilio
|
|
14
|
+
*/
|
|
15
|
+
export const elevenlabs_start_outbound_call = {
|
|
16
|
+
name: "elevenlabs_start_outbound_call",
|
|
17
|
+
description: `Initiate a single outbound phone call using an ElevenLabs Voice Agent via Twilio.
|
|
18
|
+
|
|
19
|
+
This tool starts an AI-powered phone call to a specific phone number. The agent will use its configured prompt, voice, and tools to have a conversation with the person who answers. You can personalize the call with dynamic variables and override agent settings for this specific call.
|
|
20
|
+
|
|
21
|
+
Prerequisites:
|
|
22
|
+
- A Twilio phone number must be imported and associated with an agent
|
|
23
|
+
- The agent must be properly configured
|
|
24
|
+
- Destination phone number must be valid
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
- agent_id (string): Agent to use for this call (e.g., 'ag_abc123')
|
|
28
|
+
- agent_phone_number_id (string): Phone number ID to use as caller ID
|
|
29
|
+
- to_number (string): Destination phone number in E.164 format (e.g., '+1234567890')
|
|
30
|
+
- conversation_initiation_client_data (object): Optional personalization data
|
|
31
|
+
- dynamic_variables (object): Dynamic variables for personalization
|
|
32
|
+
Example: {dynamic_variables: {name: 'John', user_id: '123', account_balance: 1500}}
|
|
33
|
+
- conversation_config_override (object): Override agent settings for this call
|
|
34
|
+
- agent.first_message: Custom greeting for this call
|
|
35
|
+
- agent.prompt.prompt: Custom system prompt for this call
|
|
36
|
+
- agent.language: Language override
|
|
37
|
+
- tts.voice_id: Voice override
|
|
38
|
+
- conversation.max_duration_seconds: Maximum call duration
|
|
39
|
+
- response_format ('markdown' | 'json'): Output format
|
|
40
|
+
|
|
41
|
+
Returns:
|
|
42
|
+
- success: Whether the call was initiated
|
|
43
|
+
- message: Human-readable status message
|
|
44
|
+
- conversation_id: ID to track this conversation (null if failed)
|
|
45
|
+
- callSid: Twilio call identifier (null if failed)
|
|
46
|
+
|
|
47
|
+
Examples:
|
|
48
|
+
- Use when: "Call +14155551234 with the sales agent"
|
|
49
|
+
- Use when: "Start outbound call to check appointment with customer John"
|
|
50
|
+
- Use when: "Dispatch agent to +447911123456 with custom greeting"
|
|
51
|
+
- Don't use when: You want to make multiple calls at once (use elevenlabs_submit_batch_call)
|
|
52
|
+
- Don't use when: Phone number isn't set up yet (use elevenlabs_import_phone_number first)
|
|
53
|
+
|
|
54
|
+
Error Handling:
|
|
55
|
+
- Returns success: false if call initiation fails
|
|
56
|
+
- Returns "Error: Phone number not found" if agent_phone_number_id is invalid
|
|
57
|
+
- Returns "Error: Agent not found" if agent_id doesn't exist
|
|
58
|
+
- Returns "Error: Invalid phone number format" if to_number is malformed`,
|
|
59
|
+
|
|
60
|
+
zodSchema: StartOutboundCallSchema,
|
|
61
|
+
|
|
62
|
+
annotations: {
|
|
63
|
+
readOnlyHint: false,
|
|
64
|
+
destructiveHint: false,
|
|
65
|
+
idempotentHint: false,
|
|
66
|
+
openWorldHint: true
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
handler: async (args: unknown) => {
|
|
70
|
+
const parsed = StartOutboundCallSchema.parse(args);
|
|
71
|
+
|
|
72
|
+
const requestData = {
|
|
73
|
+
agent_id: parsed.agent_id,
|
|
74
|
+
agent_phone_number_id: parsed.agent_phone_number_id,
|
|
75
|
+
to_number: parsed.to_number,
|
|
76
|
+
...(parsed.conversation_initiation_client_data && {
|
|
77
|
+
conversation_initiation_client_data: parsed.conversation_initiation_client_data
|
|
78
|
+
})
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const response = await postRequest<OutboundCallResponse>(
|
|
82
|
+
"/convai/twilio/outbound-call",
|
|
83
|
+
requestData
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
content: [
|
|
88
|
+
{
|
|
89
|
+
type: "text",
|
|
90
|
+
text: formatResponse(response, parsed.response_format, "outbound_call")
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
};
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phone number management tools
|
|
3
|
+
*
|
|
4
|
+
* MCP tools for listing, importing, updating, and deleting phone numbers
|
|
5
|
+
* connected to voice agents via Twilio or SIP trunking.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { getRequest, postRequest, patchRequest, deleteRequest } from "../services/elevenlabs-api.js";
|
|
9
|
+
import { formatResponse } from "../services/formatters.js";
|
|
10
|
+
import { PhoneNumber, ImportPhoneNumberResponse } from "../types.js";
|
|
11
|
+
import {
|
|
12
|
+
ListPhoneNumbersSchema,
|
|
13
|
+
GetPhoneNumberSchema,
|
|
14
|
+
ImportPhoneNumberSchema,
|
|
15
|
+
UpdatePhoneNumberSchema,
|
|
16
|
+
DeletePhoneNumberSchema
|
|
17
|
+
} from "../schemas/phone-number-schemas.js";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Lists all phone numbers connected to the workspace
|
|
21
|
+
*/
|
|
22
|
+
export const elevenlabs_list_phone_numbers = {
|
|
23
|
+
name: "elevenlabs_list_phone_numbers",
|
|
24
|
+
description: `List all phone numbers connected to your ElevenLabs workspace.
|
|
25
|
+
|
|
26
|
+
This tool retrieves all phone numbers you've imported (Twilio or SIP trunk), showing which agents they're assigned to, their capabilities (inbound/outbound), and configuration details.
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
- response_format ('markdown' | 'json'): Output format
|
|
30
|
+
|
|
31
|
+
Returns:
|
|
32
|
+
Array of phone number objects, each containing:
|
|
33
|
+
- phone_number: The actual phone number
|
|
34
|
+
- label: Descriptive name
|
|
35
|
+
- phone_number_id: Unique identifier for API operations
|
|
36
|
+
- provider: 'twilio' or 'sip_trunk'
|
|
37
|
+
- supports_inbound: Whether it can receive calls
|
|
38
|
+
- supports_outbound: Whether it can make calls
|
|
39
|
+
- assigned_agent: Agent details (if assigned) or null
|
|
40
|
+
|
|
41
|
+
Examples:
|
|
42
|
+
- Use when: "Show me all my phone numbers"
|
|
43
|
+
- Use when: "List available phone numbers for outbound calling"
|
|
44
|
+
- Use when: "Which phone numbers are assigned to agents?"
|
|
45
|
+
- Don't use when: You want details about a specific phone number (use elevenlabs_get_phone_number)
|
|
46
|
+
|
|
47
|
+
Error Handling:
|
|
48
|
+
- Returns empty array if no phone numbers exist
|
|
49
|
+
- Returns "Error: Invalid API key" if authentication fails`,
|
|
50
|
+
|
|
51
|
+
zodSchema: ListPhoneNumbersSchema,
|
|
52
|
+
|
|
53
|
+
annotations: {
|
|
54
|
+
readOnlyHint: true,
|
|
55
|
+
destructiveHint: false,
|
|
56
|
+
idempotentHint: true,
|
|
57
|
+
openWorldHint: true
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
handler: async (args: unknown) => {
|
|
61
|
+
const parsed = ListPhoneNumbersSchema.parse(args);
|
|
62
|
+
|
|
63
|
+
const response = await getRequest<PhoneNumber[]>("/convai/phone-numbers");
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
content: [
|
|
67
|
+
{
|
|
68
|
+
type: "text",
|
|
69
|
+
text: formatResponse(response, parsed.response_format, "phone_number_list")
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Gets details about a specific phone number
|
|
78
|
+
*/
|
|
79
|
+
export const elevenlabs_get_phone_number = {
|
|
80
|
+
name: "elevenlabs_get_phone_number",
|
|
81
|
+
description: `Get detailed information about a specific phone number.
|
|
82
|
+
|
|
83
|
+
This tool retrieves complete configuration details for a phone number, including provider settings, agent assignment, trunk configurations, and capability flags.
|
|
84
|
+
|
|
85
|
+
Args:
|
|
86
|
+
- phone_number_id (string): Unique phone number identifier (e.g., 'pn_abc123')
|
|
87
|
+
- response_format ('markdown' | 'json'): Output format
|
|
88
|
+
|
|
89
|
+
Returns:
|
|
90
|
+
Complete phone number details including provider-specific configuration.
|
|
91
|
+
|
|
92
|
+
Examples:
|
|
93
|
+
- Use when: "Show me details for phone number pn_abc123"
|
|
94
|
+
- Use when: "What agent is assigned to phone pn_xyz789?"
|
|
95
|
+
- Use when: "Get configuration for phone number ID pn_test456"
|
|
96
|
+
- Don't use when: You want to list all phone numbers (use elevenlabs_list_phone_numbers)
|
|
97
|
+
|
|
98
|
+
Error Handling:
|
|
99
|
+
- Returns "Error: Phone number not found" if phone_number_id doesn't exist
|
|
100
|
+
- Returns "Error: Invalid API key" if authentication fails`,
|
|
101
|
+
|
|
102
|
+
zodSchema: GetPhoneNumberSchema,
|
|
103
|
+
|
|
104
|
+
annotations: {
|
|
105
|
+
readOnlyHint: true,
|
|
106
|
+
destructiveHint: false,
|
|
107
|
+
idempotentHint: true,
|
|
108
|
+
openWorldHint: true
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
handler: async (args: unknown) => {
|
|
112
|
+
const parsed = GetPhoneNumberSchema.parse(args);
|
|
113
|
+
|
|
114
|
+
const response = await getRequest<PhoneNumber>(
|
|
115
|
+
`/convai/phone-numbers/${parsed.phone_number_id}`
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
return {
|
|
119
|
+
content: [
|
|
120
|
+
{
|
|
121
|
+
type: "text",
|
|
122
|
+
text: formatResponse(response, parsed.response_format, "phone_number")
|
|
123
|
+
}
|
|
124
|
+
]
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Imports a Twilio phone number
|
|
131
|
+
*/
|
|
132
|
+
export const elevenlabs_import_phone_number = {
|
|
133
|
+
name: "elevenlabs_import_phone_number",
|
|
134
|
+
description: `Import a Twilio phone number to use with ElevenLabs Voice Agents.
|
|
135
|
+
|
|
136
|
+
This tool connects your existing Twilio phone number to ElevenLabs, enabling it for inbound and/or outbound voice agent calls. You'll need your Twilio Account SID and Auth Token.
|
|
137
|
+
|
|
138
|
+
Prerequisites:
|
|
139
|
+
- Active Twilio account with a purchased phone number
|
|
140
|
+
- Twilio Account SID and Auth Token
|
|
141
|
+
- Phone number must not already be imported
|
|
142
|
+
|
|
143
|
+
Args:
|
|
144
|
+
- phone_number (string): Phone number to import in E.164 format (e.g., '+1234567890')
|
|
145
|
+
- label (string): Descriptive name for this number (e.g., 'Customer Support Line')
|
|
146
|
+
- sid (string): Twilio Account SID (starts with 'AC')
|
|
147
|
+
- token (string): Twilio Auth Token
|
|
148
|
+
- provider (string): Must be 'twilio'
|
|
149
|
+
- supports_inbound (boolean, optional): Enable inbound calls (default: true)
|
|
150
|
+
- supports_outbound (boolean, optional): Enable outbound calls (default: true)
|
|
151
|
+
- region_config (object, optional): Regional configuration
|
|
152
|
+
- region_id: 'us1', 'ie1', or 'au1'
|
|
153
|
+
- token: Regional token
|
|
154
|
+
- edge_location: Twilio edge location
|
|
155
|
+
- response_format ('markdown' | 'json'): Output format
|
|
156
|
+
|
|
157
|
+
Returns:
|
|
158
|
+
- phone_number_id: Unique identifier for the imported phone number
|
|
159
|
+
|
|
160
|
+
Examples:
|
|
161
|
+
- Use when: "Import my Twilio number +1234567890 for customer support"
|
|
162
|
+
- Use when: "Connect Twilio phone number with SID AC123... for outbound calling"
|
|
163
|
+
- Use when: "Add new phone number +447911123456 from Twilio account"
|
|
164
|
+
- Don't use when: Number is already imported (update it instead)
|
|
165
|
+
- Don't use when: You need to assign it to an agent (use elevenlabs_update_phone_number after)
|
|
166
|
+
|
|
167
|
+
Error Handling:
|
|
168
|
+
- Returns "Error: Invalid Twilio credentials" if SID/token are wrong
|
|
169
|
+
- Returns "Error: Phone number already exists" if already imported
|
|
170
|
+
- Returns "Error: Invalid phone number format" if not E.164`,
|
|
171
|
+
|
|
172
|
+
zodSchema: ImportPhoneNumberSchema,
|
|
173
|
+
|
|
174
|
+
annotations: {
|
|
175
|
+
readOnlyHint: false,
|
|
176
|
+
destructiveHint: false,
|
|
177
|
+
idempotentHint: false,
|
|
178
|
+
openWorldHint: true
|
|
179
|
+
},
|
|
180
|
+
|
|
181
|
+
handler: async (args: unknown) => {
|
|
182
|
+
const parsed = ImportPhoneNumberSchema.parse(args);
|
|
183
|
+
|
|
184
|
+
const requestData = {
|
|
185
|
+
phone_number: parsed.phone_number,
|
|
186
|
+
label: parsed.label,
|
|
187
|
+
sid: parsed.sid,
|
|
188
|
+
token: parsed.token,
|
|
189
|
+
provider: parsed.provider,
|
|
190
|
+
...(parsed.supports_inbound !== undefined && {
|
|
191
|
+
supports_inbound: parsed.supports_inbound
|
|
192
|
+
}),
|
|
193
|
+
...(parsed.supports_outbound !== undefined && {
|
|
194
|
+
supports_outbound: parsed.supports_outbound
|
|
195
|
+
}),
|
|
196
|
+
...(parsed.region_config && {
|
|
197
|
+
region_config: parsed.region_config
|
|
198
|
+
})
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
const response = await postRequest<ImportPhoneNumberResponse>(
|
|
202
|
+
"/convai/phone-numbers",
|
|
203
|
+
requestData
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
return {
|
|
207
|
+
content: [
|
|
208
|
+
{
|
|
209
|
+
type: "text",
|
|
210
|
+
text: formatResponse(response, parsed.response_format, "phone_number_import")
|
|
211
|
+
}
|
|
212
|
+
]
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Updates a phone number (primarily for agent assignment)
|
|
219
|
+
*/
|
|
220
|
+
export const elevenlabs_update_phone_number = {
|
|
221
|
+
name: "elevenlabs_update_phone_number",
|
|
222
|
+
description: `Update a phone number's configuration, primarily to assign or unassign agents.
|
|
223
|
+
|
|
224
|
+
This tool modifies phone number settings. The most common use is assigning an agent to a phone number so the agent can handle calls from that number. You can also configure SIP trunk settings for advanced deployments.
|
|
225
|
+
|
|
226
|
+
Args:
|
|
227
|
+
- phone_number_id (string): Phone number identifier to update (e.g., 'pn_abc123')
|
|
228
|
+
- agent_id (string, optional): Agent ID to assign (set to null to unassign)
|
|
229
|
+
- inbound_trunk_config (object, optional): SIP trunk configuration for inbound
|
|
230
|
+
- outbound_trunk_config (object, optional): SIP trunk configuration for outbound
|
|
231
|
+
- livekit_stack ('standard' | 'static', optional): LiveKit stack configuration
|
|
232
|
+
- response_format ('markdown' | 'json'): Output format
|
|
233
|
+
|
|
234
|
+
Returns:
|
|
235
|
+
Updated phone number object with new configuration.
|
|
236
|
+
|
|
237
|
+
Examples:
|
|
238
|
+
- Use when: "Assign agent ag_abc123 to phone number pn_xyz789"
|
|
239
|
+
- Use when: "Connect my customer support agent to the main phone line"
|
|
240
|
+
- Use when: "Unassign agent from phone number pn_test456"
|
|
241
|
+
- Use when: "Update phone number pn_sales to use agent ag_sales"
|
|
242
|
+
- Don't use when: You need to import a new number (use elevenlabs_import_phone_number)
|
|
243
|
+
|
|
244
|
+
Error Handling:
|
|
245
|
+
- Returns "Error: Phone number not found" if phone_number_id doesn't exist
|
|
246
|
+
- Returns "Error: Agent not found" if agent_id doesn't exist
|
|
247
|
+
- Returns "Error: Invalid API key" if authentication fails`,
|
|
248
|
+
|
|
249
|
+
zodSchema: UpdatePhoneNumberSchema,
|
|
250
|
+
|
|
251
|
+
annotations: {
|
|
252
|
+
readOnlyHint: false,
|
|
253
|
+
destructiveHint: false,
|
|
254
|
+
idempotentHint: true,
|
|
255
|
+
openWorldHint: true
|
|
256
|
+
},
|
|
257
|
+
|
|
258
|
+
handler: async (args: unknown) => {
|
|
259
|
+
const parsed = UpdatePhoneNumberSchema.parse(args);
|
|
260
|
+
|
|
261
|
+
const updateData: Record<string, unknown> = {};
|
|
262
|
+
|
|
263
|
+
if (parsed.agent_id !== undefined) {
|
|
264
|
+
updateData.agent_id = parsed.agent_id;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
if (parsed.inbound_trunk_config !== undefined) {
|
|
268
|
+
updateData.inbound_trunk_config = parsed.inbound_trunk_config;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
if (parsed.outbound_trunk_config !== undefined) {
|
|
272
|
+
updateData.outbound_trunk_config = parsed.outbound_trunk_config;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
if (parsed.livekit_stack !== undefined) {
|
|
276
|
+
updateData.livekit_stack = parsed.livekit_stack;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const response = await patchRequest<PhoneNumber>(
|
|
280
|
+
`/convai/phone-numbers/${parsed.phone_number_id}`,
|
|
281
|
+
updateData
|
|
282
|
+
);
|
|
283
|
+
|
|
284
|
+
return {
|
|
285
|
+
content: [
|
|
286
|
+
{
|
|
287
|
+
type: "text",
|
|
288
|
+
text: formatResponse(response, parsed.response_format, "phone_number")
|
|
289
|
+
}
|
|
290
|
+
]
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Deletes a phone number
|
|
297
|
+
*/
|
|
298
|
+
export const elevenlabs_delete_phone_number = {
|
|
299
|
+
name: "elevenlabs_delete_phone_number",
|
|
300
|
+
description: `Delete a phone number from your ElevenLabs workspace.
|
|
301
|
+
|
|
302
|
+
This tool permanently removes a phone number from ElevenLabs. This does NOT delete the number from your Twilio account - it only disconnects it from ElevenLabs. You can re-import it later if needed.
|
|
303
|
+
|
|
304
|
+
IMPORTANT: This action cannot be undone. Any agent assignments will be removed.
|
|
305
|
+
|
|
306
|
+
Args:
|
|
307
|
+
- phone_number_id (string): Phone number identifier to delete (e.g., 'pn_abc123')
|
|
308
|
+
|
|
309
|
+
Returns:
|
|
310
|
+
Confirmation message indicating successful deletion.
|
|
311
|
+
|
|
312
|
+
Examples:
|
|
313
|
+
- Use when: "Delete phone number pn_test123"
|
|
314
|
+
- Use when: "Remove phone number pn_old456 from ElevenLabs"
|
|
315
|
+
- Use when: "Disconnect Twilio number pn_unused789"
|
|
316
|
+
- Don't use when: You just want to unassign an agent (use elevenlabs_update_phone_number)
|
|
317
|
+
- Don't use when: You're not sure - this is permanent!
|
|
318
|
+
|
|
319
|
+
Error Handling:
|
|
320
|
+
- Returns "Error: Phone number not found" if phone_number_id doesn't exist
|
|
321
|
+
- Returns "Error: Invalid API key" if authentication fails`,
|
|
322
|
+
|
|
323
|
+
zodSchema: DeletePhoneNumberSchema,
|
|
324
|
+
|
|
325
|
+
annotations: {
|
|
326
|
+
readOnlyHint: false,
|
|
327
|
+
destructiveHint: true,
|
|
328
|
+
idempotentHint: true,
|
|
329
|
+
openWorldHint: true
|
|
330
|
+
},
|
|
331
|
+
|
|
332
|
+
handler: async (args: unknown) => {
|
|
333
|
+
const parsed = DeletePhoneNumberSchema.parse(args);
|
|
334
|
+
|
|
335
|
+
await deleteRequest(`/convai/phone-numbers/${parsed.phone_number_id}`);
|
|
336
|
+
|
|
337
|
+
return {
|
|
338
|
+
content: [
|
|
339
|
+
{
|
|
340
|
+
type: "text",
|
|
341
|
+
text: `Successfully deleted phone number: ${parsed.phone_number_id}`
|
|
342
|
+
}
|
|
343
|
+
]
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
};
|