Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Commit

Permalink
SWI-3646 Update Ruby BXML Guide Snippets (#1164)
Browse files Browse the repository at this point in the history
* SWI-3646 Update Ruby BXML Guide Snippets

* first few verbs

* more verbs

* more verbs

* last of the verbs

* update other examples on the verb pages i missed

* hopefully the last snippets

* run cypress tests
  • Loading branch information
ckoegel authored Oct 3, 2023
1 parent 7fad2d7 commit 3798698
Show file tree
Hide file tree
Showing 35 changed files with 671 additions and 936 deletions.
48 changes: 25 additions & 23 deletions site/docs/voice/bxml/about.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const Highlight = ({children, color}) => (

Bandwidth XML allows you to create a voice application as easily as you create a Web application. Using Bandwidth XML (or BXML) your application handles incoming call events using standard action verbs that are described in XML.

Before we begin creating a new BXML application youll need two things initially setup:
Before we begin creating a new BXML application you'll need two things initially setup:

1. A phone number that is allocated to your Bandwidth Application Platform account and is configured to an application. For instructions on setting up your application, read the [applications](/docs/account/applications/) page

Expand Down Expand Up @@ -59,28 +59,30 @@ If BXML execution ends without performing a webhook, there is an implicit `<Hang

| Verb | Description |
|:------------------------------------------------|:------------------------------------------------------------------------------------------------------|
| [`<Conference>`](/docs/voice/bxml/conference/) | The Conference verb is used to add a call to a conference. |
| [`<Bridge>`](/docs/voice/bxml/bridge/) | The Bridge verb is used to bridge two calls. |
| [`<Pause>`](/docs/voice/bxml/pause/) | The Pause verb is used to delay verb execution for a period of time. |
| [`<Forward>`](/docs/voice/bxml/forward/) | The Forward verb is used to forward an unanswered incoming call to another number. |
| [`<Transfer>`](/docs/voice/bxml/transfer/) | The Transfer verb is used to transfer the call to another number. |
| [`<Ring>`](/docs/voice/bxml/ring/) | The Ring verb is used to play ringing audio on a call. |
| [`<Hangup>`](/docs/voice/bxml/hangup/) | The Hangup verb is used to hang up or reject a call. |
| [`<Redirect>`](/docs/voice/bxml/redirect/) | The Redirect verb is used to redirect the current XML execution to another URL. |
| [`<PlayAudio>`](/docs/voice/bxml/playAudio/) | The PlayAudio verb is used to play an audio file in the call. |
| [`<SpeakSentence>`](/docs/voice/bxml/speakSentence/) | The SpeakSentence verb converts text into audible speech. |
| [`<Record>`](/docs/voice/bxml/record/) | The Record verb allows a segment of audio to be recorded during a call. |
| [`<StartRecording>`](/docs/voice/bxml/startRecording/) | The StartRecording verb allows a segment of a call to be recorded while other verbs are executing. |
| [`<PauseRecording>`](/docs/voice/bxml/pauseRecording/) | The PauseRecording verb is used to pause a recording previously started by a `<StartRecording>` verb. |
| [`<ResumeRecording>`](/docs/voice/bxml/resumeRecording/) | The ResumeRecording verb is used to resume a recording previously paused by a `<PauseRecording>` verb.|
| [`<StopRecording>`](/docs/voice/bxml/stopRecording/) | The StopRecording verb stops a recording that was previously started by a `<StartRecording>`. |
| [`<Gather>`](/docs/voice/bxml/gather/) | The Gather verb is used to collect DTMF digits. |
| [`<StartGather>`](/docs/voice/bxml/startGather/) | The StartGather verb is used to collect DTMF digits during the execution of other verbs. |
| [`<StopGather>`](/docs/voice/bxml/stopGather/) | The StopGather verb stops the DTMF collection initiated by `<StartGather>`. |
| [`<StartStream>`](/docs/voice/bxml/startStream/) | The StartStream verb allows a segment of a call to be streamed to an external destination. |
| [`<StopStream>`](/docs/voice/bxml/stopStream/) | The StopStream verb is used to stop a stream previously started by a `<StartStream>` verb. |
| [`<SendDtmf>`](/docs/voice/bxml/sendDtmf/) | The SendDtmf verb is used to play DTMF digits in the call. |
| [`<Tag>`](/docs/voice/bxml/tag/) | The Tag verb is used to set a new tag value without executing a webhook. |
| [`<Conference>`](/docs/voice/bxml/conference/) | The Conference verb is used to add a call to a conference. |
| [`<Bridge>`](/docs/voice/bxml/bridge/) | The Bridge verb is used to bridge two calls. |
| [`<Pause>`](/docs/voice/bxml/pause/) | The Pause verb is used to delay verb execution for a period of time. |
| [`<Forward>`](/docs/voice/bxml/forward/) | The Forward verb is used to forward an unanswered incoming call to another number. |
| [`<Transfer>`](/docs/voice/bxml/transfer/) | The Transfer verb is used to transfer the call to another number. |
| [`<Ring>`](/docs/voice/bxml/ring/) | The Ring verb is used to play ringing audio on a call. |
| [`<Hangup>`](/docs/voice/bxml/hangup/) | The Hangup verb is used to hang up or reject a call. |
| [`<Redirect>`](/docs/voice/bxml/redirect/) | The Redirect verb is used to redirect the current XML execution to another URL. |
| [`<PlayAudio>`](/docs/voice/bxml/playAudio/) | The PlayAudio verb is used to play an audio file in the call. |
| [`<SpeakSentence>`](/docs/voice/bxml/speakSentence/) | The SpeakSentence verb converts text into audible speech. |
| [`<Record>`](/docs/voice/bxml/record/) | The Record verb allows a segment of audio to be recorded during a call. |
| [`<StartRecording>`](/docs/voice/bxml/startRecording/) | The StartRecording verb allows a segment of a call to be recorded while other verbs are executing. |
| [`<PauseRecording>`](/docs/voice/bxml/pauseRecording/) | The PauseRecording verb is used to pause a recording previously started by a `<StartRecording>` verb. |
| [`<ResumeRecording>`](/docs/voice/bxml/resumeRecording/) | The ResumeRecording verb is used to resume a recording previously paused by a `<PauseRecording>` verb. |
| [`<StopRecording>`](/docs/voice/bxml/stopRecording/) | The StopRecording verb stops a recording that was previously started by a `<StartRecording>`. |
| [`<Gather>`](/docs/voice/bxml/gather/) | The Gather verb is used to collect DTMF digits. |
| [`<StartGather>`](/docs/voice/bxml/startGather/) | The StartGather verb is used to collect DTMF digits during the execution of other verbs. |
| [`<StopGather>`](/docs/voice/bxml/stopGather/) | The StopGather verb stops the DTMF collection initiated by `<StartGather>`. |
| [`<StartStream>`](/docs/voice/bxml/startStream/) | The StartStream verb allows a segment of a call to be streamed to an external destination. |
| [`<StopStream>`](/docs/voice/bxml/stopStream/) | The StopStream verb is used to stop a stream previously started by a `<StartStream>` verb. |
| [`<StartTranscription>`](/docs/voice/bxml/startTranscription/) | The StartTranscription verb allows a segment of a call to be transcribed during the execution of other verbs. |
| [`<StopTranscription>`](/docs/voice/bxml/stopTranscription/) | The StopTranscription verb is used to stop a transcription previously started by a `<StartTranscription>` verb. |
| [`<SendDtmf>`](/docs/voice/bxml/sendDtmf/) | The SendDtmf verb is used to play DTMF digits in the call. |
| [`<Tag>`](/docs/voice/bxml/tag/) | The Tag verb is used to set a new tag value without executing a webhook. |

### BXML Webhooks

Expand Down
35 changes: 10 additions & 25 deletions site/docs/voice/bxml/bridge.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -196,38 +196,23 @@ Console.WriteLine(response.ToBXML());

First call (c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d):
```ruby
speak_sentence = Bandwidth::Voice::SpeakSentence.new({
:sentence => "Wait until the second call answers."
})

pause = Bandwidth::Voice::Pause.new({
:duration => 60
})

response = Bandwidth::Voice::Response.new()
response.push(speak_sentence)
response.push(pause)
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])

