File size: 1,638 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Package twiml provides a type-safe way of building and parsing the TwiML markup language in Go.
//
// TwiML is an XML-based language used by Twilio to control phone calls and SMS messages. The package provides
// Go structs that can be used to generate TwiML documents or parse incoming TwiML messages.
//
// The `Response` struct is the root element of a TwiML document. It can contain a sequence of `Verb`s, such as
// `Say`, `Gather`, `Pause`, `Redirect`, or `Hangup`. Each `Verb` is represented by a Go struct that contains
// the corresponding TwiML attributes and child elements.
//
// Example usage:
//
//	r := &twiml.Response{
//	    Verbs: []twiml.Verb{
//	        &twiml.Say{
//	            Content: "Hello, world!",
//	        },
//	        &twiml.Gather{
//	            Action: "/process_gather",
//	            NumDigitsCount: 1,
//	            Verbs: []twiml.GatherVerb{
//	                &twiml.Say{
//	                    Content: "Press 1 to confirm, or any other key to try again.",
//	                },
//	            },
//	        },
//	    },
//	}
//	b, _ := xml.MarshalIndent(r, "", "  ")
//	fmt.Println(string(b))
//
// Output:
//
// <Response>
//
//	<Say>Hello, world!</Say>
//	<Gather action="/process_gather">
//	  <Say>Press 1 to confirm, or any other key to try again.</Say>
//	</Gather>
//
// </Response>
//
// Incoming TwiML messages can be parsed using the `Interpreter` struct, which reads a sequence of bytes and
// returns the next `Verb` in the message until the end is reached. The `Interpreter` can be used to implement
// server-side TwiML applications that respond to user input.
package twiml