[英]How to use a variable in a custom function in Twilio Studio?
I would like to use variables from the Trigger
widget in Twilio Studio, for example the trigger.message.From
variable (that I believe contains the sender's phone number). 我想使用Twilio Studio中“
Trigger
窗口小部件中的变量,例如trigger.message.From
变量(我相信其中包含发件人的电话号码)。
Unfortunately, these variables are not passed to the event
object in my function: 不幸的是,这些变量没有传递给我函数中的
event
对象:
exports.handler = function(context, event, callback) {
console.log("received event: " + JSON.stringify(event, null, 4));
};
prints: 打印:
received event: {}
收到的事件:{}
The variables need to be passed as parameters in the run function
configuration. 变量需要在
run function
配置中作为参数传递。 For example, adding a parameter with Key caller
and Value {{trigger.message.From}}
should inject this variable in the event
object: 例如,添加带有键
caller
和值{{trigger.message.From}}
应将此变量注入event
对象:
exports.handler = function(context, event, callback) {
console.log("caller is: " + event.caller);
};
Try calling the Twilio number and you should see your number: 尝试拨打Twilio号码,您应该会看到您的号码:
caller is: +1XXXXXXXXX
来电者是:+ 1XXXXXXXXX
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.