Outbound call initialization and APIs

In order to make an outbound call, follow the below.

Perform authentication

The dialer application must be authenticated in order to trigger an outbound call.

To use the HTTP basic authentication method for outbound calling you should use the client secret as the password for the authentication.

The dialout request should include a header like the following (the value is built according to the username and the password):

Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=

For testing with the curl utility, the following command-line option can be used for sending the header:

-u "username:password"

The username is the account’s CLIENT_ID and the password is the CLIENT_SECRET.

Triggering the outbound call

The dialer application triggers Live Hub to make an outbound call, by sending an HTTP POST request to the /api/v1/actions/dialout endpoint.

Live Hub's REST API base URL is https://livehub.audiocodes.io/

An HTTP Authorization header must be included in the request, as explained in the previous section.

The HTTP POST body should contain a JSON object with the following properties:

Property

Type

Description

bot

String

The ID of the bot that should be connected to the outbound call.

target

String

URI of the target of the outbound call. For example: “tel:+123456789”.

Live Hub forwards this URI to the SBC and it is used for routing (i.e., as the DestURI).

The value of this parameter is also forwarded to the bot on the initial event in the outboundTarget field.

caller

String

User-part for the caller-id of the outbound call.

The phone number you purchased will be used as the caller-id.

callerHost

String

(Optional) Host-part for the caller-id of the outbound call. If omitted, it is filled with an arbitrary value.

callerDisplayName

String

(Optional) Display name for the caller-id of the outbound call.

notifyUrl

String

(Optional) Absolute URL of the dialer application to where Live Hub sends notifications. If the URL uses the HTTPS schema, TLS will be used for securing the connection.

If not provided, no notifications are sent.

See Receiving call status notifications below for more details.

metadata

JSON Object

(Optional) Data to be sent to the bot (can be used to provide information to the bot about the call, such as the name of the target).

If set, the initial event to the bot will include a dialoutMetadata field with the value specified. For more information, see Receiving dialoutInitiated event.

answerTimeoutSec

Number

(Optional) Number of seconds to wait for the end-user to answer.

If the specified time passes, the call it marked as failed, with reason of "no-answer".

The valid range is 1 to 300.

Default: 20 seconds

machineDetection

String

(Optional) Activates machine (answering machine and fax) detection.

Possible values:

  • "disabled" (default): Machine detection is disabled and the call is not disconnected if a machine is detected.

  • "disconnect": Machine detection is enabled and the call is disconnected if a machine is detected.

  • "detect": Machine detection is enabled. If a fax is detected, the call is disconnected. If an answering machine is detected, instead of disconnecting the call, Live Hub allows the bot to play a message to the answering machine.

See Machine detection below for more details.

voicemailEndTimeoutSec

Number

Defines a timeout (in seconds) that is activated upon detection of an answering machine (if machineDetection is set to "detect"). If no beep has been detected when the timeout expires, Live Hub sends the bot an event to notify that it can start playing its voice message to the answering machine.

The default is 20 seconds.

For example:

POST /api/v1/actions/dialout HTTP/1.1
Host: livehub.audiocodes.io
Content-Type: application/json;charset=UTF-8
Authorization: BEARER 223d0d870a364a4a

{
  "bot": "UUID",
  "target": "tel:+123456789",
  "caller": "1-800-111-111",
  "notifyUrl": "https://my-app.example.com/call/454/notify",
  "machineDetection": "detect", 
  "voicemailEndTimeoutSec": 20, 
  "metadata": {
    "participantName": "Alice"
  }
}

In case the triggering of the outbound call was successful, Live Hub will respond 200 OK with a JSON body with the following properties:

Property

Type

Description

conversationId

String

UUID of the newly created conversation.

For example:

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8


{
  "conversationId": "daf0c30f-e7a7-4644-b20b-667676b70615"
}

Receiving 200 OK response only means that the outbound call was triggered. It does not mean that it was actually performed. See Receiving call status notifications below for a way to get the outcome of the outbound call.

In case of error, one of the following response codes will be sent:

An example of error response:

HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8


{
  "error": "request should have required property 'bot'"
}

Receiving dialoutInitiated event

If the value "dialoutInitiated" is included in the sendEventsToBot bot configuration parameter, Live Hub will send the dialoutInitiated event to the bot when an outbound call is initiated (before it was answered).

