twilio-labs / plugin-webhook

Twilio CLI plugin to emulate webhook requests from Twilio
MIT License
10 stars 2 forks source link

Add more event types #4

Open dkundel opened 2 years ago

dkundel commented 2 years ago

Right now the only two event types that are supported are:

Other's that would be helpful to have are:

How to create new event types

  1. Start a local webserver (it doesn't really have to do anything)
  2. Start up ngrok and connect it to the local webserver
  3. Setup your ngrok URL as webhook for the webhook trigger you try to emulate
  4. Trigger the event
  5. Open http://127.0.0.1:4040 to inspect the incoming headers & request payload
  6. Create a copy of the utils/webhook-events/sms.js file and name it <eventName>.js for example whatsapp.js.
  7. Enter the data that you've seen in the incoming request for headers and request payload into the file. Make sure to replace actual data with mock data. For example replacing phone numbers or changing SIDs
  8. Add your event type to the options array for the type flag inside the src/commands/webhook/invoke.js file.
meeraj257 commented 2 years ago

@dkundel - i would like to work on this issue. Needed clarification on step 4 above. When you say - Trigger the event - did you mean say for example - whatsapp event? How do i trigger that? - Thanks

philnash commented 2 years ago

@meeraj257 to trigger a WhatsApp webhook you would need to setup the WhatsApp Sandbox (or your own WhatsApp number if you have one) to deliver webhook events to the ngrok URL that you created in step 2.

Then send a message to the WhatsApp number which will trigger the event and cause Twilio to send the webhook request to your URL so you can inspect the incoming parameters in step 5.

meeraj257 commented 2 years ago

@philnash - thanks for the info. I will start working on this issue. Pls assign to me.

philnash commented 2 years ago

Assigned!

meeraj257 commented 2 years ago

@philnash - i got the event samples for whatsapp and mms. Is sync referring to syncing sms msgs to other devices - for e.g - sharing same apple Id - for iOS?

philnash commented 2 years ago

Sync refers to the product Twilio Sync.

meeraj257 commented 2 years ago

@philnash @dkundel - I have raised the PR for this issue. Pls review