SAGEA LogoDocs & API
CookbooksMYLO Cookbooks

Build an Inbound IVR Menu

Map a phone number to a MYLO agent and route inbound callers with tool-driven menus.

  • Bind a phone number to an agent_id for inbound calls
  • Route billing, support, and hours intents with function tools
  • Fall back to a human agent when confidence is low Time to complete: ~25 minutes

Prerequisites

  • SAGEA_API_KEY exported in your shell as Bearer auth
  • Python 3.10+ with requests installed
  • A SAGEA phone number you can assign to an agent
  • Complete Send your first API request
  • Read the MYLO overview import from '@/components/Tabs';

Step 1: Map your phone number to an agent

Point your inbound number at the IVR agent so MYLO answers every call.

curl -X POST https://api.sagea.space/mylo/sessions \
  -H "Authorization: Bearer $SAGEA_API_KEY" -H "Content-Type: application/json" \
  -d '{"agent_id":"ivr_main","model":"sage-2-5-celer","voice":"atlas","language":"en-US","system_prompt":"You are an IVR receptionist. Offer billing, support, hours."}'

In production bind the number to ivr_main so inbound audio uses this session.

Step 2: Add menu routing tools

Give the agent tools for bookings, orders, and human transfer.

curl -X POST https://api.sagea.space/mylo/sessions \
  -H "Authorization: Bearer $SAGEA_API_KEY" -H "Content-Type: application/json" \
  -d '{"agent_id":"ivr_main","model":"sage-2-5-celer","voice":"atlas","language":"en-US","system_prompt":"Route callers. Use tools.","tools":[{"name":"check_booking"},{"name":"fetch_order_status"},{"name":"transfer_to_human"}]}'

Keep tool names short and spoken-friendly for reliable mid-call invocation.

Step 3: Add human fallback and close out

Transfer on request or low confidence, then fetch transcript and delete.

SESSION_ID="mylo_ses_REPLACE_ME"
curl https://api.sagea.space/mylo/sessions/$SESSION_ID/transcript \
  -H "Authorization: Bearer $SAGEA_API_KEY"
curl -X DELETE https://api.sagea.space/mylo/sessions/$SESSION_ID \
  -H "Authorization: Bearer $SAGEA_API_KEY"

Log every transfer_to_human call with reason so staffing matches demand.

Verify

ErrorCauseFix
401 UnauthorizedMissing or invalid API keyExport valid SAGEA_API_KEY and retry
404 session_not_foundSession expired before transferCreate fresh session, shorten test loop
429 rate_limit_exceededToo many test sessionsPace inbound tests, reuse session if possible
422 voice_not_foundBad voice on agent configUse nova or atlas, check settings

What's next

On this page