0
votes

I am extremely new to Twilio but so far I have build quiet the web of widgets in studio and I love the design of this system. My only problem so far is being able to get user input and pass it to a function.

On my Voice IVR - Twilio Studio I have a Gather Input On Call widget that requests the caller enter a code. From there, the user pressed keys result goes to a Run Function widget.

My Run Function properties are set to the correct function URL and the function parameters are set to

KEY: passedID VALUE: {{widgets.security.Digits}}

security is the correct name of the Gather Input On Call widget. From there, I have the following code in my function.

exports.handler = function(context, event, callback) {
    
    // get passed IDs
    let passedID1 = context.passedID;
    
    // default to wrong ID entered
        callback(null, "0");

    // approved IDs
    var emps = ["99999"];

    // check if ID matches list
    var emps1 = emps.includes(passedID1);

    // good id found
    if (emps1 === true){
        callback(null, "1");
    }
    
};

For the life of me, I can't figure out why the input is not being passed to the function.


as far as I can tell, everything is running fine its just not getting the keyed parameters.... I changed my script to this

exports.handler = function(context, event, callback) {
    
var passedID1 = context.passedID;

var emps = [41079, 99999];

function CheckID() {
    var IDstatus = emps.includes(passedID1);
  if (IDstatus === true){
    IDstatus = 1;
  }else{
    IDstatus = 0;
  }
    return IDstatus;
}

callback(null, CheckID());
    
};

if context.passedID is changed to 99999 the flow runs perfectly.

1

1 Answers

0
votes

You want to get the value from the event object rather than the context object.

var passedID1 = event.passedID;