1

As question says twilio redirect function not working properly with flow (twilio studio).

When I select function on phone number for incoming messages it is working FINE.

enter image description here


But when I tried to redirect incoming msg using the function widget on studio, redirect not working properly and debug console says response body empty.

This is the redirect function

exports.handler = function(context, event, callback) {
    const response = new Twilio.Response();
    response.appendHeader('Location', context.HTTP_REDIRECT_URL);
    callback(null, response);
};

Please advise what's happening here?

Do I need to transfer some key pairs using function widgets?

enter image description here


enter image description here


enter image description here

brucelin
  • 981
  • 2
  • 11
  • 23

1 Answers1

0

Short answer:

Probably yes. But it is maybe better if you replace context.HTTP_REDIRECT_URL with the string literal "http://example.com:myport"

Longer answer:

Twilio does not know the value of HTTP_REDIRECT_URL from the ether.

The context parameter is propagated from the runtime environment variables, so you need to add that HTTP_REDIRECT_URL environment variable and a value to it.

Although I rather recommend you redirecting with twiml.redirect(url) rather than using the location header. That's more easy to debug.

(see the demo code for getting the twiml object)

lezsakdomi
  • 115
  • 10