Cebod Telecom
  • Introduction
  • Customer Onboarding
  • FAQs (Frequently Asked Questions)
  • Cebod Telecom Web Portal
    • Dashboard
    • Activities
      • Call records
      • Messages
      • Active calls
      • SMS records
      • Faxes
    • Phone System
      • Phone Numbers
      • IVR (Auto Receptionist)
      • Users (Extensions)
        • Dynamic Caller ID
      • Manage Devices
      • Manage Groups
      • Manage Conferences
      • Postcall Actions
      • Webhooks
      • Time Conditions
      • Call Blocking
      • Call Center
        • Active Calls
        • Agents
        • Queue
        • Agents to queue
        • Agents Status
        • Agent Statistics
    • Tools / Settings
      • Manage Phone Lines
      • Add 911 Address
      • SMS
      • International Calling
      • Outbound Rates
      • Manage Recordings
        • AI Text-to-Speech Feature
      • Global Settings
        • Daily Spent Control
      • Voicemail Greetings
      • CNAM
    • My Account
      • Profile
      • Change Password:
      • Add Balance
      • Payment History
      • Vouchers
      • Invoices
      • Auto Refill
      • Logout
  • How To's
    • Set up BLF
    • Register a New Account
    • Setup Call Forwarding
      • Call Forwarding to an Extension
      • Call Forwarding Manually to a Cell Phone
    • Dial-By-Name Directory
    • Voicemail
      • Setting up the Voicemail Menu
      • Accessing Voicemail
      • Navigate through the Voicemail Menu
    • Provisioning
      • Cisco 8841
    • Setup Speed Dial
    • Cebod Telecom Free Applications
      • MS Windows Desktop Softphone
      • Mac Desktop Softphone
      • Apple IOS Mobile App
      • Android Mobile App
      • Desktop SMS/MMS Application
      • Click to Call Browser Extension
    • GS Wave
    • Setting Up Whisper Announcement
  • Enable Call Recording
  • Features
    • Manage Phone Features
      • Call Block
      • Call transfer
      • Call Queue
      • Call Center
      • Active Call Features
      • Ring Groups
      • Call Forward
      • Call Recording
      • Call Park
      • Paging
      • Voicemail
      • Call Monitoring
      • Hide Caller ID
    • Missed Call SMS
    • Missed Call Email Notification
    • 3-Way Calling
    • Conference Bridge
    • Setting up Time Condition
    • Setup Email FAX - Incoming
    • Sending eFax using email
  • API
    • Voice API
    • Quick Start
      • Identify Caller
      • Collect Response
    • didML reference doc
      • Voice API reference params
      • Voice API response
      • didML Verbs
        • <dial>
          • <client>
          • <conference>
          • <number>
          • <queue>
          • <sip>
        • <enqueue>
        • <fax>
        • <gather>
        • <hangup>
        • <pause>
        • <play>
        • <postcall>
        • <record>
        • <recordcall>
        • <redirect>
        • <reject>
        • <say>
        • <sms>
Powered by GitBook
On this page

Was this helpful?

  1. API
  2. Quick Start

Collect Response

Collect users response to build the IVR, or transfer the call to right person based on users input.

Collect Response

In the previous example you were able to identify the caller and greet them by name. Now lets take it to next level. Our caller has been greeted by name and is now prompted by the system to make a choice from provided options.

Example:-

Hello Bob! Press 1 to speak with support Press 2 to record your message

<?php

       // contacts array will List everyone your contacts
            $contacts = array(    
              "9495797676"=>"John",
              "9495776878"=>"Lily",
              "3102168544"=>"Bob",
              "8587771234"=>"Wendy",
              "6058393817"=>"Amanda"
              );
        // if the caller is known, then greet them by name
        // otherwise, just identify them as another caller
        if(!$name = $contacts[$_REQUEST['From']])
                $name = "there";

        // now greet the caller
        header("content-type: text/xml");
        echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<Response>
        <Say>Hello <?php echo $name; ?>.</Say>
        <Gather numDigits="1" action="hello-world-handle-key.php" method="POST">
                <Say>
                        Press 1 To speak with Support.
                        Press 2 to record your message.
                        Press any other key to start over.
                </Say>
        </Gather>
</Response>

We start of by the code we wrote for “Identify caller by name”. We will add gather keyword to it. After greeting the caller, gather keyword is triggered and it prompts the caller to make a choice by pressing the assigned keys from their phone. In our example “1″ is to speak to Support and “2″ is to record the message. As soon as the user makes a choice by pressing either one of the keys we call:-

hello-world-handle-key.php

This files job is to handle and respond to the user input. We pass the key to post/get data with name “Digits” This will check what Digit the caller has pressed.

  • If they pressed 1, then we will forward the call to 19499300360 and disconnect the call.

  • If they pressed 2, then the Record API will ask them to record their Name and Message.

    • Once the recording if complete the Record API will call hello-world-handle-recording.php URL. This file will play back the message to the caller and hang up.

The example below will help you understand how we handle this in the code

<?php
 
        // Check the digit caller pressed 
        if($_REQUEST['Digits'] != '1' and $_REQUEST['Digits'] != '2') {
                header("Location: hello-world.php");
                die;
        }
 
        // If 1 connect to office.  
        // Let the person record some sound.
        header("content-type: text/xml");
        echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<Response>
<?php if ($_REQUEST['Digits'] == '1') { ?>
        <Dial>19499300360</Dial>
        <Say> Goodbye.</Say>
<?php } elseif ($_REQUEST['Digits'] == '2') { ?>
        <Say>Lets record your own sound and we will play it back.</Say>
        <Record maxLength="30" action="hello-world-handle-recording.php" />
<?php } ?>
</Response>

If the caller had Pressed 2 then the code above call’s :

hello-world-handle-recording.php

<?php
 
        // play the recorded message back to the caller.  
        header("content-type: text/xml");
        echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<Response>
        <Say>Your recorded message is being played back.</Say>
        <Play><?php echo $_REQUEST['RecordingUrl']; ?></Play>
        <say>This was a demo system, we are excited to see what you will build.</say>
        <Say>Goodbye.</Say>
</Response>

The output of this code is to Play the recorded message to the caller and hangup.

By following these steps:-

  1. We have successfully greeted the caller by name.

  2. Prompted them to indicated their choice by pressing either 1 or 2.

  3. Based on their choice the call was either connected to support or they were prompted to record a message.

  4. Recorded message is played back to the caller and the call is completed.

Key words used in the above code are: Say Reads the text and convert’s that to audio and play to the caller. Dial Connect the existing call to another party Gather Collect the digits pressed by the caller Play Play a mp3/wav audio file from the web server. Record Caller is given the option to record the message

PreviousIdentify CallerNextdidML reference doc

Last updated 6 years ago

Was this helpful?

If the caller did not press either 1 or 2, then we redirect to the URL .

hello-world.php