Prompt

How do I build an IVR phone menu with a voice API?

Technology / API Platforms1 observationLast seen Oct 14, 2026

Latest observation

Oct 14, 2026OpenAI APIWeb search: off

To build an IVR phone menu with a voice API, you usually combine:

  1. A phone number
  2. A webhook/server
  3. Call control logic
  4. Speech or keypad input handling
  5. Routing to an agent, voicemail, or another menu

Basic IVR flow

Example menu:

  • “Press 1 for sales”
  • “Press 2 for support”
  • “Press 3 to leave a message”

The voice API connects the call to your webhook. Your server responds with call instructions such as:

  • play audio / text-to-speech
  • gather DTMF digits
  • listen for speech
  • transfer the call
  • record voicemail

Typical architecture

Caller → Phone number → Voice API → Your webhook → IVR response

Your webhook decides what happens next based on:

  • which menu level the caller is on
  • what digit they pressed
  • what they said
  • business hours, caller ID, language, etc.

Steps to build it

1. Buy or configure a phone number

In your voice provider dashboard:

  • purchase a number
  • enable voice
  • set the incoming call webhook URL

2. Create a webhook endpoint

This is usually a small HTTP server that returns instructions in the provider’s XML/JSON format.

You’ll need endpoints like:

  • /voice/incoming
  • /voice/menu
  • /voice/transfer
  • /voice/voicemail

3. Return a greeting and menu

For an incoming call, your webhook responds with something like:

  • “Thanks for calling Acme Corp.”
  • “Press 1 for sales.”
  • “Press 2 for support.”
  • “Press 3 to leave a voicemail.”

4. Collect input

Most voice APIs support either:

  • DTMF: keypad digits
  • Speech recognition: caller says “sales” or “support”

5. Route based on input

Your app maps the input to actions:

  • 1 → connect to sales queue
  • 2 → connect to support queue
  • 3 → record voicemail
  • invalid input → repeat menu or send to operator

6. Add error handling

Plan for:

  • no input
  • bad input
  • disconnected calls
  • busy agents
  • after-hours routing

Example IVR logic

Main menu

  • 1: Sales
  • 2: Support
  • 3: Billing
  • 0: Operator

Support submenu

  • 1: technical issue
  • 2: account issue
  • 3: password reset

After-hours

  • Record voicemail or send SMS with a callback link

Example pseudocode

def handle_incoming_call():
    say("Welcome to Acme.")
    gather_input(options=["1", "2", "3"])

def handle_menu_selection(digit):
    if digit == "1":
        connect_to("sales_queue")
    elif digit == "2":
        connect_to("support_queue")
    elif digit == "3":
        record_voicemail()
    else:
        say("Invalid option.")
        handle_incoming_call()

Example TwiML-style flow

If your voice API uses XML instructions, the idea looks like this:

<Response>
  <Say>Welcome to Acme. Press 1 for sales. Press 2 for support. Press 3 to leave a message.</Say>
  <Gather numDigits="1" action="/voice/menu" method="POST">
    <Say>Please enter your choice now.</Say>
  </Gather>
</Response>

Then your /voice/menu endpoint checks the digit and returns the next action.


Best practices

  • Keep menus short: 3–5 options max
  • Offer a way to reach a human
  • Support both keypad and speech if possible
  • Handle invalid input gracefully
  • Test with real phones
  • Log call events for debugging
  • Consider business hours and time zones
  • Make voicemail and callback options easy

Minimal implementation checklist

  • Voice API account
  • Phone number configured
  • Public webhook URL
  • Incoming call handler
  • Menu handler
  • Transfer/queue logic
  • Voicemail recording
  • Error handling and retries

If you want, I can also show you:

  1. a working example in Python/Flask,
  2. a Node.js example, or
  3. an example for a specific provider like Twilio, Vonage, Plivo, or Telnyx.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.