3 const Twilio
= require('twilio');
7 internals
.kMenuTimeout
= 10; // timeout in seconds
8 internals
.kContentType
= 'application/xml'; // The content type used to respond
9 internals
.kMenuLanguage
= 'es-mx'; // the language to use
10 internals
.kMainMenuRoute
= '/menus/main';
11 internals
.kListenMessageRoute
= '/recordings/';
12 internals
.kMenuMessage
= 'Escribe el numero de mensaje y presiona gato para terminar.';
13 internals
.kTimeoutMessage
= 'Bueno... volviendo al menĂș principal.';
14 internals
.kMenuInvalidResponseMessage
= 'No entendĂ... Volviendo al menu principal.'; // invalid selection message
17 * Handles the HTTP requests for the recording menu
19 * @class RecordingMenuController
21 module
.exports
= internals
.RecordingMenuController
= class RecordingMenuController
{
27 * @memberof RecordingMenuController
29 * @return {generator} a koa compatible handler generator function
33 return function * () {
35 const response
= new Twilio
.TwimlResponse();
37 // the action will default to post in the same URL, so no change
40 timeout: internals
.kMenuTimeout
41 }, function nestedHandler() {
43 this.say(internals
.kMenuMessage
, { language: internals
.kMenuLanguage
});
45 .say(internals
.kTimeoutMessage
, { language: internals
.kMenuLanguage
})
46 .redirect(internals
.kMainMenuRoute
, { method: 'GET' });
48 this.type
= internals
.kContentType
;
49 this.body
= response
.toString();
54 * Parses the selected recording id
56 * @function parseMenuSelection
57 * @memberof RecordingMenuController
59 * @return {generator} a koa compatible handler generator function
61 parseMenuSelection() {
63 return function * () {
65 const messageId
= parseInt(this.request
.body
.Digits
);
67 const response
= new Twilio
.TwimlResponse();
70 response
.redirect(`${internals.kListenMessageRoute}${messageId}`, { method: 'GET' });
73 response
.say(internals
.kMenuInvalidResponseMessage
, { language: internals
.kMenuLanguage
})
74 .redirect(internals
.kMainMenuRoute
, { method: 'GET' });
77 this.type
= internals
.kContentType
;
78 this.body
= response
.toString();