Opentact
  • Opentact Introduction
  • KEY CONCEPTS
    • Basic Concept
      • Voice Capability
        • Managing Inbound Calls
      • SMS Capability
      • Number Capability
    • Phone Number
      • Voice Enablement
      • SMS Enablement
      • TN Profile
        • Blacklist Caller ID
        • Whitelist Caller ID
    • SIP Control APP
      • Specify Remote Call Control URL
      • Specify Dialplan XML
    • SIP Trunking
    • Messaging
      • Quick Start Guide
      • Prepare Phone Numbers for SMS
    • SIP Connection
      • Associate SIP Connection with Phone Number
    • SIP Domain
      • Send Outbound Call with SIP Domain
      • Receive Inbound Call to SIP User
        • Web Call
        • Zoiper SIP Client
    • SIP Users
      • Create a SIPUser
      • Create a SIPUserInvite
    • Telecom Data
  • Opentact API Documentation
    • Opentact API Integration
      • API Environment
      • Opentact API keys
      • Passing Authentication
      • Authentication API
        • Example API Call
        • Authentiction with Gmail
    • TN Profile
      • Add and Remove Blacklist to TN Profile
        • Example API Call
      • Add and Remove Whitelist to TN Profile
        • Example API Call
    • Phone Number
      • Order Phone Number
        • Example API Usage
      • Release a Number
        • Example API Usage
      • Get all Purchased Numbers
      • Number Search
        • Example API Usage
    • SIP Connection
      • Remove Number from SIP Connection
      • Get Number for a SIP Connection
      • Update SIP Connections
      • Create SIP Conenctions
      • Delete SIP Connections
      • List SIP Connections
      • Assign Number to a SIP Connection
    • Messaging
      • Enable SMS on Numbers
      • Disable SMS on Number
      • Send SMS with Pool
      • Send SMS with Number
      • Receiving SMS
      • Retrieve Message Detail Records
      • Receiving Messaging Events
    • Log Retrieval
      • Retrieve Call Log
      • Retrieve SMS Log
    • Calling
      • Bridge two calls
      • Make Single Call
      • Make Bulk Call
        • Example API Call
    • SIP Domain
      • Create SIP Domain
      • Create SIP User
      • Deleting SIP User
      • Modify SIP User
    • Websocket Event Subscription
      • Create Subscription
      • Remove Subscription
      • Get Subscribed Events
        • Example API Call
  • Websocket Events
    • Event Websocket
    • Websocket Authentication
      • How to Authenticate to WSS
      • Authentication Response
      • Explanation of JSON response
    • Event Definition
      • Call Initiated
        • Example Event
      • Call Ringing
        • Example Event
      • Call Live
        • Example Event
      • Callflow
        • Example Event
      • Call Hangup
        • Example Event
      • Call Destroyed
        • Example Event
      • Call Bridged
        • Example Event
      • Call Answered
        • Example Event
      • Account events
        • Example Event
      • SMS events
        • Example Event
      • TN events
        • Example Event
      • Record Events
        • Example Event
      • Transcript
        • Example Event
      • General Event Fields
      • Example Event
  • Opentact XML
    • Overview
    • <Call/>
    • <Callback/>
    • <Geo/>
    • <Scheduler/>
    • <Play/>
    • <Say/>
    • <Hangup/>
    • <Pause/>
    • <Record/>
    • </Dial>
    • </Gather>
    • <Answer/>
    • <Hold/>
    • <Tone/>
    • <Error/>
    • <Default/>
    • <Meta/>
    • <Curl/>
  • How to build your Opentact Application
    • Introduction
    • Inbound Call Control
    • Opentact Events
    • Call Flow Control
      • Specify CallFlow for TN
        • Dynamic Call Flow XML
        • Basic Workflow
      • Handle Inbound Call
    • Send and Receive SMS
      • Life Cycle of SMS Delivery
      • Real-time SMS over Websocket
      • Send SMS via Restful API
    • Send and Receive SIP Calls
      • Create SIP User
      • Make Calls Between SIP User
      • Receive Calls as SIP User
  • Regulatory Compliance
    • 10DLC FAQs
    • Stir Shaken
  • SIP Trunking
    • Use Opentact for SIP Trunking
  • Webhook Event
    • Introduction
    • Test Webhook with Opentact
    • Event Definition
