This post was written by Ryan Mercer, Salesforce Consultant at Kicksaw, and last updated on 3/23/21.
Here at Kicksaw, we pride ourselves on being experts at integrating tools into Salesforce. From Outreach to DocuSign to Conga, we’ve got tons of experience getting your other systems hooked into Salesforce so that you can not only hit the ground running, but be in line with best practices at the same time.
One of the tools we see our customers use regularly is Calendly, which offers super slick appointment scheduling software. Calendly plays quite well with the other tools in your tech stack through several integrations, including Salesforce.
The managed package that Calendly ships with its Salesforce integration is simple: one object CalendlyAction__c, one process builder OnCalendlyActionCreated, and two flows CreateEvent and CancelEvent. When someone books an appointment with you, Calendly creates one CalendlyAction__c record. When a CalendlyAction__c record is created, the process builder launches one of two flows: either the CreateEvent flow if it’s a new appointment or the CancelEvent flow if the appointment is canceled.
Much of the automation happens during the CreateEvent flow. Though their flow is a bit unwieldy, it is certainly functional.
Here’s the bird’s eye view of what happens during the flow:
In addition to Calendly mapping a bunch of standard, expected fields into Salesforce (such Event End Time and Event Start Time), it also maps four custom questions that you can specify in the Calendly UI.
A word of warning from Calendly themselves:
Be sure to ask identical questions in the same order for each event type to ensure the fields update correctly.
When Calendly automatically creates the CalendlyAction__c record (and launches the flow), it maps the four questions and responses to these fields.
Let’s say you have a custom field on the Event object Budget__c. When creating the Event record at the very end of the flow, you can assign the value of CustomResponse1 to Budget__c, and the newly created record will have $1,000,000 in the Budget field.
Now, let’s say you have a second event type (or a third or a fourth) that asks a different set questions. Sounds likely, right? You’re going to run into immediate issues creating your new Event records.
Take this event type as an example.
Pair it with the associated CalendlyAction__c record.
You can now see why Calendly notes to “be sure to ask identical questions in the same order for each event type to ensure the fields update correctly.” Your newly created Event record will have my LinkedIn URL (CustomResponse1) in the Budget field.
To solve this problem, please enjoy this nugget of Apex code.
Sure, Apex code is great, you say, but how do I use it?
First, create custom fields on the CalendlyAction__c object to EXACTLY MATCH the Calendly questions. Create one custom field for each unique question. For example, if your Calendly question is “LinkedIn URL”, that must be the exact label of the custom field you create.
Because there is a 40 character limit for Salesforce field labels, your Calendly questions will also be restricted to 40 characters. The custom fields MUST BE of types Text or Text Area.
Open the CreateEvent flow and create a new variable called calendlyOutput.
Add an action immediately after Start and before the first SFID Provided? decision.
Use the calendlyOutput variable to assign other fields. For example, calendlyOutput.LinkedIn_URL__c can be mapped to wherever you’d like to warehouse that data in Salesforce.
In my example, I created custom fields on the Event object to store each piece of data and added the mappings to the final Create Event element.
Now my Candidate Events in Salesforce look like this:
And my Sales Events look like this:
BOOM! 💥 All Calendly custom field data is where it’s supposed to be in Salesforce!
Want to take the Apex test class so that you can deploy to production? Connect with Ryan on LinkedIn and send me a message. Hope to hear from you!