Bridge
The Bridge verb is used to bridge another party (target call) onto the current call.
When the target call is bridged, any BXML being executed in it will be cancelled.
The bridge ends when one of the calls leaves the bridge. A call leaves the bridge when it is hung up or when it gets redirected to another BXML.
One of the Bridge Complete or Bridge Target Complete webhooks is sent when the bridge ends, to allow the call that remained in the bridge to execute new BXML. For example, if the call that executed the Bridge verb hangs up or is redirected first, the Bridge Target Complete webhook is sent and the BXML returned from that will be executed on the bridge target. In this case, the Bridge Complete webhook is NOT sent. Similarly, if the target of the Bridge verb hangs up or is redirected first, the Bridge Complete webhook is sent and the BXML returned from that will be executed on the call that executed the Bridge. In this case, the Bridge Target Complete webhook is not sent.
There are certain circumstances in which calls cannot be bridged, such as when the target call:
- is outbound and is still not answered
- is executing Forward
- is already hung up
In any of those cases a Bridge Complete event is sent with an error message.
Text Content
Name | Description |
---|---|
Target call | String containing the callId of the call to be bridged. |
Attributes
Attribute | Description |
---|---|
bridgeCompleteUrl | (optional) URL to send the Bridge Complete event to and request new BXML. If this attribute is specified, then Verbs following the <Bridge> verb will be ignored and the BXML returned in this webhook is executed on the call.If this attribute is not specified then no webhook will be sent, and execution of the verbs following the <Bridge> verb continues. May be a relative URL. |
bridgeCompleteMethod | (optional) The HTTP method to use for the request to bridgeCompleteUrl . GET or POST. Default value is POST. |
bridgeCompleteFallbackUrl | (optional) A fallback url which, if provided, will be used to retry the Bridge Complete webhook delivery in case bridgeCompleteUrl fails to respond. |
bridgeCompleteFallbackMethod | (optional) The HTTP method to use to deliver the Bridge Complete webhook to bridgeCompleteFallbackUrl . GET or POST. Default value is POST. |
bridgeTargetCompleteUrl | (optional) URL to send the Bridge Target Complete event to and request new BXML. If this attribute is specified, then the BXML returned in this webhook is executed on the target call. If this attribute is not specified then no webhook will be sent, and the target call will be hung up. May be a relative URL. |
bridgeTargetCompleteMethod | (optional) The HTTP method to use for the request to bridgeTargetCompleteUrl . GET or POST. Default value is POST. |
bridgeTargetCompleteFallbackUrl | (optional) A fallback url which, if provided, will be used to retry the Bridge Target Complete webhook delivery in case bridgeTargetCompleteUrl fails to respond. |
bridgeTargetCompleteFallbackMethod | (optional) The HTTP method to use to deliver the Bridge Target Complete webhook to bridgeTargetCompleteFallbackUrl . GET or POST. Default value is POST. |
username | (optional) The username to send in the HTTP request to bridgeCompleteUrl and to bridgeTargetCompleteUrl . |
password | (optional) The password to send in the HTTP request to bridgeCompleteUrl and to bridgeTargetCompleteUrl . |
fallbackUsername | (optional) The username to send in the HTTP request to bridgeCompleteFallbackUrl and to bridgeTargetCompleteFallbackUrl . |
fallbackPassword | (optional) The password to send in the HTTP request to bridgeCompleteFallbackUrl and to bridgeTargetCompleteFallbackUrl . |
tag | (optional) A custom string that will be sent with the bridgeComplete webhook and all future webhooks of the call unless overwritten by a future tag attribute or <Tag> verb, or cleared.May be cleared by setting tag="" Max length 256 characters. |
Webhooks Received
Webhooks | Can reply with more BXML |
---|---|
Bridge Complete | Yes |
Bridge Target Complete | Yes |
Examples
Bridge Two Calls
- XML
- Java
- C#
- Ruby
- NodeJS
- Python
- PHP
First call (c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d):
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<SpeakSentence>Wait until the second call answers.</SpeakSentence>
<Pause duration="60" />
</Response>
Second call:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<SpeakSentence>The bridge will start now.</SpeakSentence>
<Bridge bridgeCompleteUrl="https://bridge.url/nextBXMLForSecondCall" bridgeTargetCompleteUrl="https://bridge.url/nextBXMLForFirstCall">
c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d
</Bridge>
</Response>
First call (c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d):
SpeakSentence speakSentence = new SpeakSentence("Wait until the second call answers.");
Pause pause = new Pause(60d)
Response response = new Response()
.withVerbs(speakSentence, pause);
System.out.println(response.toBXML());
Second call:
SpeakSentence speakSentence = new SpeakSentence("The bridge will start now.");
Bridge bridge = new Bridge().builder()
.targetCallId("c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d")
.bridgeCompleteUrl("https://bridge.url/nextBXMLForSecondCall")
.bridgeTargetCompleteUrl("https://bridge.url/nextBXMLForFirstCall")
.build();
Response response = new Response()
.withVerbs(speakSentence, bridge);
System.out.println(response.toBXML());
First call (c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d):
SpeakSentence speakSentence = new SpeakSentence
{
Sentence = "Wait until the second call answers."
};
Pause pause = new Pause
{
Duration = 60
};
Response response = new Response();
response.Add(speakSentence);
response.Add(pause);
Console.WriteLine(response.ToBXML());
Second call:
SpeakSentence speakSentence = new SpeakSentence
{
Sentence = "The bridge will start now."
};
Bridge bridge = new Bridge
{
CallId = "c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d",
BridgeCompleteUrl = "https://bridge.url/nextBXMLForSecondCall",
BridgeTargetCompleteUrl = "https://bridge.url/nextBXMLForFirstCall"
};
Response response = new Response();
response.Add(speakSentence);
response.Add(bridge);
Console.WriteLine(response.ToBXML());
First call (c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d):
speak_sentence = Bandwidth::Bxml::SpeakSentence.new('Wait until the second call answers.')
pause = Bandwidth::Bxml::Pause.new({ duration: 60 })
response = Bandwidth::Bxml::Response.new([speak_sentence, pause])
p response.to_bxml
Second call:
speak_sentence = Bandwidth::Bxml::SpeakSentence.new('The bridge will start now.')
bridge = Bandwidth::Bxml::Bridge.new('c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d', {
bridge_complete_url: 'https://bridge.url/nextBXMLForSecondCall',
bridge_target_complete_url: 'https://bridge.url/nextBXMLForFirstCall'
})
response = Bandwidth::Bxml::Response.new([speak_sentence, bridge])
p response.to_bxml
First call (c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d):
const speakSentence = new Bxml.SpeakSentence(
'Wait until the second call answers.'
);
const pause = new Pause({ duration: 60 });
const response = new Response([speakSentence, pause]);
console.log(response.toBxml());
Second call:
const speakSentence = new Bxml.SpeakSentence('The bridge will start now.');
const bridge = new Bridge('c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d', {
bridgeCompleteUrl: 'https://bridge.url/nextBXMLForSecondCall',
bridgeTargetCompleteUrl: 'https://bridge.url/nextBXMLForFirstCall'
});
const response = new Response([speakSentence, bridge]);
console.log(response.toBxml());
First call (c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d):
speak_sentence = SpeakSentence(
text="Wait until the second call answers."
)
pause = Pause(
duration=60
)
response = Response()
response.add_verb(speak_sentence)
response.add_verb(pause)
print(response.to_bxml())
Second call:
speak_sentence = SpeakSentence(
text="The bridge will start now."
)
bridge = Bridge("c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d",
bridge_complete_url="https://bridge.url/nextBXMLForSecondCall",
bridge_target_complete_url="https://bridge.url/nextBXMLForFirstCall"
)
response = Response()
response.add_verb(speak_sentence)
response.add_verb(bridge)
print(response.to_bxml())
First call (c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d):
$speakSentence = new BandwidthLib\Voice\Bxml\SpeakSentence("Wait until the second call answers.");
$pause = new BandwidthLib\Voice\Bxml\Pause();
$pause->duration(60);
$response = new BandwidthLib\Voice\Bxml\Response();
$response->addVerb($speakSentence);
$response->addVerb($pause);
echo $response->toBxml();
Second call:
$speakSentence = new BandwidthLib\Voice\Bxml\SpeakSentence('The bridge will start now.');
$bridge = new BandwidthLib\Voice\Bxml\Bridge("c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d");
$bridge->bridgeCompleteUrl("https://bridge.url/nextBXMLForSecondCall");
$bridge->bridgeTargetCompleteUrl("https://bridge.url/nextBXMLForFirstCall");
$response = new BandwidthLib\Voice\Bxml\Response();
$response->addVerb($speakSentence);
$response->addVerb($bridge);
echo $response->toBxml();