This guide will help you make your first AI voice call using Trillet AI’s REST API.

Prerequisites

Before you begin, you’ll need:

  • A Trillet AI account (sign up here)
  • API credentials from your dashboard
  • A phone number for testing

Step 1: Create an Agent

First, create an AI agent that will handle the calls:

curl -X POST https://api.trillet.ai/api/v1/agents \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My First Agent",
    "llmModel": "gpt-4",
    "ttsModel": {
      "provider": "openai",
      "voiceId": "alloy"
    }
  }'

Response:

{
  "id": "agent_123abc",
  "name": "My First Agent",
  "status": "ready",
  "llmModel": "gpt-4",
  "ttsModel": {
    "provider": "openai",
    "voiceId": "alloy"
  },
  "createdAt": "2024-01-20T12:00:00Z"
}

Step 2: Create a Simple Flow

Next, create a conversation flow for your agent:

curl -X POST https://api.trillet.ai/api/v1/flows \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Simple Greeting",
    "agentId": "agent_123abc",
    "type": "simple",
    "prompt": "Greet the caller and ask how you can help them today."
  }'

Response:

{
  "id": "flow_xyz789",
  "name": "Simple Greeting",
  "status": "active",
  "agentId": "agent_123abc",
  "type": "simple",
  "prompt": "Greet the caller and ask how you can help them today.",
  "createdAt": "2024-01-20T12:01:00Z"
}

Step 3: Make Your First Call

Now you can initiate a call using your agent and flow:

curl -X POST https://api.trillet.ai/api/v1/calls/send \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "agentId": "agent_123abc",
    "flowId": "flow_xyz789",
    "toNumber": "+1234567890"
  }'

Response:

{
  "status": "success",
  "callId": "call_abc123",
  "roomName": "room_def456",
  "fromNumber": "+1987654321",
  "toNumber": "+1234567890",
  "agent": {
    "id": "agent_123abc",
    "name": "My First Agent",
    "model": "gpt-4",
    "voice": {
      "provider": "openai",
      "voiceId": "alloy"
    }
  }
}

Step 4: Check Call Status

You can monitor the status of your call:

curl https://api.trillet.ai/api/v1/calls/call_abc123 \
  -H "Authorization: Bearer YOUR_API_KEY"

Response:

{
  "id": "call_abc123",
  "status": "in_progress",
  "duration": 45,
  "startTime": "2024-01-20T12:02:00Z",
  "agentId": "agent_123abc",
  "flowId": "flow_xyz789",
  "toNumber": "+1234567890"
}

Next Steps

Now that you’ve made your first call, explore these resources: