如何从 Calendly webhook 获取举办活动的用户?

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

我收到来自 Calendly 的 invitee.created webhook,其中包含受邀者详细信息。我需要获得对主持该活动的 Calendly 用户的引用,以便我可以在我的应用程序中报告它(例如,跟踪与特定用户预订的会议)。我该怎么做?

如果您需要知道哪个 Calendly 用户(或用户,对于 collective events) the event was booked with, you need to call Get Eventevent_memberships 数组将包含用户引用 (URI) 列表。下面是更详细的步骤指南.

  1. 您收到了事件 invitee.created 的 webhook。 The payload 看起来像这样:
{
  "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": "test@example.com",
    "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
  }
}

这里的payload对象就是被邀请人预定的Invitee. It has an event field that is a reference to the Event

  1. webhook_data.payload.event 进行 GET 调用 - 这将是 Get Event 操作。响应将如下所示:
{
  "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": []
  }
}

上述有效载荷中的event_memberships数组是安排事件的一组用户(如果是集体事件,可以是多个)。然后,您可以对这些用户 URI 执行 GET 操作,或者将这些 URI 与您之前保存在数据库中的 URI 进行比较。