|
1 | 1 | ---
|
2 | 2 | title: "Configuring your number"
|
3 |
| -description: "Learn how to configure your phone number with an agent." |
| 3 | +description: "Setting up our agent to function as a receptionist" |
4 | 4 | ---
|
5 | 5 |
|
6 |
| -# Configuring Numbers |
| 6 | +Now that we have a number set up on Vocode, our agent is ready to start accepting calls. Vocode [Agents](/agents) |
| 7 | +have several different parameters we can use to control its behavior. We're going to be setting up our receptionist |
| 8 | +by modifying: |
7 | 9 |
|
8 |
| -Once you have purchased a number, you can configure it with an inbound agent to set its prompt, voice, and actions. |
| 10 | +1. Voice -> this is the voice of our agent |
| 11 | +2. Prompt -> the prompt is the instruction we give our agent that controls its behavior |
| 12 | +3. Actions -> actions are things that the agent **_can do_** like end the conversation or |
| 13 | + make an API request to an external service (like a calendar booking software) |
9 | 14 |
|
10 |
| -## Pick your Number |
| 15 | +## Setting up our receptionist |
11 | 16 |
|
12 |
| -First, list your numbers and pick the number you want to configure. |
| 17 | +### Voice |
13 | 18 |
|
14 |
| -<CodeGroup> |
| 19 | +First, let's create a new voice via [ElevenLabs]("https://elevenlabs.io) and grab the voice ID. |
15 | 20 |
|
16 |
| -```python Python |
17 |
| -numbers = vocode_client.numbers.list_numbers() |
18 | 21 | ```
|
| 22 | +voice = vocode_client.voices.create_voice( |
| 23 | + request={ |
| 24 | + "type": "voice_eleven_labs", |
| 25 | + "voice_id": "06oPEcZqPWhZ2IeTcOJc", |
| 26 | + "stability": ".2", |
| 27 | + "similarity_boost": ".75", |
| 28 | + "model_id": "eleven_turbo_v2", |
| 29 | + "optimize_streaming_latency": "4", |
| 30 | + } |
| 31 | +) |
19 | 32 |
|
20 |
| -```javascript TypeScript |
21 |
| -const numbers = await vocode.numbers.listNumbers(); |
| 33 | +voice_id = voice.id |
22 | 34 | ```
|
23 | 35 |
|
24 |
| -</CodeGroup> |
25 |
| - |
26 |
| -## Changing the Prompt |
| 36 | +For other voice options curated by Vocode, check out our page on [Voices](/voices). Voice clones are also available on demand |
| 37 | +for enterprise accounts. |
27 | 38 |
|
28 |
| -All phone numbers come with the default agent configuration. Let's change the |
29 |
| -prompt so the AI responds like Yoda. |
| 39 | +### Prompt |
30 | 40 |
|
31 |
| -<CodeGroup> |
| 41 | +The prompt is how our agent will know what instructions to follow on the call. We're going to set up a prompt suitable for a |
| 42 | +receptionist agent and create a prompt object in the API: |
32 | 43 |
|
33 |
| -```python Python |
34 |
| -from vocode import AgentUpdateParams, PromptUpdateParams |
35 |
| - |
36 |
| -yoda_prompt = PromptUpdateParams(content="I want you to act as Yoda. Respond as Yoda would.") |
37 |
| -number = vocode_client.numbers.update_number( |
38 |
| - phone_number="YOUR_NUMBER", inbound_agent=AgentUpdateParams(prompt=yoda_prompt) |
39 |
| -) |
40 | 44 | ```
|
| 45 | +PROMPT = """ |
| 46 | +sample prompt |
| 47 | +""" |
41 | 48 |
|
42 |
| -```javascript TypeScript |
43 |
| -const yoda_prompt = "I want you to act as Yoda. Respond as Yoda would."; |
44 |
| -const number = await vocode.numbers.updateNumber({ |
45 |
| - phoneNumber: "YOUR_NUMBER", |
46 |
| - inboundAgent: { prompt: { content: yoda_prompt } }, |
47 |
| -}); |
| 49 | +prompt = vocode_client.prompts.create_prompt(request={"content": PROMPT}) |
| 50 | +prompt_id = prompt.id |
48 | 51 | ```
|
49 | 52 |
|
50 |
| -</CodeGroup> |
| 53 | +For more guidance on how prompts work check out our guide on [Prompt Objects](/prompts) and [Prompt Engineering](/prompt-engineering). |
51 | 54 |
|
52 |
| -## Changing the Voice |
| 55 | +### Actions |
53 | 56 |
|
54 |
| -Our prompt has been updated. Now let's use a voice provided by other API providers. |
| 57 | +Finally, for our receptionist to be complete, we're going to want to give it the ability to actually do two things: |
55 | 58 |
|
56 |
| -### Rime |
| 59 | +1. End the conversation |
| 60 | +2. Make an API call to our calendar software to book calendar appointments. |
57 | 61 |
|
58 |
| -<CodeGroup> |
| 62 | +Let's set up both of these actions using the API: |
59 | 63 |
|
60 |
| -```python Python |
61 |
| -from vocode import RimeVoiceParams |
| 64 | +```python |
62 | 65 |
|
63 |
| -rime_voice = RimeVoiceParams( |
64 |
| - type="voice_rime", |
65 |
| - speaker="RIME_SPEAKER", |
| 66 | +# This action ends the conversation |
| 67 | +end_conversation_action = vocode_client.actions.create_action( |
| 68 | + request=ActionParamsRequest(type="action_end_conversation", config={}) |
66 | 69 | )
|
67 |
| -voice = vocode_client.voices.create_voice(request=rime_voice) |
68 |
| -``` |
69 |
| - |
70 |
| -```javascript TypeScript |
71 |
| -const rimeVoice = { |
72 |
| - type: "voice_rime", |
73 |
| - voiceId: "RIME_SPEAKER", |
74 |
| -}; |
75 |
| -const number = await vocode.voices.createVoice(rimeVoice); |
76 |
| -``` |
77 |
| - |
78 |
| -</CodeGroup> |
79 | 70 |
|
80 |
| -### Play.ht |
81 |
| - |
82 |
| -<CodeGroup> |
83 |
| - |
84 |
| -```python Python |
85 |
| -from vocode import PlayHtVoiceParams |
86 |
| - |
87 |
| -play_ht_voice = PlayHtVoiceParams( |
88 |
| - type="voice_play_ht", |
89 |
| - voice_id="PLAY_HT_VOICE_ID", |
90 |
| - api_user_id="PLAY_HT_USER_ID", |
91 |
| - api_key="PLAY_HT_API_KEY", |
| 71 | +# This action makes an API call to our calendar endpoint |
| 72 | +calendar_action = vocode_client.actions.create_action( |
| 73 | + request={ |
| 74 | + "type": "action_external", |
| 75 | + "config": { |
| 76 | + "name": "Meeting_Booking_Assistant", |
| 77 | + "description": ("Book a meeting for a 30 minute or 1 hour call."), |
| 78 | + "url": "http://example.com/booking", |
| 79 | + "speak_on_send": True, |
| 80 | + "speak_on_receive": True, |
| 81 | + "input_schema": { |
| 82 | + "type": "object", |
| 83 | + "properties": { |
| 84 | + "length": { |
| 85 | + "type": "string", |
| 86 | + "enum": ["30m", "1hr"], |
| 87 | + }, |
| 88 | + "time": { |
| 89 | + "type": "string", |
| 90 | + "pattern": "^\d{2}:\d0[ap]m$", |
| 91 | + }, |
| 92 | + }, |
| 93 | + }, |
| 94 | + }, |
| 95 | + }, |
92 | 96 | )
|
93 |
| -voice = vocode_client.voices.create_voice(request=play_ht_voice) |
94 | 97 | ```
|
95 | 98 |
|
96 |
| -```javascript TypeScript |
97 |
| -const playHtVoice = { |
98 |
| - type: "voice_play_ht", |
99 |
| - voiceId: "PLAY_HT_VOICE_ID", |
100 |
| - apiUserId: "PLAY_HT_USER_ID", |
101 |
| - apiKey: "PLAY_HT_API_KEY, |
102 |
| -}; |
103 |
| -const number = await vocode.voices.createVoice(playHtVoice); |
104 |
| -``` |
| 99 | +For more information on how to set up actions, check out our [Actions](/actions) guide and our new beta feature |
| 100 | +[External Actions](/external-actions) which we are using here to make the calendar API call. |
105 | 101 |
|
106 |
| -</CodeGroup> |
| 102 | +## Updating our agent |
107 | 103 |
|
108 |
| -### ElevenLabs |
| 104 | +Now that we've created our voice, prompt, and actions, we can run a query to update our agent as follows. We'll |
| 105 | +also add an `initial_message` to our agent to greet people who call in. |
109 | 106 |
|
110 |
| -We will use the `rachel` voice from ElevenLabs. Instead of updating our existing agent directly, |
111 |
| -we'll create a new voice config and set the agent to use it. |
| 107 | +We'll have to first grab the `agent_id` in order to make the `agent/update` request. Here's how we can grab it from our |
| 108 | +phone number: |
112 | 109 |
|
113 |
| -<CodeGroup> |
114 |
| -
|
115 |
| -```python Python |
116 |
| -from vocode import ElevenLabsVoiceParams |
117 |
| -
|
118 |
| -elevenlabs_voice = ElevenLabsVoiceParams( |
119 |
| - type="voice_eleven_labs", |
120 |
| - voice_id="ELEVEN_LABS_VOICE_ID", |
121 |
| - api_key="ELEVEN_LABS_API_KEY", |
122 |
| -) |
123 |
| -voice = vocode_client.voices.create_voice(request=elevenlabs_voice) |
| 110 | +```python |
| 111 | +number = vocode_client.numbers.get(phone_number="1123456789") |
| 112 | +agent_id = number.agent_id |
| 113 | +print(agent_id) |
124 | 114 | ```
|
125 | 115 |
|
126 |
| -```javascript TypeScript |
127 |
| -const elevenlabsVoice = { |
128 |
| - type: "voice_eleven_labs", |
129 |
| - voiceId: "ELEVEN_LABS_VOICE_ID", |
130 |
| - apiKey: "ELEVEN_LABS_API_KEY", |
131 |
| -}; |
132 |
| -const number = await vocode.voices.createVoice(elevenlabsVoice); |
133 |
| -``` |
134 |
| -
|
135 |
| -</CodeGroup> |
136 |
| -
|
137 |
| -Now, we have our `voice_id` and can update our agent to use it. |
138 |
| -
|
139 |
| -<CodeGroup> |
| 116 | +Which should output a UUID for our agent. |
140 | 117 |
|
141 |
| -```python Python |
142 |
| -from vocode import AgentUpdateParams |
143 |
| -
|
144 |
| -agent = vocode_client.agents.update_agent( |
145 |
| - id="AGENT_ID", |
146 |
| - request=AgentUpdateParams(voice="VOICE_ID"), |
147 |
| -) |
148 | 118 | ```
|
149 |
| -
|
150 |
| -```javascript TypeScript |
151 |
| -const agent = await vocode.agents.updateAgent({ |
152 |
| - id: "AGENT_ID", |
153 |
| - body: { voice: "VOICE_ID" }, |
154 |
| -}); |
155 |
| -console.log(agent); |
| 119 | +ad1d802e-12ab-41c7-8726-14e119d6c92c |
156 | 120 | ```
|
157 | 121 |
|
158 |
| -</CodeGroup> |
| 122 | +And now we can use the `agent_id` in our update request as follows: |
159 | 123 |
|
160 |
| -## Adding an Initial Message |
| 124 | +```python |
| 125 | +INITIAL_MESSAGE = "Hi, this is a Vocode scheduling agent, how can I help you?" |
161 | 126 |
|
162 |
| -The initial message will be spoken as soon as the call starts before the user says anything. Let's make our agent say "Hello, I am Yoda" when the call starts. |
163 |
| -
|
164 |
| -<CodeGroup> |
165 |
| -
|
166 |
| -```python Python |
167 |
| -from vocode import AgentUpdateParams |
168 |
| -
|
169 |
| -number = vocode_client.numbers.update_number( |
170 |
| - phone_number="YOUR_NUMBER", inbound_agent=AgentUpdateParams(initial_message="Hello, I am Yoda.") |
| 127 | +update_response = vocode_client.agents.update_agent( |
| 128 | + id=agent_id, |
| 129 | + request=AgentUpdateParams( |
| 130 | + initial_message=INITIAL_MESSAGE, |
| 131 | + prompt=prompt_id, |
| 132 | + voice=voice_id, |
| 133 | + actions=[end_conversation_action_id, external_action_id], |
| 134 | + ), |
171 | 135 | )
|
172 |
| -
|
173 |
| -``` |
174 |
| -
|
175 |
| -```javascript TypeScript |
176 |
| -import { VocodeClient } from "@vocode/vocode-api"; |
177 |
| -
|
178 |
| -const number = await vocode.numbers.updateNumber({ |
179 |
| - phoneNumber: "YOUR_NUMBER", |
180 |
| - inboundAgent: { initialMessage: "Hello, I am Yoda." }, |
181 |
| -}); |
182 | 136 | ```
|
183 | 137 |
|
184 |
| -</CodeGroup> |
| 138 | +Now our agent is ready to be a receptionist! Check it out by giving it a call. |
0 commit comments