Twilio and Picker: invalid response - content-type?

Hi all,

I am using Picker to process incoming text messages via Twilio. The goal is to alert me via Slack as soon as I receive one.

Everything works fine and I get a notification in Slack, but I receive daily emails from Twilio saying that there was a problem calling my webhook url, this is what Twilio receives from my server:

<html>
    <head>
        <title>502 Bad Gateway</title>
    </head>
    <body>
        <h1>Bad Gateway</h1>An upstream server returned an invalid response.
    </body>
</html>

This is my Picker route:

Picker.route '/api/new-sms', (params, req, res, next) ->
  message =
    to: params.query.To
    from: params.query.From
    body: params.query.Body
  booking = Bookings.findOne phone: message.from,
    sort: createdAt: -1
  EventEmitter.emit 'newIncomingSms', message, booking
  res.statusCode = 200
  res.end()

I tried to replicate this by using POSTMAN, but I always get a 200 OK. Could it be something with content-type? If so, how do you change that with Picker?

Thanks a lot!

I think I solved it:

  res.writeHead 200, 'Content-Type': 'text/html'
  return res.end 'ok'