diff --git a/site/docs/voice/bxml/about.mdx b/site/docs/voice/bxml/about.mdx index 0c7802d35..d7e852fb8 100644 --- a/site/docs/voice/bxml/about.mdx +++ b/site/docs/voice/bxml/about.mdx @@ -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 you’ll 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 @@ -59,28 +59,30 @@ If BXML execution ends without performing a webhook, there is an implicit ``](/docs/voice/bxml/conference/) | The Conference verb is used to add a call to a conference. | -| [``](/docs/voice/bxml/bridge/) | The Bridge verb is used to bridge two calls. | -| [``](/docs/voice/bxml/pause/) | The Pause verb is used to delay verb execution for a period of time. | -| [``](/docs/voice/bxml/forward/) | The Forward verb is used to forward an unanswered incoming call to another number. | -| [``](/docs/voice/bxml/transfer/) | The Transfer verb is used to transfer the call to another number. | -| [``](/docs/voice/bxml/ring/) | The Ring verb is used to play ringing audio on a call. | -| [``](/docs/voice/bxml/hangup/) | The Hangup verb is used to hang up or reject a call. | -| [``](/docs/voice/bxml/redirect/) | The Redirect verb is used to redirect the current XML execution to another URL. | -| [``](/docs/voice/bxml/playAudio/) | The PlayAudio verb is used to play an audio file in the call. | -| [``](/docs/voice/bxml/speakSentence/) | The SpeakSentence verb converts text into audible speech. | -| [``](/docs/voice/bxml/record/) | The Record verb allows a segment of audio to be recorded during a call. | -| [``](/docs/voice/bxml/startRecording/) | The StartRecording verb allows a segment of a call to be recorded while other verbs are executing. | -| [``](/docs/voice/bxml/pauseRecording/) | The PauseRecording verb is used to pause a recording previously started by a `` verb. | -| [``](/docs/voice/bxml/resumeRecording/) | The ResumeRecording verb is used to resume a recording previously paused by a `` verb.| -| [``](/docs/voice/bxml/stopRecording/) | The StopRecording verb stops a recording that was previously started by a ``. | -| [``](/docs/voice/bxml/gather/) | The Gather verb is used to collect DTMF digits. | -| [``](/docs/voice/bxml/startGather/) | The StartGather verb is used to collect DTMF digits during the execution of other verbs. | -| [``](/docs/voice/bxml/stopGather/) | The StopGather verb stops the DTMF collection initiated by ``. | -| [``](/docs/voice/bxml/startStream/) | The StartStream verb allows a segment of a call to be streamed to an external destination. | -| [``](/docs/voice/bxml/stopStream/) | The StopStream verb is used to stop a stream previously started by a `` verb. | -| [``](/docs/voice/bxml/sendDtmf/) | The SendDtmf verb is used to play DTMF digits in the call. | -| [``](/docs/voice/bxml/tag/) | The Tag verb is used to set a new tag value without executing a webhook. | +| [``](/docs/voice/bxml/conference/) | The Conference verb is used to add a call to a conference. | +| [``](/docs/voice/bxml/bridge/) | The Bridge verb is used to bridge two calls. | +| [``](/docs/voice/bxml/pause/) | The Pause verb is used to delay verb execution for a period of time. | +| [``](/docs/voice/bxml/forward/) | The Forward verb is used to forward an unanswered incoming call to another number. | +| [``](/docs/voice/bxml/transfer/) | The Transfer verb is used to transfer the call to another number. | +| [``](/docs/voice/bxml/ring/) | The Ring verb is used to play ringing audio on a call. | +| [``](/docs/voice/bxml/hangup/) | The Hangup verb is used to hang up or reject a call. | +| [``](/docs/voice/bxml/redirect/) | The Redirect verb is used to redirect the current XML execution to another URL. | +| [``](/docs/voice/bxml/playAudio/) | The PlayAudio verb is used to play an audio file in the call. | +| [``](/docs/voice/bxml/speakSentence/) | The SpeakSentence verb converts text into audible speech. | +| [``](/docs/voice/bxml/record/) | The Record verb allows a segment of audio to be recorded during a call. | +| [``](/docs/voice/bxml/startRecording/) | The StartRecording verb allows a segment of a call to be recorded while other verbs are executing. | +| [``](/docs/voice/bxml/pauseRecording/) | The PauseRecording verb is used to pause a recording previously started by a `` verb. | +| [``](/docs/voice/bxml/resumeRecording/) | The ResumeRecording verb is used to resume a recording previously paused by a `` verb. | +| [``](/docs/voice/bxml/stopRecording/) | The StopRecording verb stops a recording that was previously started by a ``. | +| [``](/docs/voice/bxml/gather/) | The Gather verb is used to collect DTMF digits. | +| [``](/docs/voice/bxml/startGather/) | The StartGather verb is used to collect DTMF digits during the execution of other verbs. | +| [``](/docs/voice/bxml/stopGather/) | The StopGather verb stops the DTMF collection initiated by ``. | +| [``](/docs/voice/bxml/startStream/) | The StartStream verb allows a segment of a call to be streamed to an external destination. | +| [``](/docs/voice/bxml/stopStream/) | The StopStream verb is used to stop a stream previously started by a `` verb. | +| [``](/docs/voice/bxml/startTranscription/) | The StartTranscription verb allows a segment of a call to be transcribed during the execution of other verbs. | +| [``](/docs/voice/bxml/stopTranscription/) | The StopTranscription verb is used to stop a transcription previously started by a `` verb. | +| [``](/docs/voice/bxml/sendDtmf/) | The SendDtmf verb is used to play DTMF digits in the call. | +| [``](/docs/voice/bxml/tag/) | The Tag verb is used to set a new tag value without executing a webhook. | ### BXML Webhooks diff --git a/site/docs/voice/bxml/bridge.mdx b/site/docs/voice/bxml/bridge.mdx index 9723fe5e3..f727d199c 100644 --- a/site/docs/voice/bxml/bridge.mdx +++ b/site/docs/voice/bxml/bridge.mdx @@ -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 ``` diff --git a/site/docs/voice/bxml/conference.mdx b/site/docs/voice/bxml/conference.mdx index 338280344..f1692b434 100644 --- a/site/docs/voice/bxml/conference.mdx +++ b/site/docs/voice/bxml/conference.mdx @@ -147,20 +147,11 @@ Console.WriteLine(response.ToBXML()); ```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 ``` @@ -292,22 +283,15 @@ response.Add(conference); ```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 ``` diff --git a/site/docs/voice/bxml/forward.mdx b/site/docs/voice/bxml/forward.mdx index 2f0210777..c33436d99 100644 --- a/site/docs/voice/bxml/forward.mdx +++ b/site/docs/voice/bxml/forward.mdx @@ -97,15 +97,13 @@ Console.WriteLine(response.ToBXML()); ```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 ``` diff --git a/site/docs/voice/bxml/gather.mdx b/site/docs/voice/bxml/gather.mdx index cc7c9d8aa..a4782234f 100644 --- a/site/docs/voice/bxml/gather.mdx +++ b/site/docs/voice/bxml/gather.mdx @@ -143,22 +143,15 @@ Console.WriteLine(response.ToBXML()); ```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 ``` @@ -300,21 +293,15 @@ Console.WriteLine(response.ToBXML()); ```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 ``` @@ -477,31 +464,16 @@ Console.WriteLine(response.ToBXML()); ```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 ``` diff --git a/site/docs/voice/bxml/hangup.mdx b/site/docs/voice/bxml/hangup.mdx index 761cd359d..6527a959b 100644 --- a/site/docs/voice/bxml/hangup.mdx +++ b/site/docs/voice/bxml/hangup.mdx @@ -87,12 +87,10 @@ Console.WriteLine(response.ToBXML()); ```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 ``` diff --git a/site/docs/voice/bxml/pause.mdx b/site/docs/voice/bxml/pause.mdx index eda7e739c..d3ab3a1c6 100644 --- a/site/docs/voice/bxml/pause.mdx +++ b/site/docs/voice/bxml/pause.mdx @@ -91,14 +91,10 @@ Console.WriteLine(response.ToBXML()); ```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 ``` diff --git a/site/docs/voice/bxml/pauseRecording.mdx b/site/docs/voice/bxml/pauseRecording.mdx index f1eb17b66..28baa9d1c 100644 --- a/site/docs/voice/bxml/pauseRecording.mdx +++ b/site/docs/voice/bxml/pauseRecording.mdx @@ -89,12 +89,10 @@ Console.WriteLine(response.ToBXML()); ```ruby -pause_recording = Bandwidth::Voice::PauseRecording.new() +pause_recording = Bandwidth::Bxml::PauseRecording.new +response = Bandwidth::Bxml::Response.new([pause_recording]) -response = Bandwidth::Voice::Response.new() -response.push(pause_recording) - -puts response.to_bxml() +p response.to_bxml ``` @@ -342,74 +340,39 @@ Console.WriteLine(response.ToBXML()); ```ruby -speak_sentence_start = Bandwidth::Voice::SpeakSentence.new({ - :sentence => "This call is being recorded. Please wait while we transfer you.", - :voice => "bridget" -}) - -start_recording = Bandwidth::Voice::StartRecording.new({ - :recording_available_url => "https://myapp.com/noBXML" -}) - -phone_number = Bandwidth::Voice::PhoneNumber.new({ - :number => "+15554567892" +speak_sentence_start = Bandwidth::Bxml::SpeakSentence.new('This call is being recorded. Please wait while we transfer you.', { + voice: 'bridget' }) - -transfer = Bandwidth::Voice::Transfer.new({ - :phone_numbers => [phone_number] -}) - -pause_recording = Bandwidth::Voice::PauseRecording.new() - -speak_sentence_gather = Bandwidth::Voice::SpeakSentence.new({ - :sentence => "Press one if you want to be transferred to another number.", - :voice => "kate" +start_recording = Bandwidth::Bxml::StartRecording.new({ recording_available_url: 'https://myapp.com/noBXML' }) +phone_number = Bandwidth::Bxml::PhoneNumber.new('+15554567892') +transfer = Bandwidth::Bxml::Transfer.new([phone_number]) +pause_recording = Bandwidth::Bxml::PauseRecording.new +speak_sentence_gather = Bandwidth::Bxml::SpeakSentence.new('Press one if you want to be transferred to another number.', { + voice: 'kate' }) - -gather = Bandwidth::Voice::Gather.new({ - :gather_url => "https://myapp.com/gatherCallbackBxml", - :max_digits => 1, - :first_digit_timeout => 10, - :speak_sentence => speak_sentence_gather +gather = Bandwidth::Bxml::Gather.new([speak_sentence_gather], { + gather_url: 'https://myapp.com/gatherCallbackBxml', + max_digits: 1, + first_digit_timeout: 10 }) +response = Bandwidth::Bxml::Response.new([speak_sentence_start, start_recording, transfer, pause_recording, gather]) -response = Bandwidth::Voice::Response.new() -response.push(speak_sentence_start) -response.push(start_recording) -response.push(transfer) -response.push(pause_recording) -response.push(gather) - -puts response.to_bxml() +p response.to_bxml ``` > BXML Response to the Gather Webhook ```ruby -resume_recording = Bandwidth::Voice::ResumeRecording.new() - -phone_number = Bandwidth::Voice::PhoneNumber.new({ - :number => "+15554567893" -}) - -transfer = Bandwidth::Voice::Transfer.new({ - :phone_numbers => [phone_number] +resume_recording = Bandwidth::Bxml::ResumeRecording.new +phone_number = Bandwidth::Bxml::PhoneNumber.new('+15554567893') +transfer = Bandwidth::Bxml::Transfer.new([phone_number]) +stop_recording = Bandwidth::Bxml::StopRecording.new +speak_sentence_end = Bandwidth::Bxml::SpeakSentence.new('Thanks for your call. Have a nice day!', { + voice: 'bridget' }) +response = Bandwidth::Bxml::Response.new([resume_recording, transfer, stop_recording, speak_sentence_end]) -stop_recording = Bandwidth::Voice::StopRecording.new() - -speak_sentence_end = Bandwidth::Voice::SpeakSentence.new({ - :sentence => "Thanks for your call. Have a nice day!", - :voice => "bridget" -}) - -response = Bandwidth::Voice::Response.new() -response.push(resume_recording) -response.push(transfer) -response.push(stop_recording) -response.push(speak_sentence_end) - -puts response.to_bxml() +p response.to_bxml ``` diff --git a/site/docs/voice/bxml/playAudio.mdx b/site/docs/voice/bxml/playAudio.mdx index 924f52297..3a743ab58 100644 --- a/site/docs/voice/bxml/playAudio.mdx +++ b/site/docs/voice/bxml/playAudio.mdx @@ -130,19 +130,11 @@ Console.WriteLine(response.ToBXML()); ```ruby -play_audio_1 = Bandwidth::Voice::PlayAudio.new({ - :url => "https://audio.url/audio1.wav" -}) +play_audio_1 = Bandwidth::Bxml::PlayAudio.new('https://audio.url/audio1.wav') +play_audio_2 = Bandwidth::Bxml::PlayAudio.new('https://audio.url/audio2.mp3') +response = Bandwidth::Bxml::Response.new([play_audio_1, play_audio_2]) -play_audio_2 = Bandwidth::Voice::PlayAudio.new({ - :url => "https://audio.url/audio2.mp3" -}) - -response = Bandwidth::Voice::Response.new() -response.push(play_audio_1) -response.push(play_audio_2) - -puts response.to_bxml() +p response.to_bxml ``` diff --git a/site/docs/voice/bxml/record.mdx b/site/docs/voice/bxml/record.mdx index 4287f9379..6dc71c48e 100644 --- a/site/docs/voice/bxml/record.mdx +++ b/site/docs/voice/bxml/record.mdx @@ -163,27 +163,16 @@ Console.WriteLine(response.ToBXML()); ```ruby -speak_sentence = Bandwidth::Voice::SpeakSentence.new({ - :sentence => "Please leave your message after the beep.", - :voice => "bridget" +speak_sentence = Bandwidth::Bxml::SpeakSentence.new('Please leave your message after the beep.', { voice: 'bridget' }) +play_audio = Bandwidth::Bxml::PlayAudio.new('https://audio.url/beep.wav') +record = Bandwidth::Bxml::Record.new({ + record_complete_url: 'https://myapp.com/nextBXML', + recording_available_url: 'https://myapp.com/recordingAvailable', + max_duration: '10' }) +response = Bandwidth::Bxml::Response.new([speak_sentence, play_audio, record]) -play_audio = Bandwidth::Voice::PlayAudio.new({ - :url => "https://audio.url/beep.wav" -}) - -record = Bandwidth::Voice::Record.new({ - :record_complete_url => "https://myapp.com/nextBXML", - :recording_available_url => "https://myapp.com/recordingAvailable", - :max_duration => "10" -}) - -response = Bandwidth::Voice::Response.new() -response.push(speak_sentence) -response.push(play_audio) -response.push(record) - -puts response.to_bxml() +p response.to_bxml ``` @@ -336,21 +325,15 @@ Console.WriteLine(response.ToBXML()); ```ruby -speak_sentence = Bandwidth::Voice::SpeakSentence.new({ - :sentence => "Please say your name." -}) - -record = Bandwidth::Voice::Record.new({ - :record_complete_url => "https://record.url.server/record", - :transcribe => true, - :transcription_available_url => "https://transcription.url.server/transcribe/", +speak_sentence = Bandwidth::Bxml::SpeakSentence.new('Please say your name.') +record = Bandwidth::Bxml::Record.new({ + record_complete_url: 'https://record.url.server/record', + transcribe: true, + transcription_available_url: 'https://transcription.url.server/transcribe/' }) +response = Bandwidth::Bxml::Response.new([speak_sentence, record]) -response = Bandwidth::Voice::Response.new() -response.push(speak_sentence) -response.push(record) - -puts response.to_bxml() +p response.to_bxml ``` diff --git a/site/docs/voice/bxml/redirect.mdx b/site/docs/voice/bxml/redirect.mdx index 054844941..537b0de87 100644 --- a/site/docs/voice/bxml/redirect.mdx +++ b/site/docs/voice/bxml/redirect.mdx @@ -106,14 +106,10 @@ Console.WriteLine(response.ToBXML()); ```ruby -redirect = Bandwidth::Voice::Redirect.new({ - :redirect_url => "http://flow.url/newFlow" -}) +redirect = Bandwidth::Bxml::Redirect.new({ redirect_url: 'http://flow.url/newFlow' }) +response = Bandwidth::Bxml::Response.new([redirect]) -response = Bandwidth::Voice::Response.new() -response.push(redirect) - -puts response.to_bxml() +p response.to_bxml ``` diff --git a/site/docs/voice/bxml/resumeRecording.mdx b/site/docs/voice/bxml/resumeRecording.mdx index 14f532b19..a67dfe9de 100644 --- a/site/docs/voice/bxml/resumeRecording.mdx +++ b/site/docs/voice/bxml/resumeRecording.mdx @@ -92,12 +92,10 @@ Console.WriteLine(response.ToBXML()); ```ruby -resume_recording = Bandwidth::Voice::ResumeRecording.new() +resume_recording = Bandwidth::Bxml::ResumeRecording.new +response = Bandwidth::Bxml::Response.new([resume_recording]) -response = Bandwidth::Voice::Response.new() -response.push(resume_recording) - -puts response.to_bxml() +p response.to_bxml ``` diff --git a/site/docs/voice/bxml/ring.mdx b/site/docs/voice/bxml/ring.mdx index 4c24404d6..b76afcb8b 100644 --- a/site/docs/voice/bxml/ring.mdx +++ b/site/docs/voice/bxml/ring.mdx @@ -93,14 +93,13 @@ Console.WriteLine(response.ToBXML()); ```ruby -response = Bandwidth::Voice::Response.new() -ring = Bandwidth::Voice::Ring.new({ - :duration => 10, - :answer_call => false +ring = Bandwidth::Bxml::Ring.new({ + duration: 10, + answer_call: false }) +response = Bandwidth::Bxml::Response.new([ring]) -response.push(ring) -puts response.to_bxml() +p response.to_bxml ``` diff --git a/site/docs/voice/bxml/sendDtmf.mdx b/site/docs/voice/bxml/sendDtmf.mdx index 22266fe47..c3b7b49d1 100644 --- a/site/docs/voice/bxml/sendDtmf.mdx +++ b/site/docs/voice/bxml/sendDtmf.mdx @@ -99,14 +99,10 @@ Console.WriteLine(response.ToBXML()); ```ruby -send_dtmf = Bandwidth::Voice::SendDtmf.new({ - :dtmf => "12w34" -}) - -response = Bandwidth::Voice::Response.new() -response.push(send_dtmf) +send_dtmf = Bandwidth::Bxml::SendDtmf.new('12w34') +response = Bandwidth::Bxml::Response.new([send_dtmf]) -puts response.to_bxml() +p response.to_bxml ``` diff --git a/site/docs/voice/bxml/speakSentence.mdx b/site/docs/voice/bxml/speakSentence.mdx index c0235a374..df7d985d2 100644 --- a/site/docs/voice/bxml/speakSentence.mdx +++ b/site/docs/voice/bxml/speakSentence.mdx @@ -246,15 +246,10 @@ Console.WriteLine(response.ToBXML()); ```ruby -speak_sentence = Bandwidth::Voice::SpeakSentence.new({ - :sentence => "This is a test.", - :voice => "julie" -}) - -response = Bandwidth::Voice::Response.new() -response.push(speak_sentence) +speak_sentence = Bandwidth::Bxml::SpeakSentence.new('This is a test.', { voice: 'julie' }) +response = Bandwidth::Bxml::Response.new([speak_sentence]) -puts response.to_bxml() +p response.to_bxml ``` @@ -365,15 +360,12 @@ Console.WriteLine(response.ToBXML()); ```ruby -speak_sentence = Bandwidth::Voice::SpeakSentence.new({ - :sentence => 'Hello, you have reached the home of Antonio Mendoza. Please leave a message.', - :voice => "jorge" +speak_sentence = Bandwidth::Bxml::SpeakSentence.new('Hello, you have reached the home of Antonio Mendoza. Please leave a message.', { + voice: 'jorge' }) +response = Bandwidth::Bxml::Response.new([speak_sentence]) -response = Bandwidth::Voice::Response.new() -response.push(speak_sentence) - -puts response.to_bxml() +p response.to_bxml ``` diff --git a/site/docs/voice/bxml/startGather.mdx b/site/docs/voice/bxml/startGather.mdx index 68914eded..3dc0c8fa2 100644 --- a/site/docs/voice/bxml/startGather.mdx +++ b/site/docs/voice/bxml/startGather.mdx @@ -117,19 +117,11 @@ Console.WriteLine(response.ToBXML()); ```ruby -start_gather = Bandwidth::Voice::StartGather.new({ - :dtmf_url => "https://startgather.url/callback" -}) +start_gather = Bandwidth::Bxml::StartGather.new({ dtmf_url: 'https://startgather.url/callback' }) +conference = Bandwidth::Bxml::Conference.new('my-conference-name') +response = Bandwidth::Bxml::Response.new([start_gather, conference]) -conference = Bandwidth::Voice::Conference.new({ - :conference_name => "my-conference-name" -}) - -response = Bandwidth::Voice::Response.new() -response.push(start_gather) -response.push(conference) - -puts response.to_bxml() +p response.to_bxml ``` diff --git a/site/docs/voice/bxml/startRecording.mdx b/site/docs/voice/bxml/startRecording.mdx index 35ea3fab4..026fcbd50 100644 --- a/site/docs/voice/bxml/startRecording.mdx +++ b/site/docs/voice/bxml/startRecording.mdx @@ -185,38 +185,23 @@ Console.WriteLine(response.ToBXML()); ```ruby -speak_sentence_start = Bandwidth::Voice::SpeakSentence.new({ - :sentence => "This call is being recorded. Please wait while we transfer you.", - :voice => "bridget" +speak_sentence_start = Bandwidth::Bxml::SpeakSentence.new('This call is being recorded. Please wait while we transfer you.', { + voice: 'bridget' }) - -start_recording = Bandwidth::Voice::StartRecording.new({ - :recording_available_url => "https://myapp.com/noBXML" -}) - -phone_number = Bandwidth::Voice::PhoneNumber.new({ - :number => "+15554567892" -}) - -transfer = Bandwidth::Voice::Transfer.new({ - :phone_numbers => [phone_number] -}) - -stop_recording = Bandwidth::Voice::StopRecording.new() - -speak_sentence_end = Bandwidth::Voice::SpeakSentence.new({ - :sentence => "Thanks for your call. Have a nice day!", - :voice => "bridget" -}) - -response = Bandwidth::Voice::Response.new() -response.push(speak_sentence_start) -response.push(start_recording) -response.push(transfer) -response.push(stop_recording) -response.push(speak_sentence_end) - -puts response.to_bxml() +start_recording = Bandwidth::Bxml::StartRecording.new({ recording_available_url: 'https://myapp.com/noBXML' }) +phone_number = Bandwidth::Bxml::PhoneNumber.new('+15554567892') +transfer = Bandwidth::Bxml::Transfer.new([phone_number]) +stop_recording = Bandwidth::Bxml::StopRecording.new +speak_sentence_end = Bandwidth::Bxml::SpeakSentence.new('Thanks for your call. Have a nice day!', { voice: 'bridget' }) +response = Bandwidth::Bxml::Response.new([ + speak_sentence_start, + start_recording, + transfer, + stop_recording, + speak_sentence_end +]) + +p response.to_bxml ``` diff --git a/site/docs/voice/bxml/startStream.mdx b/site/docs/voice/bxml/startStream.mdx index d942fe7ed..a61856b28 100644 --- a/site/docs/voice/bxml/startStream.mdx +++ b/site/docs/voice/bxml/startStream.mdx @@ -207,35 +207,25 @@ Console.WriteLine(response.ToBXML()); ```ruby -speak_sentence_start = Bandwidth::Voice::SpeakSentence.new({ - :sentence => "This call is being streamed to a live studio audience.", - :voice => "bridget" +speak_sentence_start = Bandwidth::Bxml::SpeakSentence.new('This call is being streamed to a live studio audience.', { + voice: 'bridget' }) - -stream_param = Bandwidth::Voice::StreamParam.new({ - :name => "internal_id", - :value => "call_ABC" +stream_param = Bandwidth::Bxml::StreamParam.new({ + name: 'internal_id', + value: 'call_ABC' }) - -start_stream = Bandwidth::Voice::StartStream.new({ - :name => "live_audience", - :tracks => "both", - :destination => "wss://live-studio-audience.myapp.example.com", - :stream_events_url = "https://myapp.example.com/noBXML" - :stream_params => [stream_param] +start_stream = Bandwidth::Bxml::StartStream.new([stream_param], { + name: 'live_audience', + tracks: 'both', + destination: 'wss://live-studio-audience.myapp.example.com', + stream_events_url: 'ttps://myapp.example.com/noBXML' }) - -speak_sentence_end = Bandwidth::Voice::SpeakSentence.new({ - :sentence => "This will now be streamed to the destination as well as played to the call participants.", - :voice => "bridget" +speak_sentence_end = Bandwidth::Bxml::SpeakSentence.new('This will now be streamed to the destination as well as played to the call participants.', { + voice: 'bridget' }) +response = Bandwidth::Bxml::Response.new([speak_sentence_start, start_stream, speak_sentence_end]) -response = Bandwidth::Voice::Response.new() -response.push(speak_sentence_start) -response.push(start_stream) -response.push(speak_sentence_end) - -puts response.to_bxml() +p response.to_bxml ``` diff --git a/site/docs/voice/bxml/startTranscription.mdx b/site/docs/voice/bxml/startTranscription.mdx index 5a67bae39..bb6665201 100644 --- a/site/docs/voice/bxml/startTranscription.mdx +++ b/site/docs/voice/bxml/startTranscription.mdx @@ -116,6 +116,51 @@ If a `destination` is specified, it will be sent JSON messages for the duration ## Examples +### Transcribe an Active Call + + + +```xml + + + This call is being streamed to a live studio audience and transcribed. + + + + + +``` + + + + +```ruby +speak_sentence = Bandwidth::Bxml::SpeakSentence('This call is being streamed to a live studio audience and transcribed.', { + voice: 'bridget' +}) +custom_param_1 = Bandwidth::Bxml::CustomParam({name: 'custom_param_1', value: 'value_1' }) +custom_param_2 = Bandwidth::Bxml::CustomParam({name: 'custom_param_2', value: 'value_2' }) +start_transcription = Bandwidth::Bxml::StartTranscription([custom_param_1, custom_param_2], { + name: 'live_audience', + tracks: 'both', + destination: 'wss://live-studio-audience.myapp.example.com', + transcription_event_url: 'https://myapp.example.com/noBXML' +}) +response = Bandwidth::Bxml::Response.new([speak_sentence, start_transcription]) + +p response.to_bxml +``` + + + + ### A `start` Websocket Message ```json diff --git a/site/docs/voice/bxml/stopGather.mdx b/site/docs/voice/bxml/stopGather.mdx index 8d73bcab3..e66547400 100644 --- a/site/docs/voice/bxml/stopGather.mdx +++ b/site/docs/voice/bxml/stopGather.mdx @@ -134,32 +134,14 @@ Console.WriteLine(response.ToBXML()); ```ruby -start_gather = Bandwidth::Voice::StartGather.new({ - :dtmf_url => "https://startgather.url/callback" -}) - -phone_number = Bandwidth::Voice::PhoneNumber.new({ - :number => "+19195551234" -}) - -transfer = Bandwidth::Voice::Transfer.new({ - :phone_numbers => [phone_number] -}) - -stop_gather = Bandwidth::Voice::StopGather.new() - -speak_sentence = Bandwidth::Voice::SpeakSentence.new({ - :sentence => "Digits are no longer being gathered." -}) - -response = Bandwidth::Voice::Response.new() - -response.push(start_gather) -response.push(transfer) -response.push(stop_gather) -response.push(speak_sentence) - -puts response.to_bxml() +start_gather = Bandwidth::Bxml::StartGather.new({ dtmf_url: 'https://startgather.url/callback' }) +phone_number = Bandwidth::Bxml::PhoneNumber.new('+19195551234') +transfer = Bandwidth::Bxml::Transfer.new([phone_number]) +stop_gather = Bandwidth::Bxml::StopGather.new +speak_sentence = Bandwidth::Bxml::SpeakSentence.new('Digits are no longer being gathered.') +response = Bandwidth::Bxml::Response.new([start_gather, transfer, stop_gather, speak_sentence]) + +p response.to_bxml ``` diff --git a/site/docs/voice/bxml/stopRecording.mdx b/site/docs/voice/bxml/stopRecording.mdx index eb110e08c..fd428bbed 100644 --- a/site/docs/voice/bxml/stopRecording.mdx +++ b/site/docs/voice/bxml/stopRecording.mdx @@ -92,12 +92,10 @@ Console.WriteLine(response.ToBXML()); ```ruby -stop_recording = Bandwidth::Voice::StopRecording.new() +stop_recording = Bandwidth::Bxml::StopRecording.new +response = Bandwidth::Bxml::Response.new([stop_recording]) -response = Bandwidth::Voice::Response.new() -response.push(stop_recording) - -puts response.to_bxml() +p response.to_bxml ``` diff --git a/site/docs/voice/bxml/stopStream.mdx b/site/docs/voice/bxml/stopStream.mdx index 26118f565..5a4502804 100644 --- a/site/docs/voice/bxml/stopStream.mdx +++ b/site/docs/voice/bxml/stopStream.mdx @@ -95,14 +95,10 @@ Console.WriteLine(response.ToBXML()); ```ruby -stop_stream = Bandwidth::Voice::StopStream.new({ - :name => "live_audience", -}) +stop_stream = Bandwidth::Bxml::StopStream.new({ name: 'live_audience' }) +response = Bandwidth::Bxml::Response.new([stop_stream]) -response = Bandwidth::Voice::Response.new() -response.push(stop_stream) - -puts response.to_bxml() +p response.to_bxml ``` diff --git a/site/docs/voice/bxml/stopTranscription.mdx b/site/docs/voice/bxml/stopTranscription.mdx index 2ed74537e..08e4f8e4f 100644 --- a/site/docs/voice/bxml/stopTranscription.mdx +++ b/site/docs/voice/bxml/stopTranscription.mdx @@ -40,6 +40,37 @@ There is no text content available to be set for the `` verb. ## Examples +### Stop an Active Transcription + + + +```xml + + + + +``` + + + + +```ruby +stop_transcription = Bandwidth::Bxml::StopTranscription.new({ name: 'live_audience' }) +response = Bandwidth::Bxml::Response.new([stop_transcription]) + +p response.to_bxml +``` + + + + [1]: /docs/voice/bxml/startTranscription [2]: /docs/voice/webhooks/realTimeTranscriptionStarted [3]: /docs/voice/webhooks/realTimeTranscriptionStopped diff --git a/site/docs/voice/bxml/tag.mdx b/site/docs/voice/bxml/tag.mdx index 75c81cd67..3127b4bbe 100644 --- a/site/docs/voice/bxml/tag.mdx +++ b/site/docs/voice/bxml/tag.mdx @@ -118,25 +118,12 @@ Console.WriteLine(response.ToBXML()); ```ruby -tag1 = Bandwidth::Voice::Tag.new({ - :tag => "audio playing" -}) +tag_1 = Bandwidth::Bxml::Tag.new('audio playing') +play_audio = Bandwidth::Bxml::PlayAudio.new('https://audio.url/audio1.wav') +tag_2 = Bandwidth::Bxml::Tag.new('audio ended') +response = Bandwidth::Bxml::Response.new([tag_1, play_audio, tag_2]) -play_audio = Bandwidth::Voice::PlayAudio.new({ - :url => "https://audio.url/audio1.wav" -}) - -tag2 = Bandwidth::Voice::Tag.new({ - :tag => "audio ended" -}) - -response = Bandwidth::Voice::Response.new() - -response.push(tag1) -response.push(play_audio) -response.push(tag2) - -puts response.to_bxml() +p response.to_bxml ``` diff --git a/site/docs/voice/bxml/transfer.mdx b/site/docs/voice/bxml/transfer.mdx index e599b7c43..81ff6999e 100644 --- a/site/docs/voice/bxml/transfer.mdx +++ b/site/docs/voice/bxml/transfer.mdx @@ -184,19 +184,13 @@ Console.WriteLine(response.ToBXML()); ```ruby -phone_number = Bandwidth::Voice::PhoneNumber.new({ - :number => "+11234567892" +phone_number = Bandwidth::Bxml::PhoneNumber.new('+11234567892') +transfer = Bandwidth::Bxml::Transfer.new([phone_number], { + transfer_caller_id: '+11234567891' }) +response = Bandwidth::Bxml::Response.new([transfer]) -transfer = Bandwidth::Voice::Transfer.new({ - :transfer_caller_id => "+11234567891", - :phone_numbers => [phone_number] -}) - -response = Bandwidth::Voice::Response.new() -response.push(transfer) - -puts response.to_bxml() +p response.to_bxml ``` @@ -377,34 +371,23 @@ Console.WriteLine(response.ToBXML()); ```ruby -speak_sentence = Bandwidth::Voice::SpeakSentence.new({ - :sentence => "Transferring your call, please wait.", - :voice => "paul" +speak_sentence = Bandwidth::Bxml::SpeakSentence.new('Transferring your call, please wait.', { voice: 'paul' }) +phone_number = Bandwidth::Bxml::PhoneNumber.new('+11234567892', { + transfer_answer_url: 'http://myapp.com/announcement' }) - -phone_number = Bandwidth::Voice::PhoneNumber.new({ - :number => "+11234567892", - :transfer_answer_url => "http://myapp.com/announcement" -}) - -transfer = Bandwidth::Voice::Transfer.new({ - :transfer_caller_id => "+11234567891", - :phone_numbers => [phone_number] +transfer = Bandwidth::Bxml::Transfer.new([phone_number], { + transfer_caller_id: '+11234567891' }) +response = Bandwidth::Bxml::Response.new([speak_sentence, transfer]) -response = Bandwidth::Voice::Response.new() -response.push(speak_sentence) -response.push(transfer) - -puts response.to_bxml() +p response.to_bxml ``` > The announcement BXML response from `http://myapp.com/announcement` is: ```ruby -speak_sentence = Bandwidth::Voice::SpeakSentence.new({ - :sentence => "A customer would like to speak to you.", - :voice => "paul" +speak_sentence = Bandwidth::Bxml::SpeakSentence.new('A customer would like to speak to you.', { + voice: 'paul' }) ``` @@ -590,23 +573,14 @@ Console.WriteLine(response.ToBXML()); ```ruby -phone_number_1 = Bandwidth::Voice::PhoneNumber.new({ - :number => "+15552221234" -}) - -phone_number_2 = Bandwidth::Voice::PhoneNumber.new({ - :number => "+15552221233" +phone_number_1 = Bandwidth::Bxml::PhoneNumber.new('+15552221234') +phone_number_2 = Bandwidth::Bxml::PhoneNumber.new('+15552221233') +transfer = Bandwidth::Bxml::Transfer.new([phone_number_1, phone_number_2], { + transfer_caller_id: '+15552221235' }) +response = Bandwidth::Bxml::Response.new([transfer]) -transfer = Bandwidth::Voice::Transfer.new({ - :transfer_caller_id => "+15552221235", - :phone_numbers => [phone_number_1, phone_number_2] -}) - -response = Bandwidth::Voice::Response.new() -response.push(transfer) - -puts response.to_bxml() +p response.to_bxml ``` diff --git a/site/docs/voice/callInformationGuide.mdx b/site/docs/voice/callInformationGuide.mdx index 617adf82a..a77f498d2 100644 --- a/site/docs/voice/callInformationGuide.mdx +++ b/site/docs/voice/callInformationGuide.mdx @@ -170,30 +170,27 @@ class Program ```ruby -require 'bandwidth' +require 'bandwidth-sdk' -include Bandwidth -include Bandwidth::Voice - -bandwidth_client = Bandwidth::Client.new( - voice_basic_auth_user_name: ENV['BW_USERNAME'], - voice_basic_auth_password: ENV['BW_PASSWORD'] -) +Bandwidth.configure do |config| + config.username = ENV.fetch('BW_USERNAME') + config.password = ENV.fetch('BW_PASSWORD') +end -voice_client = bandwidth_client.voice_client.client +calls_api_instance = Bandwidth::CallsApi.new -body = CreateCallRequest.new -body.from = ENV['BW_NUMBER'] -body.to = ENV['USER_NUMBER'] -body.answer_url = ENV['BASE_CALLBACK_URL'] + "/callbacks/answer" -body.application_id = ENV['BW_VOICE_APPLICATION_ID'] -#remember to add auth for your application if needed! +call_body = Bandwidth::CreateCall.new( + application_id: ENV.fetch('BW_VOICE_APPLICATION_ID'), + to: ENV.fetch('USER_NUMBER'), + from: ENV.fetch('BW_NUMBER'), + answer_url: "#{ENV.fetch('BASE_CALLBACK_URL')}/callbacks/outboundCall", +) begin - result = voice_client.create_call(ENV['BW_ACCOUNT_ID'], body) - puts result.data.call_id -rescue APIException => e - puts e.response_code + result = calls_api_instance.create_call(ENV.fetch('BW_ACCOUNT_ID'), call_body) + p result.call_id +rescue Bandwidth::ApiError => e + p e.code end ``` @@ -419,25 +416,20 @@ class Program ```ruby -require 'bandwidth' +require 'bandwidth-sdk' -include Bandwidth -include Bandwidth::Voice - -bandwidth_client = Bandwidth::Client.new( - voice_basic_auth_user_name: ENV['BW_USERNAME'], - voice_basic_auth_password: ENV['BW_PASSWORD'] -) - -voice_client = bandwidth_client.voice_client.client +Bandwidth.configure do |config| + config.username = ENV.fetch('BW_USERNAME') + config.password = ENV.fetch('BW_PASSWORD') +end -callId = {CALL_ID} +calls_api_instance = Bandwidth::CallsApi.new begin - result = voice_client.get_call(ENV['BW_ACCOUNT_ID'], callId) - puts result.data.call_id -rescue APIException => e - puts e.response_code + result = calls_api_instance.get_call(ENV.fetch('BW_ACCOUNT_ID'), ENV.fetch('CALL_ID')) + p result.call_id +rescue Bandwidth::ApiError => e + p e.code end ``` diff --git a/site/docs/voice/conferenceGuide.mdx b/site/docs/voice/conferenceGuide.mdx index 992200470..8d4cf81b4 100644 --- a/site/docs/voice/conferenceGuide.mdx +++ b/site/docs/voice/conferenceGuide.mdx @@ -87,19 +87,11 @@ Console.WriteLine(response.ToBXML()); ```ruby -speak_sentence = Bandwidth::Voice::SpeakSentence.new({ - :sentence => "Joining the conference now.", -}) - -conference = Bandwidth::Voice::Conference.new({ - :conference_name => 'important-meeting' -}) - -response = Bandwidth::Voice::Response.new() -response.push(speak_sentence) -response.push(conference) +speak_sentence = Bandwidth::Bxml::SpeakSentence.new('Joining the conference now.') +conference = Bandwidth::Bxml::Conference.new('important-meeting') +response = Bandwidth::Bxml::Response.new([speak_sentence, conference]) -puts response.to_bxml() +p response.to_bxml ``` @@ -234,21 +226,13 @@ response.Add(conference); ```ruby -speak_sentence = Bandwidth::Voice::SpeakSentence.new({ - :sentence => "Welcome. You are going to coach 2 calls, please wait." +speak_sentence = Bandwidth::Bxml::SpeakSentence.new('Welcome. You are going to coach 2 calls, please wait') +conference = Bandwidth::Bxml::Conference.new('my-first-conference', { + call_ids_to_coach: ["c-example-callid-1", "c-example-callid-2"] }) -conference = Bandwidth::Voice::Conference.new({ - :conference_name => 'my-first-conference', - :call_ids_to_coach => "c-example-callid-1, c-example-callid-2", - #or - :call_ids_to_coach => ["c-example-callid-1", "c-example-callid-2"] -}) - -response = Bandwidth::Voice::Response.new() -response.push(speak_sentence) -response.push(conference) +response = Bandwidth::Bxml::Response.new([speak_sentence, conference]) -puts response.to_bxml() +p response.to_bxml ``` @@ -420,27 +404,21 @@ class Program -``` -require 'bandwidth' - -include Bandwidth -include Bandwidth::Voice - -bandwidth_client = Bandwidth::Client.new( - voice_basic_auth_user_name: {BW_USERNAME}, - voice_basic_auth_password: {BW_PASSWORD} -) +```ruby +require 'bandwidth-sdk' -voice_client = bandwidth_client.voice_client.client +Bandwidth.configure do |config| + config.username = ENV.fetch('BW_USERNAME') + config.password = ENV.fetch('BW_PASSWORD') +end -body = ModifyConferenceRequest.new -body.status = StatusEnum::COMPLETED -#remember to add auth for your application if needed! +conferences_api_instance = Bandwidth::ConferencesApi.new +body = Bandwidth::UpdateConference.new({ status: 'completed' }) begin - voice_client.modify_conference({ACCOUNT_ID}, {CONFERENCE_ID}, body) -rescue APIException => e - puts e.response_code + conferences_api_instance.update_conference(ENV.fetch('ACCOUNT_ID'), ENV.fetch('CONFERENCE_ID'), body) +rescue Bandwidth::ApiError => e + p e.code end ``` diff --git a/site/docs/voice/interactiveVoiceResponseGuide.mdx b/site/docs/voice/interactiveVoiceResponseGuide.mdx index c8dfc9cbd..d47da2aa7 100644 --- a/site/docs/voice/interactiveVoiceResponseGuide.mdx +++ b/site/docs/voice/interactiveVoiceResponseGuide.mdx @@ -160,34 +160,25 @@ public ActionResult digitsCallback() { **Note: The endpoint headers are pseudocoded. Your implementation will look different -``` -@POST '/gatherDigits' do: - speak_sentence = Bandwidth::Voice::SpeakSentence.new({ - :sentence => "Input a digit to hear it read back to you." - }) - - gather = Bandwidth::Voice::Gather.new({ - :gather_url => "/digitsCallback", - :max_digits => 1, - }) - - response = Bandwidth::Voice::Response.new() - response.push(speak_sentence) - response.push(gather) - - return response.to_bxml() - -@POST '/digitsCallback' do: - #NOTE: This section of the application may look different depending on how your endpoints receive callback events - - callback_data = JSON.parse(request.body.read) - speak_sentence = Bandwidth::Voice::SpeakSentence.new({ - :sentence => callback_data["digits"] - }) - response = Bandwidth::Voice::Response.new() - response.push(speak_sentence) - - return response.to_bxml() +```ruby +post '/gatherDigits' do + speak_sentence = Bandwidth::Bxml::SpeakSentence.new('Input a digit to hear it read back to you.') + gather = Bandwidth::Bxml::Gather.new([speak_sentence], { + gather_url: '/digitsCallback', + max_digits: 1, + }) + response = Bandwidth::Bxml::Response.new([gather]) + + return response.to_bxml +end + +post '/digitsCallback' do + data = JSON.parse(request.body.read) + speak_sentence = Bandwidth::Bxml::SpeakSentence.new(data['digits']) + response = Bandwidth::Bxml::Response.new([speak_sentence]) + + return response.to_bxml +end ``` @@ -453,39 +444,26 @@ public ActionResult gatherCallback() { **Note: This application is pseudocoded. Your implementation will look different ```ruby -post '/gatherDigits' do: - speak_sentence_1 = Bandwidth::Voice::SpeakSentence.new({ - :sentence => "Please listen to the menu of options." - }) - - play_audio_1 = Bandwidth::Voice::PlayAudio.new({ - :url => "http://audio.test/englishMenuOptions.mp3" - }) - - play_audio_2 = Bandwidth::Voice::PlayAudio.new({ - :url => "http://audio.test/spanishMenuOptions.mp3" - }) - - gather = Bandwidth::Voice::Gather.new({ - :gather_url => "/gatherCallback", - :repeat_count => 3, - :nested_verbs => [speak_sentence_1, play_audio_1, play_audio_2] - }) - - response = Bandwidth::Voice::Response.new() - response.push(gather) +post '/gatherDigits' do + speak_sentence_1 = Bandwidth::Bxml::SpeakSentence.new('Please listen to the menu of options.') + play_audio_1 = Bandwidth::Bxml::PlayAudio.new('http://audio.test/englishMenuOptions.mp3') + play_audio_2 = Bandwidth::Bxml::PlayAudio.new('http://audio.test/spanishMenuOptions.mp3') + gather = Bandwidth::Bxml::Gather.new([speak_sentence_1, play_audio_1, play_audio_2], { + gather_url: '/gatherCallback', + repeat_count: 3 + }) + response = Bandwidth::Bxml::Response.new([gather]) + + return response.to_bxml +end get '/gatherCallback' do: - #NOTE: This section of the application may look different depending on how your endpoints receive callback events + data = JSON.parse(request.body.read) + speak_sentence = Bandwidth::Bxml::SpeakSentence.new(data['digits']) + response = Bandwidth::Bxml::Response.new([speak_sentence]) - callback_data = JSON.parse(request.body.read) - speak_sentence = Bandwidth::Voice::SpeakSentence.new({ - :sentence => callback_data["digits"] - }) - response = Bandwidth::Voice::Response.new() - response.push(speak_sentence) - - return response.to_bxml() + return response.to_bxml +end ``` diff --git a/site/docs/voice/machineDetectionGuide.mdx b/site/docs/voice/machineDetectionGuide.mdx index 0fda48cc3..85aae7d7f 100644 --- a/site/docs/voice/machineDetectionGuide.mdx +++ b/site/docs/voice/machineDetectionGuide.mdx @@ -219,50 +219,47 @@ class Program ```ruby -require 'bandwidth' - -include Bandwidth -include Bandwidth::Voice +require 'bandwidth-sdk' begin - BW_USERNAME = ENV.fetch('BW_USERNAME') - BW_PASSWORD = ENV.fetch('BW_PASSWORD') - BW_ACCOUNT_ID = ENV.fetch('BW_ACCOUNT_ID') - BW_VOICE_APPLICATION_ID = ENV.fetch('BW_VOICE_APPLICATION_ID') - BW_NUMBER = ENV.fetch('BW_NUMBER') - USER_NUMBER = ENV.fetch('USER_NUMBER') - BASE_CALLBACK_URL = ENV.fetch('BASE_CALLBACK_URL') - + BW_USERNAME = ENV.fetch('BW_USERNAME') + BW_PASSWORD = ENV.fetch('BW_PASSWORD') + BW_ACCOUNT_ID = ENV.fetch('BW_ACCOUNT_ID') + BW_VOICE_APPLICATION_ID = ENV.fetch('BW_VOICE_APPLICATION_ID') + BW_NUMBER = ENV.fetch('BW_NUMBER') + USER_NUMBER = ENV.fetch('USER_NUMBER') + BASE_CALLBACK_URL = ENV.fetch('BASE_CALLBACK_URL') rescue - puts "Please set the environmental variables defined in the README" - exit(-1) + p 'Please set the environmental variables defined in the README' + exit(-1) end -bandwidth_client = Bandwidth::Client.new( - voice_basic_auth_user_name: {BW_USERNAME}, - voice_basic_auth_password: {BW_PASSWORD} -) +Bandwidth.configure do |config| + config.username = BW_USERNAME + config.password = BW_PASSWORD +end -voice_client = bandwidth_client.voice_client.client +calls_api_instance = Bandwidth::CallsApi.new -amd = MachineDetectionConfiguration.new -amd.mode = ModeEnum::ASYNC -amd.callback_url = "http://example.com/machineDetectionCallback" -amd.callback_method = AnswerMethodEnum::POST +amd_config = Bandwidth::MachineDetectionConfiguration.new( + mode: Bandwidth::MachineDetectionModeEnum::ASYNC, + callback_url: BASE_CALLBACK_URL + '/machineDetection', + callback_method: Bandwidth::CallbackMethodEnum::POST +) -body = CreateCallRequest.new -body.from = BW_NUMBER -body.to = USER_NUMBER -body.answer_url = BASE_CALLBACK_URL + "/answer" -body.application_id = BW_VOICE_APPLICATION_ID -body.machine_detection = amd -#remember to add auth for your application if needed! +call_body = Bandwidth::CreateCall.new( + application_id: BW_VOICE_APPLICATION_ID, + to: USER_NUMBER, + from: BW_NUMBER, + answer_url: BASE_CALLBACK_URL + '/answer', + machine_detection: amd_config +) begin - result = voice_client.create_call(ENV['BW_ACCOUNT_ID'], body) - puts result.data.call_id -rescue APIException => e - puts e.response_code + result = calls_api_instance.create_call(BW_ACCOUNT_ID, call_body) + p result.call_id +rescue Bandwidth::ApiError => e + p e.code end ``` @@ -616,53 +613,51 @@ class Program ```ruby -require 'bandwidth' - -include Bandwidth -include Bandwidth::Voice +require 'bandwidth-sdk' begin - BW_USERNAME = ENV.fetch('BW_USERNAME') - BW_PASSWORD = ENV.fetch('BW_PASSWORD') - BW_ACCOUNT_ID = ENV.fetch('BW_ACCOUNT_ID') - BW_VOICE_APPLICATION_ID = ENV.fetch('BW_VOICE_APPLICATION_ID') - BW_NUMBER = ENV.fetch('BW_NUMBER') - USER_NUMBER = ENV.fetch('USER_NUMBER') - BASE_CALLBACK_URL = ENV.fetch('BASE_CALLBACK_URL') - + BW_USERNAME = ENV.fetch('BW_USERNAME') + BW_PASSWORD = ENV.fetch('BW_PASSWORD') + BW_ACCOUNT_ID = ENV.fetch('BW_ACCOUNT_ID') + BW_VOICE_APPLICATION_ID = ENV.fetch('BW_VOICE_APPLICATION_ID') + BW_NUMBER = ENV.fetch('BW_NUMBER') + USER_NUMBER = ENV.fetch('USER_NUMBER') + BASE_CALLBACK_URL = ENV.fetch('BASE_CALLBACK_URL') rescue - puts "Please set the environmental variables defined in the README" - exit(-1) + p 'Please set the environmental variables defined in the README' + exit(-1) end -bandwidth_client = Bandwidth::Client.new( - voice_basic_auth_user_name: {BW_USERNAME}, - voice_basic_auth_password: {BW_PASSWORD} -) +Bandwidth.configure do |config| + config.username = BW_USERNAME + config.password = BW_PASSWORD +end -voice_client = bandwidth_client.voice_client.client +calls_api_instance = Bandwidth::CallsApi.new -amd = MachineDetectionConfiguration.new -amd.mode = ModeEnum::SYNC -amd.callback_method = AnswerMethodEnum::POST -amd.detection_timeout = 15.0 -amd.silence_timeout = 5.0 -amd.speech_threshold = 5.0 -amd.speech_end_threshold = 1.0 +amd_config = Bandwidth::MachineDetectionConfiguration.new( + mode: Bandwidth::MachineDetectionModeEnum::SYNC, + detection_timeout: 15.0, + silence_timeout: 5.0, + speech_threshold: 5.0, + speech_end_threshold: 1.0, + callback_url: BASE_CALLBACK_URL + '/machineDetection', + callback_method: Bandwidth::CallbackMethodEnum::POST +) -body = CreateCallRequest.new -body.from = BW_NUMBER -body.to = USER_NUMBER -body.answer_url = BASE_CALLBACK_URL + "/answer" -body.application_id = BW_VOICE_APPLICATION_ID -body.machine_detection = amd -#remember to add auth for your application if needed! +call_body = Bandwidth::CreateCall.new( + application_id: BW_VOICE_APPLICATION_ID, + to: USER_NUMBER, + from: BW_NUMBER, + answer_url: BASE_CALLBACK_URL + '/answer', + machine_detection: amd_config +) begin - result = voice_client.create_call(ENV['BW_ACCOUNT_ID'], body) - puts result.data.call_id -rescue APIException => e - puts e.response_code + result = calls_api_instance.create_call(BW_ACCOUNT_ID, call_body) + p result.call_id +rescue Bandwidth::ApiError => e + p e.code end ``` diff --git a/site/docs/voice/mediaAndTTSGuide.mdx b/site/docs/voice/mediaAndTTSGuide.mdx index 5b3495c37..45a10ac57 100644 --- a/site/docs/voice/mediaAndTTSGuide.mdx +++ b/site/docs/voice/mediaAndTTSGuide.mdx @@ -106,23 +106,16 @@ The second instance of PlayAudio (a relative endpoint) assumes there is an endpo **Note: This application is pseudocoded. Your implementation will look different ```ruby -post '/playAudio' do: - play_audio_1 = Bandwidth::Voice::PlayAudio.new({ - :url => "https://audio.url/audio1.wav" - }) +post '/playAudio' do + play_audio_1 = Bandwidth::Bxml::PlayAudio.new('https://audio.url/audio1.wav') + play_audio_2 = Bandwidth::Bxml::PlayAudio.new('/relative_audio') + response = Bandwidth::Bxml::Response.new([play_audio_1, play_audio_2]) - play_audio_2 = Bandwidth::Voice::PlayAudio.new({ - :url => "/relative_audio" - }) - - response = Bandwidth::Voice::Response.new() - response.push(play_audio_1) - response.push(play_audio_2) - - return response.to_bxml() + return response.to_bxml +end get '/relative_audio' do: - ...retrieve and return audio file... + # ...retrieve and return audio file... ``` The second instance of PlayAudio (a relative endpoint) assumes there is an endpoint in the application that serves an audio file. To see an example, look [here](https://github.com/Bandwidth-Samples/voice-record-java/blob/main/src/main/java/com/bandwidth/controller/FilesController.java). @@ -296,16 +289,14 @@ public ActionResult speakSentence() { **Note: The endpoint headers are pseudocoded. Your implementation will look different ``` -@POST '/tts' do: - speak_sentence = Bandwidth::Voice::SpeakSentence.new({ - :sentence => 'Hello Sherlock Holmes. You have an appointment on 11/12/2022.', - :voice => "bridget" - }) - - response = Bandwidth::Voice::Response.new() - response.push(speak_sentence) - - return response.to_bxml() +post '/tts' do + speak_sentence = Bandwidth::Bxml::SpeakSentence.new('Hello Sherlock Holmes. You have an appointment on 11/12/2022.', { + voice: 'bridget' + }) + response = Bandwidth::Bxml::Response.new([speak_sentence]) + + return response.to_bxml +end ``` diff --git a/site/docs/voice/migrationGuide.mdx b/site/docs/voice/migrationGuide.mdx index 405e1e4f6..f31c81987 100644 --- a/site/docs/voice/migrationGuide.mdx +++ b/site/docs/voice/migrationGuide.mdx @@ -391,30 +391,27 @@ class Program ```ruby -require 'bandwidth' +require 'bandwidth-sdk' -include Bandwidth -include Bandwidth::Voice - -bandwidth_client = Bandwidth::Client.new( - voice_basic_auth_user_name: ENV['BW_USERNAME'], - voice_basic_auth_password: ENV['BW_PASSWORD'] -) +Bandwidth.configure do |config| + config.username = ENV.fetch('BW_USERNAME') + config.password = ENV.fetch('BW_PASSWORD') +end -voice_client = bandwidth_client.voice_client.client +calls_api_instance = Bandwidth::CallsApi.new -body = CreateCallRequest.new -body.from = ENV['BW_NUMBER'] -body.to = ENV['USER_NUMBER'] -body.answer_url = ENV['BASE_CALLBACK_URL'] + "/callbacks/answer" -body.application_id = ENV['BW_VOICE_APPLICATION_ID'] -#remember to add auth for your application if needed! +call_body = Bandwidth::CreateCall.new( + application_id: ENV.fetch('BW_VOICE_APPLICATION_ID'), + to: ENV.fetch('USER_NUMBER'), + from: ENV.fetch('BW_NUMBER'), + answer_url: "#{ENV.fetch('BASE_CALLBACK_URL')}/callbacks/answer", +) begin - result = voice_client.create_call(ENV['BW_ACCOUNT_ID'], body) - puts result.data.call_id -rescue APIException => e - puts e.response_code + result = calls_api_instance.create_call(ENV.fetch('BW_ACCOUNT_ID'), call_body) + p result.call_id +rescue Bandwidth::ApiError => e + p e.code end ``` @@ -788,31 +785,20 @@ public ActionResult alert() { ```ruby -@POST '/incoming_calls' do: - phone_number = Bandwidth::Voice::PhoneNumber.new({ - :number => "+15555555554", - :transfer_answer_url => "/announcement" - }) +post '/incoming_calls' do + phone_number = Bandwidth::Bxml::PhoneNumber.new('+15555555554', { transfer_answer_url: '/announcement' }) + transfer = Bandwidth::Bxml::Transfer.new([phone_number], { transfer_caller_id: '+15555555555' }) + response = Bandwidth::Bxml::Response.new([transfer]) - transfer = Bandwidth::Voice::Transfer.new({ - :transfer_caller_id => "+15555555555", - :phone_numbers => [phone_number] - }) - - response = Bandwidth::Voice::Response.new() - response.push(transfer) + return response.to_bxml +end - puts response.to_bxml() - return response.to_bxml() +post '/announcement' do + speak_sentence = Bandwidth::Bxml::SpeakSentence.new("Hey! There's a customer on the line.") + response = Bandwidth::Bxml::Response.new([speak_sentence]) -@POST '/announcement' do: - speak_sentence = Bandwidth::Voice::SpeakSentence.new({ - :sentence => "Hey! There's a customer on the line." - }) - response = Bandwidth::Voice::Response.new() - response.push(speak_sentence) - puts response.to_bxml() - return response.to_bxml() + return response.to_bxml +end ``` @@ -1099,15 +1085,10 @@ Console.WriteLine(response.ToBXML()); ```ruby -speak_sentence = Bandwidth::Voice::SpeakSentence.new({ - :sentence => "This is a test.", - :voice => "julie" -}) - -response = Bandwidth::Voice::Response.new() -response.push(speak_sentence) +speak_sentence = Bandwidth::Bxml::SpeakSentence.new('This is a test.', { voice: 'julie' }) +response = Bandwidth::Bxml::Response.new([speak_sentence]) -puts response.to_bxml() +p response.to_bxml ``` diff --git a/site/docs/voice/modifyInProgressCallGuide.mdx b/site/docs/voice/modifyInProgressCallGuide.mdx index 6490d249b..73164512c 100644 --- a/site/docs/voice/modifyInProgressCallGuide.mdx +++ b/site/docs/voice/modifyInProgressCallGuide.mdx @@ -79,14 +79,10 @@ Console.WriteLine(response.ToBXML()); ```ruby -pause = Bandwidth::Voice::Pause.new({ - :duration => 60 -}) +pause = Bandwidth::Bxml::Pause.new({ duration: 60 }) +response = Bandwidth::Bxml::Response.new([pause]) -response = Bandwidth::Voice::Response.new() -response.push(pause) - -puts response.to_bxml() +p response.to_bxml ``` @@ -318,36 +314,38 @@ public ActionResult goodbyeMessage() { ```ruby -require 'bandwidth' +require 'bandwidth-sdk' -include Bandwidth -include Bandwidth::Voice +begin + BW_USERNAME = ENV.fetch('BW_USERNAME') + BW_PASSWORD = ENV.fetch('BW_PASSWORD') + BW_ACCOUNT_ID = ENV.fetch('BW_ACCOUNT_ID') + BW_VOICE_APPLICATION_ID = ENV.fetch('BW_VOICE_APPLICATION_ID') + BW_NUMBER = ENV.fetch('BW_NUMBER') + USER_NUMBER = ENV.fetch('USER_NUMBER') + BASE_CALLBACK_URL = ENV.fetch('BASE_CALLBACK_URL') + CALL_ID = ENV.fetch('CALL_ID') +rescue + p 'Please set the environmental variables defined in the README' + exit(-1) +end -ACCOUNT_ID = ENV['BW_ACCOUNT_ID'] +Bandwidth.configure do |config| + config.username = BW_USERNAME + config.password = BW_PASSWORD +end -bandwidth_client = Bandwidth::Client.new( - voice_basic_auth_user_name: ENV['BW_USERNAME'], - voice_basic_auth_password: ENV['BW_PASSWORD'] -) +calls_api_instance = Bandwidth::CallsApi.new -bandwidth_client = Bandwidth::Client.new( - voice_basic_auth_user_name: "api-username", - voice_basic_auth_password: "api-password" +call_body = Bandwidth::UpdateCall.new( + state: 'active', + redirect_url: '/goodbyeMessage' ) -voice_client = bandwidth_client.voice_client.client - -body = ModifyCallRequest.new -body.redirect_url = "/goodbyeMessage" -body.state = "active" -#remember to add auth for your application if needed! - -call_id = {CALL_ID} - begin - voice_client.modify_call(ACCOUNT_ID, call_id, body) -rescue APIException => e - puts e.response_code + calls_api_instance.update_call(ACCOUNT_ID, CALL_ID, call_body) +rescue Bandwidth::ApiError => e + p e.code end ``` @@ -356,13 +354,12 @@ end ```ruby #Note: This application is pseudocoded. Your implementation will look different -post '/goodbyeMessage' do: - speak_sentence = Bandwidth::Voice::SpeakSentence.new({ - :sentence => "Thank you for holding! Goodbye!" - }) - response = Bandwidth::Voice::Response.new() - response.push(speak_sentence) - return response.to_bxml() +post '/goodbyeMessage' do + speak_sentence = Bandwidth::Bxml::SpeakSentence.new('Thank you for holding! Goodbye!') + response = Bandwidth::Bxml::Response.new([speak_sentence]) + + return response.to_bxml +end ``` diff --git a/site/docs/voice/outboundCallGuide.mdx b/site/docs/voice/outboundCallGuide.mdx index 68d27e52f..6a0561f3e 100644 --- a/site/docs/voice/outboundCallGuide.mdx +++ b/site/docs/voice/outboundCallGuide.mdx @@ -168,30 +168,27 @@ class Program ```ruby -require 'bandwidth' +require 'bandwidth-sdk' -include Bandwidth -include Bandwidth::Voice - -bandwidth_client = Bandwidth::Client.new( - voice_basic_auth_user_name: ENV['BW_USERNAME'], - voice_basic_auth_password: ENV['BW_PASSWORD'] -) +Bandwidth.configure do |config| + config.username = ENV.fetch('BW_USERNAME') + config.password = ENV.fetch('BW_PASSWORD') +end -voice_client = bandwidth_client.voice_client.client +calls_api_instance = Bandwidth::CallsApi.new -body = CreateCallRequest.new -body.from = ENV['BW_NUMBER'] -body.to = ENV['USER_NUMBER'] -body.answer_url = ENV['BASE_CALLBACK_URL'] + "/callbacks/answer" -body.application_id = ENV['BW_VOICE_APPLICATION_ID'] -#remember to add auth for your application if needed! +call_body = Bandwidth::CreateCall.new( + application_id: ENV.fetch('BW_VOICE_APPLICATION_ID'), + to: ENV.fetch('USER_NUMBER'), + from: ENV.fetch('BW_NUMBER'), + answer_url: "#{ENV.fetch('BASE_CALLBACK_URL')}/callbacks/answer", +) begin - result = voice_client.create_call(ENV['BW_ACCOUNT_ID'], body) - puts result.data.call_id -rescue APIException => e - puts e.response_code + result = calls_api_instance.create_call(ENV.fetch('BW_ACCOUNT_ID'), call_body) + p result.call_id +rescue Bandwidth::ApiError => e + p e.code end ``` diff --git a/site/docs/voice/recordingGuide.mdx b/site/docs/voice/recordingGuide.mdx index bc26515fa..b618323f3 100644 --- a/site/docs/voice/recordingGuide.mdx +++ b/site/docs/voice/recordingGuide.mdx @@ -145,31 +145,23 @@ public ActionResult thankYou() { ```ruby -@POST '/record_name' do: - speak_sentence = Bandwidth::Voice::SpeakSentence.new({ - :sentence => "Please say your name." - }) - - record = Bandwidth::Voice::Record.new({ - :record_complete_url => "/nextBXML", - :max_duration => "10" - }) - - response = Bandwidth::Voice::Response.new() - response.push(speak_sentence) - response.push(record) - - return response.to_bxml() - -@POST '/nextBXML' do: - speak_sentence = Bandwidth::Voice::SpeakSentence.new({ - :sentence => "Thank you." - }) - response = Bandwidth::Voice::Response.new() - response.push(speak_sentence) +post '/record_name' do + speak_sentence = Bandwidth::Bxml::SpeakSentence.new('Please say your name.') + record = Bandwidth::Bxml::Record.new({ + record_complete_url: '/nextBXML', + max_duration: 10 + }) + response = Bandwidth::Bxml::Response.new([speak_sentence, record]) + + return response.to_bxml +end - return response.to_bxml() +post '/nextBXML' do + speak_sentence = Bandwidth::Bxml::SpeakSentence.new('Thank you.') + response = Bandwidth::Bxml::Response.new([speak_sentence]) + return response.to_bxml +end ``` @@ -401,36 +393,31 @@ public ActionResult record_call() { **Note: The endpoint headers are pseudocoded. Your implementation will look different -``` -@POST '/secret_agent_endpoint' do: - start_recording = Bandwidth::Voice::StartRecording.new({ - :recording_available_url => "https://myapp.test/noBXML" - }) - intro_tts = Bandwidth::Voice::SpeakSentence.new({ - :sentence => "Hello secret agent. What is your message?", - }) - pause1 = Bandwidth::Voice::Pause.new({ :duration => 10 }) - - pause_recording = Bandwidth::Voice::PauseRecording.new() - - passcode_tts = Bandwidth::Voice::SpeakSentence.new({ - :sentence => "Please say your secret passcode to send. Don't worry, the recording is paused!", - }) - pause2 = Bandwidth::Voice::Pause.new({ :duration => 5 }) - - resume_recording = Bandwidth::Voice::ResumeRecording.new() - - goodbye_tts = Bandwidth::Voice::SpeakSentence.new({ - :sentence => "Thank you agent. Good luck on your mission!", - }) - - stop_recording = Bandwidth::Voice::StopRecording.new() - - response = Bandwidth::Voice::Response.new() - response.push(start_recording, intro_tts, pause1, pause_recording, passcode_tts, - pause2, resume_recording, goodbye_tts, stop_recording) - - return response.to_bxml() +```ruby +post '/secret_agent_endpoint' do + start_recording = Bandwidth::Bxml::StartRecording.new({ recording_available_url: 'https://myapp.test/noBXML' }) + speak_sentence_intro = Bandwidth::Bxml::SpeakSentence.new('Hello secret agent. What is your message?') + pause_1 = Bandwidth::Bxml::Pause.new({ duration: 10 }) + pause_recording = Bandwidth::Bxml::PauseRecording.new + speak_sentence_passcode = Bandwidth::Bxml::SpeakSentence.new("Please say your secret passcode to send. Don't worry, the recording is paused!") + pause_2 = Bandwidth::Bxml::Pause.new({ duration: 5 }) + resume_recording = Bandwidth::Bxml::ResumeRecording.new() + speak_sentence_goodbye = Bandwidth::Bxml::SpeakSentence.new('Thank you agent. Good luck on your mission!') + stop_recording = Bandwidth::Bxml::StopRecording.new() + response = Bandwidth::Bxml::Response.new([ + start_recording, + speak_sentence_intro, + pause_1, + pause_recording, + speak_sentence_passcode, + pause_2, + resume_recording, + speak_sentence_goodbye, + stop_recording + ]) + + return response.to_bxml +end ``` @@ -646,23 +633,31 @@ class Program ```ruby -require 'bandwidth' +require 'bandwidth-sdk' -include Bandwidth -include Bandwidth::Voice +begin + BW_USERNAME = ENV.fetch('BW_USERNAME') + BW_PASSWORD = ENV.fetch('BW_PASSWORD') + BW_ACCOUNT_ID = ENV.fetch('BW_ACCOUNT_ID') + CALL_ID = ENV.fetch('CALL_ID') + RECORDING_ID = ENV.fetch('RECORDING_ID') +rescue + p 'Please set the environmental variables defined in the README' + exit(-1) +end -bandwidth_client = Bandwidth::Client.new( - voice_basic_auth_user_name: {BW_USERNAME}, - voice_basic_auth_password: {BW_PASSWORD} -) +Bandwidth.configure do |config| + config.username = BW_USERNAME + config.password = BW_PASSWORD +end -voice_client = bandwidth_client.voice_client.client +recordings_api_instance = Bandwidth::RecordingsApi.new begin - response = voice_client.get_call_recording({ACCOUNT_ID}, {CALL_ID}, {RECORDING_ID}) - puts response.data.application_id -rescue APIException => e - puts e.response_code + response = calls_api_instance.get_call_recording(BW_ACCOUNT_ID, CALL_ID, RECORDING_ID) + p response.application_id +rescue Bandwidth::ApiError => e + p e.code end ``` @@ -861,27 +856,32 @@ static async Task Main(string[] args) { ```ruby -require 'bandwidth' +require 'bandwidth-sdk' -include Bandwidth -include Bandwidth::Voice +begin + BW_USERNAME = ENV.fetch('BW_USERNAME') + BW_PASSWORD = ENV.fetch('BW_PASSWORD') + BW_ACCOUNT_ID = ENV.fetch('BW_ACCOUNT_ID') + CALL_ID = ENV.fetch('CALL_ID') + RECORDING_ID = ENV.fetch('RECORDING_ID') +rescue + p 'Please set the environmental variables defined in the README' + exit(-1) +end -bandwidth_client = Bandwidth::Client.new( - voice_basic_auth_user_name: {BW_USERNAME}, - voice_basic_auth_password: {BW_PASSWORD} -) +Bandwidth.configure do |config| + config.username = BW_USERNAME + config.password = BW_PASSWORD +end -voice_client = bandwidth_client.voice_client.client +recordings_api_instance = Bandwidth::RecordingsApi.new -body = TranscribeRecordingRequest.new -body.callback_url = "http://example.test/transcription" -#remember to add auth for your application if needed! +body = Bandwidth::TranscribeRecording.new(callback_url: 'http://example.test/transcription') begin - response = voice_client.create_transcribe_call_recording({ACCOUNT_ID}, {CALL_ID}, {RECORDING_ID}, body) - puts response.data.transcripts -rescue APIException => e - puts e.response_code + recordings_api_instance.transcribe_call_recording(BW_ACCOUNT_ID, CALL_ID, RECORDING_ID, body) +rescue Bandwidth::ApiError => e + p e.code end ``` @@ -1053,22 +1053,21 @@ public ActionResult alert() { **Note: The endpoint headers are pseudocoded. Your implementation will look different -``` -@POST '/incoming_calls' do: - - record = Bandwidth::Voice::Record.new({ - :transcribe => true, - :transcription_available_url => "/transcription_callback", - :max_duration => "10" - }) - - response = Bandwidth::Voice::Response.new() - response.push(record) - - return response.to_bxml() +```ruby +post '/incoming_calls' do + record = Bandwidth::Bxml::Record.new({ + transcribe: true, + transcription_available_url: '/transcription_callback', + max_duration: 10 + }) + response = Bandwidth::Bxml::Response.new([record]) + + return response.to_bxml +end -@POST '/transcription_callback' do: - puts "Oh! A transcription!".inspect +post '/transcription_callback' do + # handle transcription callback +end ``` @@ -1233,18 +1232,33 @@ static async Task Main(string[] args) ```ruby -bandwidth_client = Bandwidth::Client.new( - voice_basic_auth_user_name: {BW_USERNAME}, - voice_basic_auth_password: {BW_PASSWORD} -) +require 'bandwidth-sdk' -voice_client = bandwidth_client.voice_client.client +begin + BW_USERNAME = ENV.fetch('BW_USERNAME') + BW_PASSWORD = ENV.fetch('BW_PASSWORD') + BW_ACCOUNT_ID = ENV.fetch('BW_ACCOUNT_ID') + CALL_ID = ENV.fetch('CALL_ID') + RECORDING_ID = ENV.fetch('RECORDING_ID') +rescue + p 'Please set the environmental variables defined in the README' + exit(-1) +end + +Bandwidth.configure do |config| + config.username = BW_USERNAME + config.password = BW_PASSWORD +end + +recordings_api_instance = Bandwidth::RecordingsApi.new + +body = Bandwidth::TranscribeRecording.new(callback_url: 'http://example.test/transcription') begin - response = voice_client.get_call_transcription({ACCOUNT_ID}, {CALL_ID}, {RECORDING_ID}) - puts response.data.transcripts -rescue APIException => e - puts e.response_code + response = recordings_api_instance.get_call_transcription(BW_ACCOUNT_ID, CALL_ID, RECORDING_ID) + p response.transcripts +rescue Bandwidth::ApiError => e + p e.code end ``` diff --git a/site/docs/voice/transferGuide.mdx b/site/docs/voice/transferGuide.mdx index 2f1c442a8..92fa86f1a 100644 --- a/site/docs/voice/transferGuide.mdx +++ b/site/docs/voice/transferGuide.mdx @@ -88,18 +88,11 @@ Console.WriteLine(response.ToBXML()); ```ruby -phone_number = Bandwidth::Voice::PhoneNumber.new({ - :number => "+11234567892" -}) +phone_number = Bandwidth::Bxml::PhoneNumber.new('+11234567892') +transfer = Bandwidth::Bxml::Transfer.new([phone_number]) +response = Bandwidth::Bxml::Response.new([transfer]) -transfer = Bandwidth::Voice::Transfer.new({ - :phone_numbers => [phone_number] -}) - -response = Bandwidth::Voice::Response.new() -response.push(transfer) - -puts response.to_bxml() +p response.to_bxml ``` @@ -288,36 +281,21 @@ public ActionResult alert() { ```ruby -@POST '/incoming_calls' do: - speak_sentence = Bandwidth::Voice::SpeakSentence.new({ - :sentence => "Thank you for calling Scrooge and Marley! Please hold while we connect you to an associate.", - }) - - phone_number = Bandwidth::Voice::PhoneNumber.new({ - :number => "+15555555554", - :transfer_answer_url => "/announcement" - }) - - transfer = Bandwidth::Voice::Transfer.new({ - :transfer_caller_id => "+15555555555", - :phone_numbers => [phone_number] - }) - - response = Bandwidth::Voice::Response.new() - response.push(speak_sentence) - response.push(transfer) - - puts response.to_bxml() - return response.to_bxml() +post '/incoming_calls' do + speak_sentence = Bandwidth::Bxml::SpeakSentence.new('Thank you for calling Scrooge and Marley! Please hold while we connect you to an associate.') + phone_number = Bandwidth::Bxml::PhoneNumber.new('+15555555554', { transfer_answer_url: '/announcement' }) + transfer = Bandwidth::Bxml::Transfer.new([phone_number], { transfer_caller_id: '+15555555555' }) + response = Bandwidth::Bxml::Response.new([speak_sentence, transfer]) -@POST '/announcement' do: - speak_sentence = Bandwidth::Voice::SpeakSentence.new({ - :sentence => "Hey! There's a customer on the line." - }) - response = Bandwidth::Voice::Response.new() - response.push(speak_sentence) - puts response.to_bxml() - return response.to_bxml() + return response.to_bxml +end + +post '/announcement' do + speak_sentence = Bandwidth::Bxml::SpeakSentence.new("Hey! There's a customer on the line.") + response = Bandwidth::Bxml::Response.new([speak_sentence]) + + return response.to_bxml +end ```