0

我无法在 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);
         
     });
     
     
    };
4

1 回答 1

1

您需要通过 Run Function Widget Function Parameters 将 `{{widgets.Mortgage_info.Digits}}` 的值传递给 Twilio 函数。

您可以通过查看此代码示例来了解其工作原理。

在 Studio 中使用 Run Function 小部件

于 2021-04-28T11:35:51.693 回答