cal.com icon indicating copy to clipboard operation
cal.com copied to clipboard

[CAL-1141] Add new events to webhook BOOKING_PAID, BOOKING_CONFIRMED, BOOKING_REJECTED

Open alishaz-polymath opened this issue 2 years ago β€’ 13 comments

Add new events to webhook, namely:

  • BOOKING_PAID | When a booking has been paid for successfully
  • BOOKING_REQUESTED | When an opt-in booking is made (not yet confirmed)
  • BOOKING_REJECTED | When an opt-in booking is REJECTED

From SyncLinear.com | CAL-1141

alishaz-polymath avatar Feb 23 '23 14:02 alishaz-polymath

Currently, BOOKING_CREATED is triggered once a booking is confirmed. So this would be changed then, that it already triggers once a booking that requires confirmation is booked, right? Do we have any concerns here for already existing webhooks with BOOKING_CREATED triggers?

CarinaWolli avatar Feb 23 '23 16:02 CarinaWolli

Yeah, that's a very good point. We should avoid changing BOOKING_CREATED and instead maybe use BOOKING_REQUESTED for the booking that isn't confirmed yet

alishaz-polymath avatar Feb 23 '23 17:02 alishaz-polymath

I'm thinking about handling this one.

Do you have any guidance or a place where I can start?

wesleymatosdev avatar Apr 30 '23 18:04 wesleymatosdev

Is this just adding to the enum?

Josh-Archer avatar May 01 '23 00:05 Josh-Archer

@ologbonowiwi Thank you for looking into this πŸ™Œ You do need to update the schema and add enum as @Josh-Archer mentioned, but that would only add it at the Database level.

enum WebhookTriggerEvents {
  BOOKING_CREATED
  BOOKING_RESCHEDULED
  BOOKING_CANCELLED
  FORM_SUBMITTED
  MEETING_ENDED
  BOOKING_PAID
  BOOKING_REQUESTED 
  BOOKING_REJECTED 
}

The next step would be to update the codebase to identify which hook should fire at what point. This would primarily be in the booking handler. Finally, these would need to be added to the webhook form to store them as webhook triggers.

Please pay close attention to the migration to make sure it doesn't destroy any existing webhooks πŸ™

All the best! πŸŽ‰

alishaz-polymath avatar May 03 '23 07:05 alishaz-polymath

I'm excited to help with the project and this issue seems perfect for me. I noticed that no one has claimed it yet. @alishaz-polymath Can I take this up and work on it over the weekend? I'll send you a PR as soon as possible.

shivamklr avatar May 06 '23 06:05 shivamklr

I added the BOOKING_PAID webhook. Can you take a look @alishaz-polymath?

Thank you!

wesleymatosdev avatar May 06 '23 07:05 wesleymatosdev

@alishaz-polymath I have added Booking Rejected webhook to the codebase. Let me know if this is what we are expecting. The issue is still under progress though. Moreover, I am hoping to add a test for the same with playwright as well. Let me know your thoughts on the same.

shivamklr avatar May 08 '23 13:05 shivamklr

@alishaz-polymath @PeerRich I have a two questions,

  • Do we fire the Booking_Requested Webhook when a slot with event type, confirmation required, is created?

  • If the above it true, what will be the type of data sent in the webhook?

shivamklr avatar May 08 '23 23:05 shivamklr

@alishaz-polymath @PeerRich I have a two questions,

* Do we fire the Booking_Requested Webhook when a **slot** with event type, confirmation required, is created?

YES πŸ™

* If the above it true, what will be the type of data sent in the webhook?

Essentially the same payload as confirmation, except with the booking status being PENDING

alishaz-polymath avatar May 09 '23 08:05 alishaz-polymath

~~@alishaz-polymath I guess we can use sendGenericWebhookPayload for BOOKING_REQUESTED webhook then. https://github.com/calcom/cal.com/blob/94917dbb1ec002f49c9dd2cfed3eeadb323279dd/packages/features/webhooks/lib/sendPayload.ts#L128~~

shivamklr avatar May 09 '23 11:05 shivamklr

Hi @alishaz-polymath , I noticed that @ologbonowiwi has implemented the BOOKING_PAID EventTrigger in the source code. I have also added the BOOKING_REQUESTED and BOOKING_REJECTED events in the handlers. I have created a PR for this and I would appreciate your feedback on my code. Please let me know if there are any issues that need to be fixed. Thank you

shivamklr avatar May 14 '23 16:05 shivamklr

Hey @shivamklr Thanks a lot for your PR. I'm currently OOO but I'll review it as soon as I can. I'm also certain one of the team members would probably review it very soon. πŸ™

alishaz-polymath avatar May 14 '23 17:05 alishaz-polymath