Building your first voice AI agent
In this guide, we’ll create a simple agent that can make outbound calls and receive inbound calls. The example code for this guide is available here.
1. Create an API key
Navigate to the API keys page, create a new API key,
and store it in a .env.local file.
.env.local
2. Install the SDK
Install the Phonic SDK and dotenv to load the API key from the .env.local file.
3. Initialize the client
4. Create an agent
Let’s create an agent and assign it a random phone number.
You should see now my-first-agent on the Agents page.
5. Make an outbound call
Let’s make the agent call you. Specify your phone number, the agent name, and a welcome message:
Now, pick up the phone and chat with your agent!
6. Make an inbound call
Grab the agent’s phone number on the Agents page, and give it a call!
See here for a complete code example.