Skip to main content

Calendly to Slack

Send a Slack notification when a Calendly event is booked

Post in Slack each time an event is booked through Calendly

Steps in this guide:

  1. Create a Superblocks Workflow
  2. Create a Calendly REST API integration
  3. Create a webhook in your Calendly account
  4. Connect Superblocks to Slack
  5. Use Python to parse data

Connect Calendly to Slack with a Superblocks workflow

Create a Superblocks Workflow

  • Create a new Workflow in your account.
  • Scroll down to the Trigger Workflow section and grab the workflow UUID and authorization token as we'll need these in the next step for creating a webhook in Calendly.

Use Authentication tokens to authenticate with third party services

Create a Calendly REST API integration

Content-Type: application/json
Authorization: Bearer <YOUR_CALENDLY_AUTH_TOKEN>
  • Click Create Integration.

    Create REST Integration to Calendly

Create a webhook in your Calendly account

Follow the Calendly docs for setting up a webhook within your Calendly account. This webhook will invoke your Superblocks workflow every time someone books an event within your Calendly organization. Note that this can only be done via the API. Here's a sample POST request, please modify to fit your specific use case:

curl --request POST \
--url https://api.calendly.com/webhook_subscriptions \
--header 'Authorization: Bearer <YOUR_CALENDLY_AUTH_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"url": "https://app.superblocks.com/agent/v1/workflows/<YOUR_SUPERBLOCKS_WORKFLOW_UUID>?sb-auth=<YOUR_SUPERBLOCKS_AUTH_TOKEN>",
"events": [
"invitee.created"
],
"organization": "https://api.calendly.com/organizations/<YOUR_CALENDLY_ORG_UUID>",
"scope": "organization"
}'
info

You can leverage the get current user endpoint to find your Calendly User UUID and Organization UUID.

Connect Superblocks to Slack

  • Create an app and webhook in Slack.

  • Create a new REST API integration in Superblocks.

  • Set the "Display Name" to the Slack channel you want to post into.

  • Update the "Base URL" to https://hooks.slack.com/services/YOUR_SLACK_WEBHOOK_URL.

  • Click Create Integration.

    Create REST API Integration to Slack webhook

Use Python to parse data

In your workflow, you'll now create multiple steps to parse through the incoming payload and feed some of that back through the Calendly API to enrich the slack post with metadata.

Step 1 - parseEventUUID
  • Create a python step.
  • Rename the step parseEventUUID.
  • Use the following code to parse out the event UUID from the incoming payload:
event = body.payload.event.split("/") #split across the / to make a list
return event[4] #pull the uuid from this position, the URL is static
Step 2 - getEventDetails
  • Create a step using the Calendly REST API.
  • Rename the step getEventDetails.
  • Use GET as the method.
  • Set the "URL Path" as scheduled_events/{{parseEventUUID.output}}. This takes the output of our python script in step 1 and dynamically updates the get request with the Event UUID.
  • Set the params as:
scope: organization
organization: https://api.calendly.com/organizations/<YOUR_CALENDLY_ORG_UUID>

Call REST services from Superblocks API steps

Step 3 - getEventInvitees
  • Create a step using the Calendly REST API.
  • Rename the step getEventInvitees.
  • Use GET as the method.
  • Set the "URL Path" as scheduled_events/{{parseEventUUID.output}}/invitees.

Get Calendly invitees

Step 4 - parseEventInviteesDetails
  • Create a python step.
  • Rename the step parseEventInviteesDetails.
  • Use the following code to parse out any custom answers from your Calendly sign up form:
user_details = ["Not provided", "Not provided", "Not provided", "Not provided"] #needs 4 in the list, this is hardcoded in postToSlack step

for idx, item in enumerate(getEventInvitees.output.collection[0].questions_and_answers):
if item.answer:
user_details[idx] = item.answer
else:
continue

return user_details
info

You'll need to customize this section to match the formatting of your sign up form.

Step 5 - parseUserUUIDandTime
  • Create a python step.
  • Rename the step parseUserUUIDandTime.
  • Use the following code to parse out the event UUID from the incoming payload:
import time

user = getEventDetails.output.resource.event_memberships[0].user.split("/") #split across the / to make a list

struct_time_event = time.strptime(str(getEventDetails.output.resource.start_time), '%Y-%m-%dT%H:%M:%S.%fZ')
mktime = time.mktime(struct_time_event)
readable_time = time.ctime(mktime)
return [user[4],readable_time] #pull the uuid from this position, the URL is static
Step 6 - getUserDetails
  • Create a step using the Calendly REST API.
  • Rename the step getUserDetails.
  • Use GET as the method.
  • Set the "URL Path" as users/{{parseUserUUIDandTime.output[0]}}.

Get user details from Calendly with REST API step

Step 7 - postToSlack
  • Create a step using the Slack REST API.
  • Rename the step postToSlack.
  • Use POST as the method.
  • Update the "JSON Body" with the text you want to be posted into slack. Here's a sample body:
{
"text": "*Date*: {{parseUserUUIDandTime.output[1]}} \n *Assigned to*: {{getUserDetails.output.resource.name}} \n *Attendee(s)*: {{getEventInvitees.output.collection[0].name}} - {{getEventInvitees.output.collection[0].email}} \n *Company Name*: {{parseEventInviteesDetails.output[0]}} \n *Number of Employees*: {{parseEventInviteesDetails.output[1]}} \n *Estimated Number of Superblocks Creators*: {{parseEventInviteesDetails.output[2]}} \n *How are you building internal tools now?*: {{parseEventInviteesDetails.output[3]}}"
}
info

Similar to Step 4, you'll need to customize the JSON body based on the formatting of your Calendly sign up form.

And here's what the final result looks like for each new event booked!

Generate Slack messages from event bookings with Superblocks workflows