puts response.to_bxml()
p response.to_bxml
```

Second call:
```ruby
speak_sentence = Bandwidth::Voice::SpeakSentence.new({
:sentence => "The bridge will start now."
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])

bridge = Bandwidth::Voice::Bridge.new({
:call_id => "c-c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d",
:bridge_complete_url => "https://bridge.url/nextBXMLForSecondCall",
:bridge_target_complete_url => "https://bridge.url/nextBXMLForFirstCall"
})

response = Bandwidth::Voice::Response.new()
response.push(speak_sentence)
response.push(bridge)

puts response.to_bxml()
p response.to_bxml
```

</TabItem>
Expand Down
36 changes: 10 additions & 26 deletions site/docs/voice/bxml/conference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,11 @@ Console.WriteLine(response.ToBXML());
<TabItem value="ruby">

```ruby
speak_sentence = Bandwidth::Voice::SpeakSentence.new({
:sentence => "You will be added to your conference now.",
:gender => "male"
})

conference = Bandwidth::Voice::Conference.new({
:conference_name => 'my-conference-name'
})
speak_sentence = Bandwidth::Bxml::SpeakSentence.new('You will be added to your conference now.', { gender: 'male' })
conference = Bandwidth::Bxml::Conference.new('my-conference-name')
response = Bandwidth::Bxml::Response.new([speak_sentence, conference])

