Configuring your number
Configuring Numbers
Once you have purchased a number, you can configure it with an inbound agent to set its prompt, voice, and actions.
Pick your Number
First, list your numbers and pick the number you want to configure.
numbers = vocode_client.numbers.list_numbers()
Changing the Prompt
All phone numbers come with the default agent configuration. Let’s change the prompt so the AI responds like Yoda.
from vocode import AgentUpdateParams, PromptUpdateParams
yoda_prompt = PromptUpdateParams(content="I want you to act as Yoda. Respond as Yoda would.")
number = vocode_client.numbers.update_number(
phone_number="YOUR_NUMBER", inbound_agent=AgentUpdateParams(prompt=yoda_prompt)
)
Changing the Voice
Our prompt has been updated. Now let’s use a voice provided by other API providers.
Rime
from vocode import RimeVoiceParams
rime_voice = RimeVoiceParams(
type="voice_rime",
speaker="RIME_SPEAKER",
)
voice = vocode_client.voices.create_voice(request=rime_voice)
Play.ht
from vocode import PlayHtVoiceParams
play_ht_voice = PlayHtVoiceParams(
type="voice_play_ht",
voice_id="PLAY_HT_VOICE_ID",
api_user_id="PLAY_HT_USER_ID",
api_key="PLAY_HT_API_KEY",
)
voice = vocode_client.voices.create_voice(request=play_ht_voice)
ElevenLabs
We will use the rachel
voice from ElevenLabs. Instead of updating our existing agent directly,
we’ll create a new voice config and set the agent to use it.
from vocode import ElevenLabsVoiceParams
elevenlabs_voice = ElevenLabsVoiceParams(
type="voice_eleven_labs",
voice_id="ELEVEN_LABS_VOICE_ID",
api_key="ELEVEN_LABS_API_KEY",
)
voice = vocode_client.voices.create_voice(request=elevenlabs_voice)
Now, we have our voice_id
and can update our agent to use it.
from vocode import AgentUpdateParams
agent = vocode_client.agents.update_agent(
id="AGENT_ID",
request=AgentUpdateParams(voice="VOICE_ID"),
)
Adding an Initial Message
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.
from vocode import AgentUpdateParams
number = vocode_client.numbers.update_number(
phone_number="YOUR_NUMBER", inbound_agent=AgentUpdateParams(initial_message="Hello, I am Yoda.")
)