ymaghzaz
ymaghzaz

Reputation: 84

twilio Lambda backend aws

Is it possible to use Lambda as a backend for Twilio?

I can call Twilio fro Lambda, but I need to get information from the caller, such as "press 1". I could make a server, but can I invoke Lambda functions? (I know we can't invoke Lambda).

Here's an example of what I'd like to do.

exports.handler = function(event, context) {
  resp.say('bienvenue ', {
    voice:'alice',
    language:'fr-FR'
  });
  resp.say('helloo', {
    voice:'woman',
    language:'fr-FR'
  });
  .gather({
   method:"GET",
   finishOnKey:'*',
   action : 'serveur_backend',
   timeout: "10"
  }, function() {
   this.say('presse 1 to ****  ', {
   voice:'alice',
   language:'fr-FR'
  });

  var l = "<Response>"+S(resp.toString()).between('<Response>', '</Response>').s+"</Response>";
  var URL = "http://twimlets.com/echo?Twiml="+encodeURIComponent(l);
  console.log(URL);
  client.calls.create({
    url:   URL,
    to: "+**********",
    from: "+*********"
//    timeout: "10"
//    callback
  }, 
  function(err, call) { console.log("appel lancé");
   process.stdout.write(call.sid);
    console.log(call.sid);
  context.done(null,  " have a nice day ");
  });

Upvotes: 2

Views: 627

Answers (1)

ecorvo
ecorvo

Reputation: 3629

You can use the API Gateway as an endpoint for Twilio which triggers your lambda function. See this:

http://docs.aws.amazon.com/apigateway/latest/developerguide/getting-started.html

Upvotes: 1

Related Questions