Making an Outgoing Call to Collect Response

In this section, you will be acquainted with how to start sending voice calls on a particular caller ID.

📘

For more information on how to create a Voice Application, which is necessary for this context, refer to the guide - Getting Started with Unifonic

To make an outbound call to collect a response

  1. Plan out your IVR Flow.
466
  1. Send a Voice Call via API.
curl --location --request POST 'https://voice.unifonic.com/v1/calls' \
--header 'AppsId: 'XXXXXXXXXXXXX'\
--header 'Content-Type: application/json' \
{
    "recipient":["+966111111111"],
    "type" : "ivr",
    "callerId" : "+966115219086",
    "ivr":
    {
        "language" : "english",
            "voice" : "male",
        "say":"Did you like our service? Press 1 to say yes. Press 2 to say yes.",
        "responseUrl":"https://myresponseurl.com/1",
        "speechCollectionLanguage":"english",
        "onEmptyResponse":"We did not receive your response. Good bye.",
        "loop":"3"
    }
}

📘

In this code sample, we will play a TTS recording of the content specified in the said parameter. and collect a response which will be sent to this responseUrl.
The responseUrl should be a POST API with no Authorization required. If the parameter speechCollectionLanguage is present, then it represents that you would like to collect a response via user speech. If this parameter is not present, then the response collection activity will be done by DTMF.

  1. POST/responseUrl
    Note that not every field in this code sample will be present. If your response collection activity is speech, there will be a confidence level and speechResult sent to the responseUrl. Otherwise, it will just be digits. Recipients and callerId will always be sent so that you are able to map a user response to a user.
{
“confidence”:0.6, //refers to accuracy of this speech recognition activity
“speechResult”:”one”,
“digits”: “1”,
“recipient”: “+966XXXXXXXXX”,
“callerId”: “+966XXXXXXXXX”
}
  1. Provide us with a response to this POST request
    A response is required as it tells us what is the next IVR instruction after you have analyzed the IVR response. It can be a simple thank you, which will then result in a call hang-up. Or, you can conduct another response collection activity by simply providing another responseUrl.
{
  "say":"thank you",
  "language":"english",
  "voice":"male"
}
  1. Host the APIs on your API Server and expose them to your Incoming voice application on the Unifonic Console.

Alternatively, you can skip past all of these and simply make use of the Unifonic Flow Studio to create a flow and be provided with a URL that you can use as the responseUrl in the payload.