Powered by GitBook
On this page

Was this helpful?

  1. Opentact XML

</Gather>

<Gather> Tag Overview

The <Gather> tag in Opentact allows you to create Interactive Voice Response (IVR) systems, enabling you to interact with callers through voice prompts and gather responses using Dual-Tone Multi-Frequency (DTMF) codes. Here's an example of how to use <Gather> to create a multi-level IVR:


<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Say>Thank you for calling Opentact. Please hold.</Say>

    <Say>Now please enter a 1 to call the support team, 2 to call the tech team, or 0 to enter a private menu</Say>
    <Gather dtmf_length="1" dtmf_stop="#">

        <!-- SUPPORT TEAM -->
        <DTMF value="1">
            <Say>Switching the call to the support team</Say>
            <Dial>
                <To>support1@sip.opentact.org</To>
                <To>support2@sip.opentact.org</To>
                <To>support3@sip.opentact.org</To>
                <Error>
                    <Say>Sorry, our support team is busy right now, please call again later</Say>
                    <Hangup/>
                </Error>
            </Dial>
        </DTMF>

        <!-- TECH TEAM -->
        <DTMF value="2">
            <Say>Switching the call to the tech team</Say>
            <Dial>
                <To>12223334455</To>
                <To>12223334456</To>
                <To>12223334457</To>
                <Error>
                    <Say>Sorry, our tech team is busy right now, please call again later</Say>
                    <Hangup/>
                </Error>
            </Dial>
        </DTMF>

        <!-- PRIVATE MENU -->
        <DTMF value="0">
            <Say text="Now please enter a 4-digit code or # to stop entering a pin"/>
            <Gather length="4" dtmf_stop="#" url="http://private.domain.com/rest/private_menu?token=TOKEN">
                <!-- call URL will be transformed to: http://private.domain.com/rest/private_menu?token=TOKEN&dtmf=<DTMF>&from=<FROM>&tn=<TO>&state=live&sca=<SIP CONTROL APP UUID>&call=<CALL UUID> -->

                <!-- This block would be called if something goes wrong with a remote endpoint response -->
                <Error>
                    <Say>Oops, something is going wrong, please call again later</Say>
                    <Hangup/>
                </Error>
            </Gather>
        </DTMF>

        <!-- DEFAULT BEHAVIOR -->
        <Default>
            <Say>No DTMF code entered. Please call again</Say>
        </Default>

        <Error>
            <Say>Wrong input menu code entered. Please call again</Say>
        </Error>

    </Gather>

    <Say>Thank you for using our service, have a nice day!</Say>
    <Hangup />
</Response>

<Gather> Command Hints:

  • , and <Error> blocks are allowed to contain a child <Gather> command.

  • The length parameter specifies the number of DTMF codes to wait for.

  • The dtmf_stop parameter defines which DTMF code stops listening for additional codes.

  • Accepted values for dtmf_stop include: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, *, #, +.

  • Blocks start executing after entering the specified number of DTMF codes or receiving the dtmf_stop code.

Examples:

  1. Basic Usage with <DTMF>:

  • The example provides a simple use of <Gather> with a single <DTMF> block.

  • When the caller enters DTMF code "1," it responds with a "Hello world" message.

<Gather>
  <DTMF value="1">
    <Say text="Hello world"/>
  </DTMF>
</Gather>
  1. Gather with <Say> and <Play>:

  • This example combines <Say> and <Play> within <Gather> to create a dynamic interaction.

  • It prompts the caller to enter "1" for a man or "2" for a woman, playing background music.

  • Based on the entered DTMF code, it responds with a personalized greeting or an error message.

