twilio

Passing an argument from one Twilio function to another


I have a standard Twilio function:

exports.handler = (context, event, callback) => 
{
  const calledNumber = event.CalledNumber;
  if(calledNumber == "+18008675309") 
  { 
   const TheFunction = Runtime.getFunctions()['CheckForDessert'].path;
   const Function = require(TheFunction)
   var AvailableToDial = Function.CheckBusinessHours({"dessert":"yes"})
  }
  
  ...
}

The CheckForDessert function:

exports.CheckBusinessHours = function(context, event, callback) {
  console.log(event)

  return 'blankText'
};

How can I get the CheckForDesserts function to access the data passed to it, namely the fact that the key, 'dessert,' is set to 'yes?'

I've tried sending strings, JSON, etc., but I'm missing something because console.log inside the CheckForDessert function just gives me "undefined". Thank you!


Solution

  • the helper function (CheckBusinessHours) will not have context,event and callback as it is helper function. Replace it with the param that you want to pass.

    Ref link below

    Twilio docs