Outbound calling

In a typical bot deployment, VoiceAI Connect receives a phone call and connects it to your bot. The outbound calling feature allows a third-party dialer application to initiate a phone call towards a target number and connect this call to your bot. This setup is often used by companies for outbound dialing campaigns, whereby the dialer automatically initiates calls with potential customers. This feature is also termed "dialout".

The basic call flow for outbound calling is as follows:

  1. The outbound dialer application sends an HTTP request to VoiceAI Connect, triggering it to make an outbound call to the specified target URI.

  2. Optionally, VoiceAI Connect sends an event to the bot indicating the outbound call initiation, including the parameters of the call (e.g., the called number).

  3. VoiceAI Connect initiates the outbound call over SIP to the end user.

  4. When the end user answers the call, speech-to-text begins and the user’s first utterance (e.g., "Hi") is sent to the bot to trigger its logic (e.g., reply with "Hi there, we are calling from…"). In addition, VoiceAI Connect notifies the bot that the call has been answered, by sending it the call-initiation event.

  5. Optionally, VoiceAI Connect sends the dialer application asynchronous status notifications of the call ("answered", "failed" or "completed") using HTTP.

Additionally, VoiceAI Connect can be configured to detect if a human or machine (fax or answering) has answered the call.

The following diagram shows a high-level call-flow for outbound calling:

For Live Hub, please see Outbound Calling for details on how to enable this feature.

How do I use it?

To use the outbound calling feature, you should follow the following steps which are described In the following sections:

  1. Generate credentials (client id and client secret) that will be used for OAuth 2.0 authorization.

  2. Configure your bot for allowing outbound calling, by defining the application with the following policy:

    • Role: VAIC/BOTS/DIALOUT

    • Scope: You can define the scope for all bots (using *), for a specific bot (by name), or for multiple bots that have a specific authorization tag (tag=) configured using the authorizationTag parameter (below).

      For more information on assigning policies (roles and scopes) to users and applications, see Managing users.

  3. If using basic authentication, use the application's client ID and client secret as the username and password. If using OAuth 2.0, perform authentication for retrieving an OAuth 2.0 access token by issuing an HTTP POST to the /oauth/token URL.

  4. Trigger the outbound call by performing HTTP POST to the /api/v1/actions/dialout URL.

Optionally, VoiceAI Connect can send call-status notifications to your dialer application. For enabling such notifications, your dialer application should expose an HTTP server which is accessible to VoiceAI Connect installation.

For making outbound calls, your Administrator needs to provide you with the appropriate IAM policy (roles and scopes). For more information, see Managing users.

For Live Hub, after enabling the Outbound calling feature through the portal, you can skip the following 3 sections to the Triggering the outbound call section.

Generating credentials

The credentials consists of client id and client secret, which are required for authenticating your REST requests.

The following table explains how the credentials are generated:

Edition

Details

VoiceAI Connect Enterprise Contact AudioCodes professional services for generating the credentials.

Configuring your bot

When using VoiceAI Connect Enterprise, the following bot configuration parameters should be set to enable outbound calling:

Parameter Type Description
AuthorizationTag String

Defines a tag value that is used as the scope ('tag=') to identify the bot or group of bots when creating an authorization role (VAIC/BOTS/DIALOUT) for applications that will have privileges to send dialout requests for these bots, allowing the role to be limited to these bots.

Note: Regardless of the outbound dialing feature, tags can also be used for scopes to specify providers. In this case, the authorizationTag is configured under the providers section. This functionality is supported by VoiceAI Connect Enterprise from Version 3.16.063.

For more information on assigning policies (roles and scopes) to users and applications, see Managing users.

VoiceAI Connect Enterprise supports this parameter from Version 3.14.

dialoutAuthScope String

The OAuth 2.0 scope that is used to authenticated outbound calls using this bot.

Without setting a value for this parameter, outbound calling is disabled for the bot.

This parameter was deprecated in Version 3.14 and replaced by the authorizationTag parameter.

dialoutAllowedCallers

Array of strings

(Optional) An array of phone numbers (as strings) to be allowed in the caller property of the dialout request.

If not specified, any phone number is allowed.

If contains only one phone number, the caller property can be omitted from the request and the specified phone number will be used.

If contains more than one number, the caller property is validated against the specified phone numbers. If the validation fails, the dialout request is rejected.

VoiceAI Connect Enterprise supports this feature from Version 2.4 and later.

dialoutLimitPerSecond

Number

(Optional) Defines the maximum number of outbound dialing requests allowed per second, per bot.

If not configured or set to 0, there is no limit to the number of requests per second. The value can also be a fraction (e.g., a value of 0.1 means 1 request per 10 seconds).

If the limit is exceeded, VoiceAI Connect sends an HTTP 429 (Too Many Requests) response to the dialer application.