<Gather>
  <Say loop="3" text="Enter 1 for man, 2 for woman"/>
  <Play loop="10" url="http://google.com/music.mp3"/>

  <DTMF value="1">
    <Say text="Hello man"/>
  </DTMF>

  <DTMF value="2">
    <Say text="Hello woman"/>
  </DTMF>

  <Default>
    <Say>Wrong DTMF entered</Say>
  </Default>

  <Error>
    <Say>DTMF not found</Say>
  </Error>
</Gather>
  1. Gather with Dynamic Length and Stop on DTMF Code:

  • This example sets the dtmf_length to 10, expecting a 10-digit PIN.

  • The caller is asked to enter a PIN, and they can stop entering at any time by pressing "#."

  • If a PIN is entered, it welcomes the caller; otherwise, it prompts an error and hangs up.

<Gather dtmf_length="10" dtmf_stop="#">
  <Say text="Enter pin. To stop entering, enter #"/>
  <Default>
    <Say>Pin code entered, welcome</Say>
  </Default>
  <Error>
    <Say>Pin code not entered</Say>
    <Hangup/>
  </Error>
</Gather>
  1. Gather with Nested Options and External Endpoint:

  • The example presents a more complex menu with nested options for a support system.

  • Callers can enter "1" for tech support or "2" for payment support.

  • Depending on the chosen option, it further prompts the caller with specific choices.

  • It provides error messages if the selected support team is busy or if an incorrect code is entered.

<Gather dtmf_length="10" dtmf_stop="#">
  <Say text="Enter 1 for support team, 2 for HR department"/>
  <DTMF value="1">
    <Say text="Enter 1 for tech support, 2 for payment support"/>
    <Gather>
      <DTMF value="1">
        <Dial>
          <To to="support_tech1@company1.sip.opentact.org"/>
          <To to="support_tech2@company1.sip.opentact.org"/>
          <To to="support_tech3@company1.sip.opentact.org"/>
        </Dial>
      </DTMF>
      <DTMF value="2">
        <Dial>
          <To to="support_payment1@company1.sip.opentact.org"/>
          <To to="support_payment2@company1.sip.opentact.org"/>
          <To to="support_payment3@company1.sip.opentact.org"/>
        </Dial>
      </DTMF>
      <Error>
        <Say>All our support operators are busy, please call again later</Say>
        <Hangup/>
      </Error>
    </Gather>
  </DTMF>
  <DTMF value="2">
    <Dial to="hr@company1.sip.opentact.org">
      <Error>
        <Say>HR department is busy right now, please call again later</Say>
        <Hangup/>
      </Error>
    </Dial>
  </DTMF>
  <Error>
    <Say>Wrong DTMF code entered, please call again later</Say>
    <Hangup/>
  </Error>
</Gather>

Call External Endpoint with Entered DTMF Code:

If a URL is provided, all blocks except <Error> will be ignored. The <Gather> URL is updated with parameters such as dtmf, call, sca, state, from, tn.

  • This example introduces an external endpoint through the url attribute in <Gather>.

  • It instructs the caller to enter a 4-digit PIN, and the entered code is sent to an external endpoint.

  • If the PIN is successfully entered, it continues with a looped background music; otherwise, it prompts an error and hangs up.

<Say text="Enter pin. Entering enter # to stop entering the pin"/>
<Gather dtmf_length="4" dtmf_stop="#" url="http://domain.com/endpoint?token=TOKEN">
  <Play loop="10" url="https://google.com/media.mp3"/>
  <Error>
    <Say>Pin code not entered</Say>
    <Hangup/>
  </Error>
</Gather>

The <Gather> tag is a powerful tool for creating dynamic and interactive voice response systems in Opentact. It enables you to engage with callers, collect input through DTMF codes, and execute specific actions based on the received responses.

Previous</Dial>Next<Answer/>

Last updated 1 year ago

Was this helpful?