I can't get the value of my gather input widget in Twilio function, I always get an error enter image description here

This is the name of the gather input widget in Twilio studio enter image description here

This variable is not working. let 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);
         
     });
     
     
    };
1

There are 1 answers

4
Alan On BEST ANSWER

You need to pass the value of `{{widgets.Mortgage_info.Digits}}`` into the Twilio Function via the Run Function Widget Function Parameters.

You can see how this may work by looking at this code example.

Using Run Function widget in Studio