This event can be used for receiving the call details on the bot in a early stage, so it will have them even in case the call has failed. It includes all the parameters that are sent with the initial event that is sent to the bot.

Receiving the metadata on the call initiation

When the user answers the call, the call-initiation event is sent to the bot.

This event contains the metadata that was sent by the dialer application.

The syntax of the initial event depends on the bot framework:

AudioCodes Bot API

The metadata is sent in the dialoutMetadata field inside parameters.

Example:

{
  "type": "event",
  "name": "start",
  "parameters": {
    "callee": "+123456789",
    "caller": "1-800-111-111",
    "dialoutMetadata": {
      "participantName": "Alice"
    }
  }
}
Microsoft Bot Framework

The metadata is sent in the dialoutMetadata field inside channelData.

Example:

{
  "type": "event",
  "name": "channel",
  "value": "telephony",
  "channelData": {
    "callee": "+123456789",
    "caller": "1-800-111-111",
    "dialoutMetadata": {
      "participantName": "Alice"
    }
  },
  "from": {
    "id": "12345678"
  },
  "locale": "en-US"
}
Dialogflow CX

The metadata is sent in the dialoutMetadata parameter of the WELCOME event.

Example:

{
  "queryInput": {
    "event": {
      "languageCode": "en-US",
      "name": "WELCOME",
      "parameters": {
        "callee": "+123456789",
        "caller": "1-800-111-111",
        "dialoutMetadata": {
          "participantName": "Alice"
        }
      }
    }
  }
}

The data fields are also sent inside the event-WELCOME session parameter, and can be used when generating the response text, by using a syntax such as this:

$session.params.event-WELCOME.dialoutMetadata.participantName
Dialogflow ES

The metadata is sent in the dialoutMetadata parameter of the WELCOME event.

Example:

{
  "queryInput": {
    "event": {
      "languageCode": "en-US",
      "name": "WELCOME",
      "parameters": {
        "callee": "+123456789",
        "caller": "1-800-111-111",
        "dialoutMetadata": {
          "participantName": "Alice"
        }
      }
    }
  }
}

The data fields can be used when generating the response text, by using a syntax such as this:

#WELCOME.dialoutMetadata.participantName

Receiving call status notifications

For receiving call-status notifications, you should set the notifyUrl property on the dialout request.

When this property is set, Live Hub sends an HTTP POST requests towards the specified URL. This request contains a JSON body with the following properties:

Property

Type

Description

conversationId

String

UUID of the conversation (matches the conversationId sent in the dialout trigger response).

status

String

Call status:

  • "answered": The call was answered

  • "completed": The call was completed (disconnected) after it was answered.

  • "failed": The call has ended before it was answered.

reasonCode

String

If the status is "failed", it provides the reason for the failure:

  • "no-answer": There was no answer to the call (due to expiry of answerTimeoutSec or due to a SIP timeout).

  • "busy": The target number was busy.

  • "declined": The end-user declined or rejected the call.

  • "error": An error occurred before the end-user answered the call (for example, the target number was invalid).

If the status is "completed", it provides the reason for the call end:

  • "error": The call was disconnected due to an unexpected error.

  • "bot-disconnected": The call was disconnected from the bot side.

  • "client-disconnected": The call was disconnected from the end-user side.

  • "transferred": The call to the bot was disconnected after it was transferred.

  • "machine-detected": The call was disconnected because an answering machine or a fax machine was detected.

reason

String

Free text describing the reason for the failure (for example, the SIP Reason header).

connectTime

String

The time at which the call was connected (when the end-user picked up the phone).

callDuration

Number

The duration of the call from connectTime to end of call in seconds.

sbcSessionID

String

The SBC session ID. This property is included in a completed notification.

botOperationResult

String

The value of the botOperationResult parameter that was set by the bot.

This property is included in a completed or failed notification, if the bot has set this parameter.

botOperationData

String

The value of the botOperationData parameter that was set by the bot.

This property is included in a completed or failed notification, if the bot has set this parameter.

For example:

POST /call/454/notify HTTP/1.1
Host: my-app.example.com
Content-Type: application/json;charset=UTF-8

{
  "conversationId": "daf0c30f-e7a7-4644-b20b-667676b70615",
  "status": "failed",
  "reasonCode": "busy",
  "reason": "SIP ;cause=486 ;text=\"Busy Here\""
}

