twilio Lambda backend aws

假如想象 提交于 2019-12-14 03:54:33

问题


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 ");
  });

回答1:


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



来源:https://stackoverflow.com/questions/30509793/twilio-lambda-backend-aws

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!