-
Notifications
You must be signed in to change notification settings - Fork 87
Expand file tree
/
Copy pathvoice mail code
More file actions
25 lines (21 loc) · 840 Bytes
/
voice mail code
File metadata and controls
25 lines (21 loc) · 840 Bytes
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
public class AnsweringMachine extends HttpServlet {
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
TwiMLResponse twiml = new TwiMLResponse();
Say pleaseLeaveMessage = new Say("Please leave your message for Brodan now.");
// Record the caller's voice.
Record record = new Record();
record.setMaxLength(60);
record.setTimeout(5);
record.setAction("/twilio/handle-recording");
record.setPlayBeep(true);
try {
twiml.append(pleaseLeaveMessage);
twiml.append(record);
} catch (TwiMLException e) {
e.printStackTrace();
}
// Respond with TwiML
response.setContentType("application/xml");
response.getWriter().print(twiml.toXML());
}
}