Unsuccessful call attempts
When developing a script, keep in mind that the bot might not always be able to reach the client. For example, the client might not respond, or a technical error might occur.
By default, such calls are included in telephony statistics but are not handled by the script.
Events for unsuccessful calls
JAICP provides two events that allow you to handle unsuccessful call attempts in your script:
-
onCallNotConnected
: the client does not answer or the line is busy. -
onCallNotConnectedTechnical
: the call failed due to a technical error. Examples:- Incorrect number.
- Connection problems.
- No available lines in the telephone channel.
Enable events
By default, the events are not available in the script.
To enable these events, list them in the chatbot.yaml
file:
additionalEvents:
- onCallNotConnected
- onCallNotConnectedTechnical
Example
Consider the following example in which the bot failed to reach the client.
state: OnCallNotConnected
# The state is triggered by either of two events
event: onCallNotConnected
event: onCallNotConnectedTechnical
script:
$dialer.setCallResult("Failed to reach the client. Reason: " + $dialer.getCallNotConnectedReason());
var now = new Date();
$dialer.redial({
startDateTime: new Date(now.getTime() + 60 * 60000), // Another call in an hour
maxAttempts: 2, // 2 call attempts in total
retryIntervalInMinutes: 5 // 5-minute pause between attempts
});
If the onCallNotConnected
or onCallNotConnectedTechnical
event is triggered:
- The
$dialer.getCallNotConnectedReason
method returns the reason for the failed call:BUSY
,NO_ANSWER
, orTECHNICAL_ERROR
. $dialer.setCallResult
writes the reason into call campaign and session reports. For example: Failed to reach the client. Reason: NO_ANSWER.- A redial is then scheduled for an hour later using the
$dialer.redial
method.