是否可以将Lambda用作Twilio的后端?
我可以给Lambda打电话给Twilio,但我需要从来电者处获取信息,例如“按1”。我可以创建一个服务器,但是我可以调用Lambda函数吗? (我知道我们不能调用Lambda)。
以下是我想做的一个例子。
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 ");
});
答案 0 :(得分: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