如何在 Twilio 函数 "let val = event.widgets.Mortgage_info.Digits.value;" 中获取 Gather input widget 的值?
How to get the value of Gather input widget in Twilio function "let val = event.widgets.Mortgage_info.Digits.value;"?
我无法在 Twilio 函数中获取我的收集输入小部件的值,我总是收到错误
这是 Twilio 工作室中收集输入小部件的名称
这个变量不起作用。
让 val = event.widgets.Mortgage_info.Digits.value;
exports.handler = function (context, event, callback) {
const got = require('got');
got('https://cyan-sparrow-7490.twil.io/assets/mortgage.json').then (response =>{
const mort = JSON.parse(response.body);
let mortgageData = mort.feed.entry;
let mortgageIdTest = mort.feed.entry[900].gsx$mortgage.$t;
//Begin filter code
let val = event.widgets.Mortgage_info.Digits.value;
let index = mortgageData.findIndex(function(item, i){
return item.gsx$mortgage.$t === val
});
//End filter code
let mortgageSpecificData = mort.feed.entry[index];
let mortgageId = mort.feed.entry[index].gsx$mortgage.$t;
let borrowerName = mort.feed.entry[index].gsx$name.$t;
let lenderName = mort.feed.entry[index].gsx$lender.$t;
let recordDate = mort.feed.entry[index].gsx$recorddate.$t;
let lendAmount = mort.feed.entry[index].gsx$amount.$t;
let neededData = `Borrower ${borrowerName}\nYou loan with ${lenderName}\nClosed on ${recordDate}`
console.log(val);
console.log(index);
console.log(neededData);
callback(null,neededData);
});
};
您需要通过 运行 函数小部件函数参数将 `{{widgets.Mortgage_info.Digits}}`` 的值传递到 Twilio 函数中。
您可以通过查看此代码示例了解其工作原理。
我无法在 Twilio 函数中获取我的收集输入小部件的值,我总是收到错误
这是 Twilio 工作室中收集输入小部件的名称
这个变量不起作用。 让 val = event.widgets.Mortgage_info.Digits.value;
exports.handler = function (context, event, callback) {
const got = require('got');
got('https://cyan-sparrow-7490.twil.io/assets/mortgage.json').then (response =>{
const mort = JSON.parse(response.body);
let mortgageData = mort.feed.entry;
let mortgageIdTest = mort.feed.entry[900].gsx$mortgage.$t;
//Begin filter code
let val = event.widgets.Mortgage_info.Digits.value;
let index = mortgageData.findIndex(function(item, i){
return item.gsx$mortgage.$t === val
});
//End filter code
let mortgageSpecificData = mort.feed.entry[index];
let mortgageId = mort.feed.entry[index].gsx$mortgage.$t;
let borrowerName = mort.feed.entry[index].gsx$name.$t;
let lenderName = mort.feed.entry[index].gsx$lender.$t;
let recordDate = mort.feed.entry[index].gsx$recorddate.$t;
let lendAmount = mort.feed.entry[index].gsx$amount.$t;
let neededData = `Borrower ${borrowerName}\nYou loan with ${lenderName}\nClosed on ${recordDate}`
console.log(val);
console.log(index);
console.log(neededData);
callback(null,neededData);
});
};
您需要通过 运行 函数小部件函数参数将 `{{widgets.Mortgage_info.Digits}}`` 的值传递到 Twilio 函数中。
您可以通过查看此代码示例了解其工作原理。