Makes it easy for an express app to route SMS texts to functions
(Note: this project was heavily inspired by Speech router)
Twilio Router is a wrapper for Twilio's SMS APIs. It enables you to declare "routes" which map speech to functionality within your Express application.
apppost'/twilio'routes:"feedback *comments": "saveComments""signup :email": "signup""search :engine for *query": "search"Commentscreate/*...*/ressms'Your comment has been recorded';//...//...;
properties will be copied onto the object.
properties should contain a
routes hash that maps formats to functions:
The function can either be a string that maps to a function or an inline function. The format can contain parameters:
:paramMatches any text not containing whitespace
*paramMatches any text (with/without spaces)
(optional)Makes the selection optional (i.e., the route will fire the associated function regardless of whether or not the given text is found)
Associate the given callback function with the given format. This can be used to add routes on the fly. If the first argument is an object instead of a string, it is assumed that it is a hash of routes, similar what is expected in the constructor.
routerroute"say hello to :name"console.log"Hi, " + name + "!";;
Manually invoke the function associated with a transcript. This function is also used internally to invoke functions associated with a speech recognition transcript.
routertrigger"say hello to Lukas";