prashant isotiya
prashant isotiya

Reputation: 199

How to get User who hosts the event from a Calendly webhook?

I'm receiving an invitee.created webhook from Calendly, which contains Invitee details. I need to get a reference to the Calendly User that hosts the event, so that I can report on it in my application (e.g. keep track of meetings booked with a specific user). How do I do that?

Upvotes: 2

Views: 1363

Answers (1)

Dmitry Pashkevich
Dmitry Pashkevich

Reputation: 13546

If you need to know which Calendly User (or Users, for collective events) the event was booked with, you need to call Get Event. The event_memberships array will contain a list of User references (URIs). Below is a more detailed step by step guide.

  1. You received a webhook for the event invitee.created. The payload looks something like this:
{
  "created_at": "2020-11-23T17:51:19.000000Z",
  "created_by": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA",
  "event": "invitee.created",
  "payload": {
    "cancel_url": "https://calendly.com/cancellations/AAAAAAAAAAAAAAAA",
    "created_at": "2020-11-23T17:51:18.327602Z",
    "email": "[email protected]",
    "event": "https://api.calendly.com/scheduled_events/GBGBDCAADAEDCRZ2",
    "name": "John Doe",
    "new_invitee": null,
    "old_invitee": null,
    "questions_and_answers": [],
    "reschedule_url": "https://calendly.com/reschedulings/AAAAAAAAAAAAAAAA",
    "rescheduled": false,
    "status": "active",
    "text_reminder_number": null,
    "timezone": "America/New_York",
    "tracking": {
      "utm_campaign": null,
      "utm_source": null,
      "utm_medium": null,
      "utm_content": null,
      "utm_term": null,
      "salesforce_uuid": null
    },
    "updated_at": "2020-11-23T17:51:18.341657Z",
    "uri": "https://api.calendly.com/scheduled_events/GBGBDCAADAEDCRZ2/invitees/AAAAAAAAAAAAAAAA",
    "canceled": false
  }
}

Here, the payload object is the Invitee. It has an event field that is a reference to the Event that the Invitee booked.

  1. Make a GET call to webhook_data.payload.event - this will be the Get Event operation. The response will look like this:
{
  "resource": {
    "uri": "https://api.calendly.com/scheduled_events/GBGBDCAADAEDCRZ2",
    "name": "15 Minute Meeting",
    "status": "active",
    "booking_method": "instant",
    "start_time": "2019-08-24T14:15:22Z",
    "end_time": "2019-08-24T14:15:22Z",
    "event_type": "https://api.calendly.com/event_types/GBGBDCAADAEDCRZ2",
    "location": {
      "type": "physical",
      "location": "Calendly Office"
    },
    "invitees_counter": {
      "total": 0,
      "active": 0,
      "limit": 0
    },
    "created_at": "2019-01-02T03:04:05.678Z",
    "updated_at": "2019-01-02T03:04:05.678Z",
    "event_memberships": [
      {
        "user": "https://api.calendly.com/users/GBGBDCAADAEDCRZ2"
      }
    ],
    "event_guests": []
  }
}

The event_memberships array in the above payload is an array of Users with whom the event is scheduled (can be more than one, if it's a collective event). You can then do a GET on these User URIs or just compare these URIs with what you've previously saved in the database.

Upvotes: 4

Related Questions