0

I would like to use variables from the Trigger widget in Twilio Studio, for example the trigger.message.From variable (that I believe contains the sender's phone number).

Unfortunately, these variables are not passed to the event object in my function:

exports.handler = function(context, event, callback) {
    console.log("received event: " + JSON.stringify(event, null, 4));
};

prints:

received event: {}

Jezor
  • 3,253
  • 2
  • 19
  • 43

1 Answers1

2

The variables need to be passed as parameters in the run function configuration. For example, adding a parameter with Key caller and Value {{trigger.message.From}} should inject this variable in the event object:

exports.handler = function(context, event, callback) {
    console.log("caller is: " + event.caller);
};

Try calling the Twilio number and you should see your number:

caller is: +1XXXXXXXXX

Jezor
  • 3,253
  • 2
  • 19
  • 43