One of the most powerful ways to integrate with Appointlet is by using webhooks.  If you've ever wanted a custom action to occur after someone books with you, or keep your database in sync with what's happening in Appointlet, webhooks can make it happen.

If you aren't familiar with how webhooks work, you'll want to check out this handy guide from our friends at SendGrid.

What events do webhooks fire for?

We'll send webhooks for a variety of events, such as new bookings, cancelations, and even non-booking events such as when you create/delete/update a meeting type, member or field. Webhooks are fired for many events, you'll want to make sure you inspect the payload to know which event type you're dealing with.  More on that below.

How do I setup my webhook URL in Appointlet?

Once you have your webhook URL in hand, you'll need to register it with Appointlet so we know how to reach you.  You can do this by going to "Settings" > "Webhooks" > "Add".

What does the webhook request look like?

The request we send to your registered URL will come in the form of an HTTP POST. The payload will be stored in the body as a JSON-encoded blob.

Here is a sample of what that payload will look like (you can also use a service like requestbin to setup a URL that will help you inspect the payload):

{
   "id":1,
   "type":"booking",
   "action":"confirmed",
   "meta":{},
   "organization":1,
   "date_created":"2014-01-01T00:00:00Z",
   "object":{
      "id":"BOOKING_ID",
      "timezone":"US/Pacific",
      "email":"webhooks+sample@appointlet.com",
      "start":"2014-01-01T00:00:00Z",
      "end":"2014-01-01T00:00:00Z",
      "date_created":"2017-06-29T20:00:05.810173Z",
      "confirmed":true,
      "canceled":false,
      "reminder1_sent":false,
      "reminder2_sent":false,
      "reminder3_sent":false,
      "follow_up_sent":false,
      "conference_data":null,
      "conference_provider":null,
      "utm_campaign":null,
      "utm_content":null,
      "utm_term":null,
      "utm_source":null,
      "utm_medium":null,
      "payment_refunded":"0.00",
      "payment_identifier":null,
      "payment_currency":null,
      "payment_amount":"0.00",
      "payment_account":null,
      "url":"https://salon-demo.appointlet.com/booking/BOOKING_ID",
      "service":{
         "id":1,
         "category":null,
         "name":"Meeting Type 1",
         "description":"",
         "image":null,
         "duration":1800.0,
         "currency":"USD",
         "price":"0.00",
         "deposit":"0.00",
         "tax":"0.00",
         "manual_confirm":false,
         "cancelation_notice":0.0,
         "reschedule_notice":0.0,
         "minimum_notice":3600.0,
         "maximum_notice":5184000.0,
         "pooled_availability":false,
         "location_type":null,
         "location":null,
         "slug":"meeting-type-1"
      },
      "organization":{
         "id":1,
         "name":"Organization 1",
         "language":"en-us",
         "image":"https://ucarecdn.com/7228fc98-0863-4cb3-bec7-96668ebcadae/-/stretch/off/-/resize/x100/",
         "bookable_type":"member",
         "bookable_type_plural":"members",
         "service_type":"meeting type",
         "service_type_plural":"meeting types"
      },
      "bookable":{
         "id":1,
         "name":"Member 1",
         "description":"",
         "image":"",
         "timezone":"US/Pacific",
         "conference_phone":null,
         "rel":{
            "available_times":"https://api.appointlet.com/bookables/1/available_times"
         },
         "slug":"member-1"
      },
      "fields":[
         {
            "field":{
               "visible":true,
               "id":1,
               "kind":"CharField",
               "slug":"first-name",
               "kwargs":{
                  "max_length":100,
                  "required":true,
                  "label":"First Name"
               }
            },
            "value":"John"
         },
         {
            "field":{
               "visible":true,
               "id":2,
               "kind":"CharField",
               "slug":"last-name",
               "kwargs":{
                  "required":true,
                  "max_length":100,
                  "label":"Last Name"
               }
            },
            "value":"Smith"
         },
         {
            "field":{
               "visible":true,
               "id":3,
               "kind":"CharField",
               "slug":"phone-number",
               "kwargs":{
                  "help_text":"Please include area and country code.",
                  "required":true,
                  "max_length":100,
                  "label":"Phone Number"
               }
            },
            "value":"+1.888.555.1212"
         }
      ],
      "rel":{
         "reassignable_bookables":"https://api.appointlet.com/bookings/BOOKING_ID/reassignable_bookables",
         "confirm":"https://api.appointlet.com/bookings/BOOKING_ID/confirm",
         "add_to_outlook_calendar":"https://api.appointlet.com/bookings/BOOKING_ID/add_to_outlook_calendar",
         "add_to_google_calendar":"https://api.appointlet.com/bookings/BOOKING_ID/add_to_google_calendar",
         "reschedule":"https://api.appointlet.com/bookings/BOOKING_ID/reschedule",
         "ics":"https://api.appointlet.com/bookings/BOOKING_ID/ics",
         "reassign":"https://api.appointlet.com/bookings/BOOKING_ID/reassign",
         "cancel":"https://api.appointlet.com/bookings/BOOKING_ID/cancel"
      }
   }
}

Take special note of the type  and action  attributes as they will tell you what event this webhook is related to.  If, for example, you only need to take action after new bookings, make sure type === 'booking'  and action === 'confirmed' .

Why am I not receiving my webhook?

If you are expecting webhooks and they aren't coming in, here are a few things to check:

  • Make sure you have your URL entered correctly.  You can click the "Test" button next to it and we'll send a small payload ({"test":true} ) to the URL to make sure it's routing correctly.
  • Ensure that you're looking at the request's body for the JSON payload and not in your web framework's POST variables (e.g. $_POST)
  • Check your HTTP server logs to see if the requests are getting to your server. They might be getting that far but not all the way to your view or .php file.
  • Remember you can't receive webhooks in your local development environment as it's not web accessible.

Related Articles: 

Capture UTM Parameters

Passing UTM Parameters

Export Bookings

Did this answer your question?