The POST request is sent with no authorization header. It is recommended that the notifyUrl will include some unique identifier that will be used by the web server to authenticate the requests.

Disabling and enabling speech recognition upon call connect

By default, when an outbound (dialout) call is answered by the user, the user's initial words (e.g., "Hello" or an other welcome prompt) is not required and therefore, it is not sent to a speech-to-text provider. The start message sent by Live Hub to the bot does not include any speech recognition. This feature may save the provider unnecessary costs charged by the speech-to-text provider.

This feature can only be configured on the bot’s advanced parameters, using the following bot parameter:

Parameter

Type

Description

dialoutStartRecognitionOnConnect

Boolean

Indicates whether the bot expects the user welcome. This is not a dynamic parameter; it must be configured before the call is placed.

Possible values:

  • true: start recognition upon connect and send the bot the recognized sentence.

  • false: (default) do not perform recognition upon connect.

Note: If Barge-In is enabled, recognition will start regardless of the settings of this parameter.

Machine detection

You can configure Live Hub to detect if a human or machine (fax or answering) has answered the call. Live Hub can differentiate between fax and answering machine.

When enabled, Live Hub monitors the audio stream of the outbound call immediately after it has been answered, and can then do one of the following (depending on configuration) upon detection:

Playing bot message upon answering machine detection

If you want Live Hub to allow the bot to play a voice message when an answering machine is detected, set the machineDetection property to "detect" on the dialout request.

If the machineDetection property is set to "detect" and a fax machine is detected, Live Hubimmediately disconnects the call.

When configured and an answering machine is detected, instead of disconnecting the call, Live Hub does the following (in chronological order):

  1. Sends a machineDetection event to the bot to notify the bot that it has detected an answering machine:

    AudioCodes Bot API
    {
      "type": "event",
      "name": "machineDetection",
      "value": "voicemail-prompt-start"
    }
    Microsoft Bot Framework
    {
      "type": "event",
      "name": "machineDetection",
      "value": "voicemail-prompt-start"
    }
    Dialogflow CX
    {
      "queryInput": {
        "event": {
          "languageCode": "en-US",
          "name": "machineDetection",
          "parameters": {
            "value": "voicemail-prompt-start"
          }
        }
      }
    }
    
    Dialogflow ES
    {
      "queryInput": {
        "event": {
          "languageCode": "en-US",
          "name": "machineDetection",
          "parameters": {
            "value": "voicemail-prompt-start"
          }
        }
      }
    }
  2. Upon detection of the beep of the answering machine (or after a beep timeout set by the voicemailEndTimeoutSec property), it sends another event to the bot to notify the bot that it can start playing its message to the answering machine:

    AudioCodes Bot API
    {
      "type": "event",
      "name": "machineDetection",
      "value": "voicemail-prompt-end-beep"
    }
    Microsoft Bot Framework
    {
      "type": "event",
      "name": "machineDetection",
      "value": "voicemail-prompt-end-beep"
    }
    Dialogflow CX
    {
      "queryInput": {
        "event": {
          "languageCode": "en-US",
          "name": "machineDetection",
          "parameters": {
            "value": "voicemail-prompt-end-beep"
          }
        }
      }
    }
    Dialogflow ES
    {
      "queryInput": {
        "event": {
          "languageCode": "en-US",
          "name": "machineDetection",
          "parameters": {
            "value": "voicemail-prompt-end-beep"
          }
        }
      }
    }
To enable machine detection on the SBC, its License Key must include the DSP_IPM_AVILABLE_FEATURE license and the EnableDSPIPMDetectors parameter must be enabled. To enable the beep detection feature on the SBC, the AmdBeepDetectionMode parameter should be set to 1.

Disconnecting call upon machine detection

If you want Live Hub to disconnect the call upon machine (fax or answering) detection, set the machineDetection property to "disconnect" on the dialout request.

When a call is disconnected due to machine detection, the reasonCode of the disconnect is set to "machine-detected" and the reason is set to "voicemail detected" or "fax detected". The following is an example of a notification sent to the dialer application when fax is detected:

{ 
  "conversationId": "daf0c30f-e7a7-4644-b20b-667676b70615", 
  "status": "completed",
  "reasonCode": "machine-detected",
  "reason": "fax detected"
}
To enable machine detection on the SBC, its License Key must include the DSP_IPM_AVILABLE_FEATURE license and the EnableDSPIPMDetectors parameter must be enabled.