VoiceAI Connect Enterprise supports this parameter from Version 2.4 and later.
sendEventsToBot Array of strings

(Optional) If the value "dialoutInitiated" is included in the array, VoiceAI Connect sends the dialoutInitiated event to the bot when an outbound call is initiated (before it was answered).

This event can be used for passing the call details to the bot in a early stage, so it will have them even in case the call has failed.

dialoutMaxConcurrentCalls

number

Defines the maximum number of concurrent outbound calls per bot. If this maximum is reached, new calls from this bot are rejected with response code 429 “Too Many Requests”.

The valid range is 0 to 300.

The default is 0 (feature is disabled, i.e., unlimited concurrent calls).

VoiceAI Connect Enterprise supports this feature from Version 3.0 and later.

dialoutConcurrentCallsExpirationSeconds

number

Defines the timeout when a call is assumed to have ended, if no call-end event is received by VoiceAI Connect.

The valid range is 10 to 3600 seconds.

The default is 1200 seconds (20 minutes).

VoiceAI Connect Enterprise supports this feature from Version 3.0 and later.

Performing authentication

The dialer application must be authenticated in order to trigger an outbound call. The authentication can be done in one of the methods which can be enabled by the administrator: HTTP basic authentication or OAuth 2.0 authentication. See Client authentication for more details.

The following table explains how to use the authentication methods for outbound calling:

Authentication method Details
HTTP basic authentication

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"
OAuth 2.0

You should obtain an access token as explained in Client authentication.

The dialout request should include a header like the following, with the value of the access token:

Authorization: BEARER 223d0d870a364a4a

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

-H "Authorization: Bearer ACCESS_TOKEN"
The application's roles and scopes must allow dialout and configuration of the specific bot (see Managing users).

Triggering the outbound call

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

For Live Hub's REST API base URL, refer to the Live Hub REST API documentation.

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

Name of the bot that should be connected to the outbound call.

The name should match the name parameter of the bot.

target

String

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

VoiceAI Connect 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.

If dialoutAllowedCallers bot parameter (see above) is configured with only one value, this property can be omitted.

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 VoiceAI Connect 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

VoiceAI Connect Enterprise versions earlier than 2.4, there was no timeout by default.

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, VoiceAI Connect allows the bot to play a message to the answering machine.

See Machine detection below for more details.

VoiceAI Connect Enterprise supports this parameter from Version 2.4 and later ("detect" from Version 2.6 and later).

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, VoiceAI Connect sends the bot an event to notify that it can start playing its voice message to the answering machine.

The default is 20 seconds.

VoiceAI Connect Enterprise supports this parameter from Version 2.6 and later.

For example:

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

{
  "bot": "Bot1",
  "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, VoiceAI Connect 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, VoiceAI Connect 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.

See Receiving outbound call-initiated notification for more details.

Receiving the metadata on the call initiation

When the user answers the call, the call-initiation event is sent to the bot (see Call initiation).

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, VoiceAI Connect 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.

machineDetection

 

This property is included when answering machine detection is enabled (machineDetection is configured to "detect") and detected, and the call ended. It provides the detection reason:

  • "voicemail beep" (if beep was detected)

  • "voicemail timeout" (if beep was not detected and beep timeout expired)

VoiceAI Connect Enterprise is supported from Version 2.6 and later.

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).

VoiceAI Connect Enterprise supports this feature from Version 2.8 and later.

callDuration

Number

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

VoiceAI Connect Enterprise supports this feature from Version 2.8 and later.

sbcSessionID

String

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

VoiceAI Connect Enterprise supports this feature from Version 3.0 and later.

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.

VoiceAI Connect Enterprise supports this feature from Version 3.20 and later.

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.

VoiceAI Connect Enterprise supports this feature from Version 3.20 and later.

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 VoiceAI Connect to the bot does not include any speech recognition. This feature may save the provider unnecessary costs charged by the speech-to-text provider.

VoiceAI Connect Enterprise supports this feature from Version 2.8 and later.

This feature can only be configured only by the VoiceAI Connect Administrator, 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 VoiceAI Connect to detect if a human or machine (fax or answering) has answered the call. VoiceAI Connect can differentiate between fax and answering machine.

When enabled, VoiceAI Connect 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:

If the SBC doesn't support machine detection (due to its configuration), VoiceAI Connect rejects the outbound call request containing the request for machine detection.

VoiceAI Connect Enterprise supports the call rejection feature from Version 2.6 and later.

Playing bot message upon answering machine detection

If you want VoiceAI Connect 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, VoiceAI Connect immediately disconnects the call.

When configured and an answering machine is detected, instead of disconnecting the call, VoiceAI Connect 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.
VoiceAI Connect Enterprise supports this feature from Version 2.6 and later.

Disconnecting call upon machine detection

If you want VoiceAI Connect 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.
VoiceAI Connect Enterprise supports this feature from Version 2.4 and later.