Barge-in
Barge-in, also known as “allow interrupt” or “recognize during prompt”, is a telephony feature which allows callers to interrupt (barge in) during voice prompts issued by their interlocutor.
Barge-in options
To enable barge-in, call $dialer.bargeInResponse
from the appropriate state, passing the necessary barge-in settings into it.
If the client says something to the bot in the middle of its reply, the bot will be interrupted and will process the request in the context of the current state. The following example illustrates the basic usage:
state: Offer
a: We’ve got a special deal just for you!
a: Today and tomorrow only, all “Keep Calm” subscription plans are eligible for a 20% discount!
a: Are you interested?
script:
$dialer.bargeInResponse({
bargeIn: "phrase", // Barge-in mode in which the bot will finish its last reply before being interrupted
bargeInTrigger: "final", // Barge-in will be triggered after the final speech recognition result
noInterruptTime: 1000 // During 1 second after the bot starts its first reply, it cannot be interrupted
});
state: What || noContext = true
q: * [sorry] what *
script:
log($dialer.isBargeInInterrupted()); // => true
a: Today and tomorrow you can apply for a 20% discount on all “Keep Calm” subscription plans!
a: Ready to try it out?
If the client asks “What?” prematurely, the bot will interrupt mid-sentence and reply to the question.
The $dialer.isBargeInInterrupted
method tells whether barge-in took place.
Contextual barge-in
This contextual barge-in can be set up using parameters for a
and audio
reaction tags, separated from the tag body by the ||
separator.
The syntax can be observed in the following example.
state: Offer
a: We’ve got a special deal just for you! || bargeInTransition = /Offer/NotDone, bargeInLabel = firstReply
a: Today and tomorrow only, || bargeInTransition = /Offer/NotDone, bargeInLabel = secondReply
a: all “Keep Calm” subscription plans are eligible for a 20% discount! || ignoreBargeIn = true
a: Are you interested? || bargeInTransition = /Offer/Done, bargeInLabel = thirdReply
script:
$dialer.bargeInResponse({
bargeIn: "forced",
bargeInTrigger: "interim",
noInterruptTime: 0
});
go: /Offer/Done
state: NotDone
state: No
intent: /No
a: But I haven’t finished yet! This is truly a unique offer!
go!: /Offer
state: CatchAll
event: noMatch
event: speechNotRecognized
a: I’m sorry, I didn’t catch what you said. Please let me go on.
script:
log($dialer.getBargeInTransition()); // => "/Offer/NotDone"
go!: /Offer
state: Done
state: No
intent: /No
a: Right then, thanks for your time! Have a good day!
script:
$dialer.hangUp();
state: CatchAll || noContext = true
event: noMatch
event: speechNotRecognized
script:
if ($dialer.isBargeInInterrupted()) {
log($dialer.getBargeInLabel()); // => "thirdReply"
}
a: I don’t quite follow you. Are you ready to try out our offer?