pub struct VoiceResponse { /* private fields */ }Expand description
Implementations§
Source§impl VoiceResponse
impl VoiceResponse
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/voice_call.rs (line 39)
38fn simple_greeting() {
39 let response = VoiceResponse::new()
40 .say("Hello! Welcome to TwiML Rust.")
41 .say("This is a simple voice response example.")
42 .hangup();
43
44 println!("{}", response.to_xml());
45}
46
47/// Interactive voice response menu
48fn ivr_menu() {
49 let gather = Gather::new()
50 .input(vec!["dtmf".to_string(), "speech".to_string()])
51 .action("https://example.com/handle-input")
52 .method("POST")
53 .timeout(10)
54 .num_digits(1)
55 .add_say(Say::new(
56 "Press 1 for sales, 2 for support, or 3 for billing. You can also say the department name.",
57 ));
58
59 let response = VoiceResponse::new()
60 .say("Welcome to our automated phone system.")
61 .gather(gather)
62 .say("We didn't receive any input.")
63 .redirect("https://example.com/main-menu");
64
65 println!("{}", response.to_xml());
66}
67
68/// Call forwarding to a phone number
69fn call_forwarding() {
70 let dial = Dial::new()
71 .timeout(30)
72 .add_number(DialNumber::new("+15559876543").send_digits("wwww1234"));
73
74 let response = VoiceResponse::new()
75 .say("Please wait while we connect your call.")
76 .dial_with(dial)
77 .say("The call could not be completed. Please try again later.")
78 .hangup();
79
80 println!("{}", response.to_xml());
81}
82
83/// Voicemail recording system
84fn voicemail() {
85 let record = Record::new()
86 .action("https://example.com/handle-recording")
87 .method("POST")
88 .max_length(120)
89 .finish_on_key("#")
90 .transcribe(true)
91 .transcribe_callback("https://example.com/transcription");
92
93 let response = VoiceResponse::new()
94 .say("Please leave a message after the beep. Press the pound key when finished.")
95 .record(record)
96 .say("Thank you for your message. Goodbye!")
97 .hangup();
98
99 println!("{}", response.to_xml());
100}
101
102/// Advanced SSML features
103fn advanced_ssml() {
104 let say = Say::new("Welcome to our service")
105 .voice("Polly.Joanna")
106 .language("en-US")
107 .add_break(Some("medium".to_string()), None)
108 .add_emphasis(Some("strong".to_string()), "Please listen carefully")
109 .add_break(None, Some("1s".to_string()))
110 .add_prosody(
111 Some("high".to_string()),
112 Some("slow".to_string()),
113 None,
114 "This is important information",
115 );
116
117 let response = VoiceResponse::new()
118 .say_with(say)
119 .play("https://example.com/music.mp3")
120 .hangup();
121
122 println!("{}", response.to_xml());
123}Sourcepub fn comment_after(self, comment: impl Into<String>) -> Self
pub fn comment_after(self, comment: impl Into<String>) -> Self
Sourcepub fn comment_before(self, comment: impl Into<String>) -> Self
pub fn comment_before(self, comment: impl Into<String>) -> Self
Sourcepub fn dial_with_attributes(
self,
attributes: DialAttributes,
number: Option<impl Into<String>>,
) -> Dial
pub fn dial_with_attributes( self, attributes: DialAttributes, number: Option<impl Into<String>>, ) -> Dial
§Arguments
attributes- TwiML attributesnumber- Phone number to dial (optional)
Sourcepub fn gather(self, gather: Gather) -> Self
pub fn gather(self, gather: Gather) -> Self
Examples found in repository?
examples/voice_call.rs (line 61)
48fn ivr_menu() {
49 let gather = Gather::new()
50 .input(vec!["dtmf".to_string(), "speech".to_string()])
51 .action("https://example.com/handle-input")
52 .method("POST")
53 .timeout(10)
54 .num_digits(1)
55 .add_say(Say::new(
56 "Press 1 for sales, 2 for support, or 3 for billing. You can also say the department name.",
57 ));
58
59 let response = VoiceResponse::new()
60 .say("Welcome to our automated phone system.")
61 .gather(gather)
62 .say("We didn't receive any input.")
63 .redirect("https://example.com/main-menu");
64
65 println!("{}", response.to_xml());
66}Sourcepub fn hangup(self) -> Self
pub fn hangup(self) -> Self
Examples found in repository?
examples/voice_call.rs (line 42)
38fn simple_greeting() {
39 let response = VoiceResponse::new()
40 .say("Hello! Welcome to TwiML Rust.")
41 .say("This is a simple voice response example.")
42 .hangup();
43
44 println!("{}", response.to_xml());
45}
46
47/// Interactive voice response menu
48fn ivr_menu() {
49 let gather = Gather::new()
50 .input(vec!["dtmf".to_string(), "speech".to_string()])
51 .action("https://example.com/handle-input")
52 .method("POST")
53 .timeout(10)
54 .num_digits(1)
55 .add_say(Say::new(
56 "Press 1 for sales, 2 for support, or 3 for billing. You can also say the department name.",
57 ));
58
59 let response = VoiceResponse::new()
60 .say("Welcome to our automated phone system.")
61 .gather(gather)
62 .say("We didn't receive any input.")
63 .redirect("https://example.com/main-menu");
64
65 println!("{}", response.to_xml());
66}
67
68/// Call forwarding to a phone number
69fn call_forwarding() {
70 let dial = Dial::new()
71 .timeout(30)
72 .add_number(DialNumber::new("+15559876543").send_digits("wwww1234"));
73
74 let response = VoiceResponse::new()
75 .say("Please wait while we connect your call.")
76 .dial_with(dial)
77 .say("The call could not be completed. Please try again later.")
78 .hangup();
79
80 println!("{}", response.to_xml());
81}
82
83/// Voicemail recording system
84fn voicemail() {
85 let record = Record::new()
86 .action("https://example.com/handle-recording")
87 .method("POST")
88 .max_length(120)
89 .finish_on_key("#")
90 .transcribe(true)
91 .transcribe_callback("https://example.com/transcription");
92
93 let response = VoiceResponse::new()
94 .say("Please leave a message after the beep. Press the pound key when finished.")
95 .record(record)
96 .say("Thank you for your message. Goodbye!")
97 .hangup();
98
99 println!("{}", response.to_xml());
100}
101
102/// Advanced SSML features
103fn advanced_ssml() {
104 let say = Say::new("Welcome to our service")
105 .voice("Polly.Joanna")
106 .language("en-US")
107 .add_break(Some("medium".to_string()), None)
108 .add_emphasis(Some("strong".to_string()), "Please listen carefully")
109 .add_break(None, Some("1s".to_string()))
110 .add_prosody(
111 Some("high".to_string()),
112 Some("slow".to_string()),
113 None,
114 "This is important information",
115 );
116
117 let response = VoiceResponse::new()
118 .say_with(say)
119 .play("https://example.com/music.mp3")
120 .hangup();
121
122 println!("{}", response.to_xml());
123}Sourcepub fn play(self, url: impl Into<String>) -> Self
pub fn play(self, url: impl Into<String>) -> Self
Examples found in repository?
examples/voice_call.rs (line 119)
103fn advanced_ssml() {
104 let say = Say::new("Welcome to our service")
105 .voice("Polly.Joanna")
106 .language("en-US")
107 .add_break(Some("medium".to_string()), None)
108 .add_emphasis(Some("strong".to_string()), "Please listen carefully")
109 .add_break(None, Some("1s".to_string()))
110 .add_prosody(
111 Some("high".to_string()),
112 Some("slow".to_string()),
113 None,
114 "This is important information",
115 );
116
117 let response = VoiceResponse::new()
118 .say_with(say)
119 .play("https://example.com/music.mp3")
120 .hangup();
121
122 println!("{}", response.to_xml());
123}Sourcepub fn record(self, record: Record) -> Self
pub fn record(self, record: Record) -> Self
Examples found in repository?
examples/voice_call.rs (line 95)
84fn voicemail() {
85 let record = Record::new()
86 .action("https://example.com/handle-recording")
87 .method("POST")
88 .max_length(120)
89 .finish_on_key("#")
90 .transcribe(true)
91 .transcribe_callback("https://example.com/transcription");
92
93 let response = VoiceResponse::new()
94 .say("Please leave a message after the beep. Press the pound key when finished.")
95 .record(record)
96 .say("Thank you for your message. Goodbye!")
97 .hangup();
98
99 println!("{}", response.to_xml());
100}Sourcepub fn redirect(self, url: impl Into<String>) -> Self
pub fn redirect(self, url: impl Into<String>) -> Self
Examples found in repository?
examples/voice_call.rs (line 63)
48fn ivr_menu() {
49 let gather = Gather::new()
50 .input(vec!["dtmf".to_string(), "speech".to_string()])
51 .action("https://example.com/handle-input")
52 .method("POST")
53 .timeout(10)
54 .num_digits(1)
55 .add_say(Say::new(
56 "Press 1 for sales, 2 for support, or 3 for billing. You can also say the department name.",
57 ));
58
59 let response = VoiceResponse::new()
60 .say("Welcome to our automated phone system.")
61 .gather(gather)
62 .say("We didn't receive any input.")
63 .redirect("https://example.com/main-menu");
64
65 println!("{}", response.to_xml());
66}Sourcepub fn say(self, message: impl Into<String>) -> Self
pub fn say(self, message: impl Into<String>) -> Self
Examples found in repository?
examples/voice_call.rs (line 40)
38fn simple_greeting() {
39 let response = VoiceResponse::new()
40 .say("Hello! Welcome to TwiML Rust.")
41 .say("This is a simple voice response example.")
42 .hangup();
43
44 println!("{}", response.to_xml());
45}
46
47/// Interactive voice response menu
48fn ivr_menu() {
49 let gather = Gather::new()
50 .input(vec!["dtmf".to_string(), "speech".to_string()])
51 .action("https://example.com/handle-input")
52 .method("POST")
53 .timeout(10)
54 .num_digits(1)
55 .add_say(Say::new(
56 "Press 1 for sales, 2 for support, or 3 for billing. You can also say the department name.",
57 ));
58
59 let response = VoiceResponse::new()
60 .say("Welcome to our automated phone system.")
61 .gather(gather)
62 .say("We didn't receive any input.")
63 .redirect("https://example.com/main-menu");
64
65 println!("{}", response.to_xml());
66}
67
68/// Call forwarding to a phone number
69fn call_forwarding() {
70 let dial = Dial::new()
71 .timeout(30)
72 .add_number(DialNumber::new("+15559876543").send_digits("wwww1234"));
73
74 let response = VoiceResponse::new()
75 .say("Please wait while we connect your call.")
76 .dial_with(dial)
77 .say("The call could not be completed. Please try again later.")
78 .hangup();
79
80 println!("{}", response.to_xml());
81}
82
83/// Voicemail recording system
84fn voicemail() {
85 let record = Record::new()
86 .action("https://example.com/handle-recording")
87 .method("POST")
88 .max_length(120)
89 .finish_on_key("#")
90 .transcribe(true)
91 .transcribe_callback("https://example.com/transcription");
92
93 let response = VoiceResponse::new()
94 .say("Please leave a message after the beep. Press the pound key when finished.")
95 .record(record)
96 .say("Thank you for your message. Goodbye!")
97 .hangup();
98
99 println!("{}", response.to_xml());
100}Sourcepub fn say_with(self, say: Say) -> Self
pub fn say_with(self, say: Say) -> Self
Add a Say verb with a pre-configured Say object
Examples found in repository?
examples/voice_call.rs (line 118)
103fn advanced_ssml() {
104 let say = Say::new("Welcome to our service")
105 .voice("Polly.Joanna")
106 .language("en-US")
107 .add_break(Some("medium".to_string()), None)
108 .add_emphasis(Some("strong".to_string()), "Please listen carefully")
109 .add_break(None, Some("1s".to_string()))
110 .add_prosody(
111 Some("high".to_string()),
112 Some("slow".to_string()),
113 None,
114 "This is important information",
115 );
116
117 let response = VoiceResponse::new()
118 .say_with(say)
119 .play("https://example.com/music.mp3")
120 .hangup();
121
122 println!("{}", response.to_xml());
123}Sourcepub fn dial_with(self, dial: Dial) -> Self
pub fn dial_with(self, dial: Dial) -> Self
Add a Dial verb with a pre-configured Dial object
Examples found in repository?
examples/voice_call.rs (line 76)
69fn call_forwarding() {
70 let dial = Dial::new()
71 .timeout(30)
72 .add_number(DialNumber::new("+15559876543").send_digits("wwww1234"));
73
74 let response = VoiceResponse::new()
75 .say("Please wait while we connect your call.")
76 .dial_with(dial)
77 .say("The call could not be completed. Please try again later.")
78 .hangup();
79
80 println!("{}", response.to_xml());
81}Sourcepub fn gather_with(self, gather: Gather) -> Self
pub fn gather_with(self, gather: Gather) -> Self
Add a Gather verb with a pre-configured Gather object
Sourcepub fn record_with(self, record: Record) -> Self
pub fn record_with(self, record: Record) -> Self
Add a Record verb with a pre-configured Record object
Sourcepub fn connect_with(self, connect: Connect) -> Self
pub fn connect_with(self, connect: Connect) -> Self
Add a Connect verb with a pre-configured Connect object
Sourcepub fn enqueue_with(self, enqueue: Enqueue) -> Self
pub fn enqueue_with(self, enqueue: Enqueue) -> Self
Add an Enqueue verb with a pre-configured Enqueue object
Sourcepub fn refer_with(self, refer: Refer) -> Self
pub fn refer_with(self, refer: Refer) -> Self
Add a Refer verb with a pre-configured Refer object
Sourcepub fn reject_with(self, reject: Reject) -> Self
pub fn reject_with(self, reject: Reject) -> Self
Add a Reject verb with a pre-configured Reject object
Sourcepub fn start_with(self, start: Start) -> Self
pub fn start_with(self, start: Start) -> Self
Add a Start verb with a pre-configured Start object
Sourcepub fn pause_simple(self, length: u32) -> Self
pub fn pause_simple(self, length: u32) -> Self
Simple pause with just a length parameter
Sourcepub fn queue_with(self, queue: Queue) -> Self
pub fn queue_with(self, queue: Queue) -> Self
Add a Queue verb with a pre-configured Queue object
Sourcepub fn prompt_with(self, prompt: Prompt) -> Self
pub fn prompt_with(self, prompt: Prompt) -> Self
Add a Prompt verb with a pre-configured Prompt object
Trait Implementations§
Source§impl Clone for VoiceResponse
impl Clone for VoiceResponse
Source§fn clone(&self) -> VoiceResponse
fn clone(&self) -> VoiceResponse
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for VoiceResponse
impl Debug for VoiceResponse
Source§impl Default for VoiceResponse
impl Default for VoiceResponse
Source§fn default() -> VoiceResponse
fn default() -> VoiceResponse
Returns the “default value” for a type. Read more
Source§impl TwiML for VoiceResponse
impl TwiML for VoiceResponse
Auto Trait Implementations§
impl Freeze for VoiceResponse
impl RefUnwindSafe for VoiceResponse
impl Send for VoiceResponse
impl Sync for VoiceResponse
impl Unpin for VoiceResponse
impl UnwindSafe for VoiceResponse
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more