Reputation: 56
If you want to call a Twilio environmental variable from within a Twilio function, you can do it like this.
context.myVariableName
I didn't see the answer on Stack Exchange, I hope it helps. To set the environmental variable, it is done from "Configure" in the Functions menu.
Upvotes: 0
Views: 1112
Reputation: 73027
Twilio developer evangelist here.
This is correct, though not really a question. You can find out all about how the environment for a Twilio Function is constructed in the documentation.
Notably, in the function signature exports.handler = function(context, event, callback)
the following is the case:
context
contains:
and, if you have "Enable ACCOUNT_SID and AUTH_TOKEN" checked in the Configure section:
getTwilioClient()
, which will return an API client from the Twilio module authenticated with your account sid and auth tokenevent
then contains:
GET
or POST
requestsand callback
is a function that should be invoked once you are finished processing the request and would like to complete execution. If there was an error in execution, pass that error as the first argument of callback
. Otherwise, pass null
as the first argument and the response you want to return as the second argument.
As I said, this is all in the documentation, but I hope it helps if you were missing something.
Upvotes: 2