response = Bandwidth::Voice::Response.new()
response.push(speak_sentence)
response.push(conference)

puts response.to_bxml()
p response.to_bxml
```

</TabItem>
Expand Down Expand Up @@ -292,22 +283,15 @@ response.Add(conference);
<TabItem value="ruby">

```ruby
speak_sentence = Bandwidth::Voice::SpeakSentence.new({
:sentence => "Welcome. You are going to coach 2 calls, please wait.",
:gender => "male"
speak_sentence = Bandwidth::Bxml::SpeakSentence.new('Welcome. You are going to coach 2 calls, please wait.', {
gender: 'male'
})
conference = Bandwidth::Voice::Conference.new({
:conference_name => 'my-conference-name',
:call_ids_to_coach => "c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d,c-2a913f94-6a486f3a-3cae-4034-bcc3-f0c9fa77ca2f",
#or
:call_ids_to_coach => ["c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d", "c-2a913f94-6a486f3a-3cae-4034-bcc3-f0c9fa77ca2f"]
conference = Bandwidth::Bxml::Conference.new('my-conference-name', {
call_ids_to_coach: ['c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d', 'c-2a913f94-6a486f3a-3cae-4034-bcc3-f0c9fa77ca2f']
})
response = Bandwidth::Bxml::Response.new([speak_sentence, conference])

response = Bandwidth::Voice::Response.new()
response.push(speak_sentence)
response.push(conference)

puts response.to_bxml()
p response.to_bxml
```

</TabItem>
Expand Down
12 changes: 5 additions & 7 deletions site/docs/voice/bxml/forward.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,13 @@ Console.WriteLine(response.ToBXML());
<TabItem value="ruby">

```ruby
forward = Bandwidth::Voice::Forward.new({
:to => "+10987654321",
:from => "+11234567890"
forward = Bandwidth::Bxml::Forward.new({
to: '+10987654321',
from: '+11234567890'
})
response = Bandwidth::Bxml::Response.new([forward])

response = Bandwidth::Voice::Response.new()
response.push(forward)

puts response.to_bxml()
p response.to_bxml
```

</TabItem>
Expand Down
72 changes: 22 additions & 50 deletions site/docs/voice/bxml/gather.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -143,22 +143,15 @@ Console.WriteLine(response.ToBXML());
<TabItem value="ruby">

```ruby
speak_sentence = Bandwidth::Voice::SpeakSentence.new({
:sentence => "Please press a digit.",
:voice => "kate"
speak_sentence = Bandwidth::Bxml::SpeakSentence.new('Please press a digit.', { voice: 'kate' })
gather = Bandwidth::Bxml::Gather.new([speak_sentence], {
gather_url: 'https://gather.url/nextBXML',
terminating_digits: '#',
first_digit_timeout: 10
})
response = Bandwidth::Bxml::Response.new([gather])

gather = Bandwidth::Voice::Gather.new({
:gather_url => "https://gather.url/nextBXML",
:terminating_digits => "#",
:first_digit_timeout => "10",
:speak_sentence => speak_sentence
})

response = Bandwidth::Voice::Response.new()
response.push(gather)

puts response.to_bxml()
p response.to_bxml
```

</TabItem>
Expand Down Expand Up @@ -300,21 +293,15 @@ Console.WriteLine(response.ToBXML());
<TabItem value="ruby">

```ruby
speak_sentence = Bandwidth::Voice::SpeakSentence.new({
:sentence => "I am going to keep asking you to press a digit."
})

gather = Bandwidth::Voice::Gather.new({
:gather_url => "https://gather.url/nextBXML",
:repeat_count => "5",
:max_digits => "1",
:speak_sentence => speak_sentence
speak_sentence = Bandwidth::Bxml::SpeakSentence.new('I am going to keep asking you to press a digit.')
gather = Bandwidth::Bxml::Gather.new([speak_sentence], {
gather_url: 'https://gather.url/nextBXML',
repeat_count: 5,
max_digits: 1
})
response = Bandwidth::Bxml::Response.new([gather])

response = Bandwidth::Voice::Response.new()
response.push(gather)

puts response.to_bxml()
p response.to_bxml
```

</TabItem>
Expand Down Expand Up @@ -477,31 +464,16 @@ Console.WriteLine(response.ToBXML());
<TabItem value="ruby">

```ruby
speak_sentence_1 = Bandwidth::Voice::SpeakSentence.new({
:sentence => "First Sentence."
})

play_audio_1 = Bandwidth::Voice::PlayAudio.new({
:url => "https://audio.url/audio1.wav"
speak_sentence_1 = Bandwidth::Bxml::SpeakSentence.new('First Sentence.')
play_audio_1 = Bandwidth::Bxml::PlayAudio.new('https://audio.url/audio1.wav')
play_audio_2 = Bandwidth::Bxml::PlayAudio.new('https://audio.url/audio2.mp3')
speak_sentence_2 = Bandwidth::Bxml::SpeakSentence.new('Second Sentence.')
gather = Bandwidth::Bxml::Gather.new([speak_sentence_1, play_audio_1, play_audio_2, speak_sentence_2], {
gather_url: 'https://gather.url/nextBXML'
})
response = Bandwidth::Bxml::Response.new([gather])

play_audio_2 = Bandwidth::Voice::PlayAudio.new({
:url => "https://audio.url/audio2.mp3"
})

speak_sentence_2 = Bandwidth::Voice::SpeakSentence.new({
:sentence => "Second Sentence."
})

gather = Bandwidth::Voice::Gather.new({
:gather_url => "https://gather.url/nextBXML",
:nested_verbs => [speak_sentence_1, play_audio_1, play_audio_2, speak_sentence_2]
})

response = Bandwidth::Voice::Response.new()
response.push(gather)

puts response.to_bxml()
p response.to_bxml
```

</TabItem>
Expand Down
8 changes: 3 additions & 5 deletions site/docs/voice/bxml/hangup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,10 @@ Console.WriteLine(response.ToBXML());
<TabItem value="ruby">

```ruby
hangup = Bandwidth::Voice::Hangup.new()
hangup = Bandwidth::Bxml::Hangup.new
response = Bandwidth::Bxml::Response.new([hangup])

response = Bandwidth::Voice::Response.new()
response.push(hangup)

puts response.to_bxml()
p response.to_bxml
```

</TabItem>
Expand Down
10 changes: 3 additions & 7 deletions site/docs/voice/bxml/pause.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,10 @@ Console.WriteLine(response.ToBXML());
<TabItem value="ruby">

```ruby
pause = Bandwidth::Voice::Pause.new({
:duration => 2
})
pause = Bandwidth::Bxml::Pause.new({ duration: 2 })
response = Bandwidth::Bxml::Response.new([pause])

response = Bandwidth::Voice::Response.new()
response.push(pause)

puts response.to_bxml()
p response.to_bxml
```

</TabItem>
Expand Down
Loading

0 comments on commit 3798698

Please sign in to comment.