twilio / twilio-node

Node.js helper library
MIT License
1.39k stars 506 forks source link

Adding Custom Headers Property #458

Closed rbeatie closed 4 years ago

rbeatie commented 5 years ago

Note: These issues are for bugs and feature requests for the helper libraries. If you need help or support, please email help@twilio.com and one of our experts will assist you!

3.32.0

Feature Request

The ability to add headers to an API request with the product helper utilities would provide support for those that need custom headers like X-Twilio-Webhooks-Enabled.


// example of the feature request

const client = twilio('SKxxxx', 'xxxx', {
  accountSid: 'ACxxxx'
});

await client.chat
  .services(serviceSid)
  .channels(channelSid)
  .messages.create({
    body: `This was created by the API. It's ${moment().format('HH:mm:ss')}`,
    from: author,
    headers: {
      "X-Twilio-Example": "Foo" 
      "X-Twilio-Header": "Awesome Value",
      "X-Twilio-Webhooks-Enabled": "true"
   }
});
childish-sambino commented 5 years ago

For reference: https://www.twilio.com/docs/chat/webhook-events#triggering-webhooks-for-rest-api-events

childish-sambino commented 5 years ago

This issue has been added to our internal backlog to be prioritized. Pull requests and +1s on the issue summary will help it to move up the backlog.

eshanholtz commented 4 years ago

The fix for this issue will be included in the next release on 12/4.

CatalinVoss commented 4 years ago

@eshanholtz Is this documented somewhere?

CatalinVoss commented 4 years ago

For confused souls of the future, the field is called xTwilioWebhookEnabled:

twilioClient.chat
  .services(your TWILIO_CHAT_SERVICE_SID)
  .channels(your channel)
  .messages.create({
    from: author,
    body,
    ...
    xTwilioWebhookEnabled: true,
  });