Custom integrations with external systems

Sprintful supports "Custom Integrations", which is the ability to write code snippets (NodeJS) that are triggered on events (on_booking, on_cancel, on_reminder). There are many use cases when this capability comes in handy, for example:

  • Write records to your internal system, or trigger internal workflow
  • Integrate with external (non-natively supported) tools your organization might be using
  • Trigger webhooks or events based on logic (for example, only if the user email is "xyz.com")

Note that this feature is available on the Business and Enterprise Plans for approved use cases, specifically, simple HTTP GET/POST to legitimate targets and within a reasonable frequency. Check below for more details and sample code. 

  

How do I access Custom Integrations?

To access the feature, go to Dashboard > Integrations > New Integration, and from there, choose "Custom Integration". You will be prompted with a simple code editor where you can type in code (in simple NodeJS). Hit "Test" to test the code, and observe the output underneath to confirm whether your code was successfully run. 

Make sure you hit "Save" after you make any changes. Sharing this integration with your organization will trigger the integration for all organization members.

  

What data is available in the context of the code?

Code being run inside "Custom Integration" has access to two objects ("event" String, and "payload" Hash).

var event = String; // possible values: "on_booking", "on_cancel", "on_reminder"

var payload = {

id: String,

url: String,

page_name: String,

page_slug: String,

meeting_name: String,

description: String,

location: String,

date_from: DateTime,

date_to: DateTime,

timezone: String,

attendee_name: String,

attendee_email: String,

attendee_cell: String,

sub_page_names: [], # array of Strings, sub-pages names (if team-booking page)

sub_page_slugs: [], # array of Strings, sub-pages slugs (if team-booking page)

form: [], # array of objects, form questions and their answers

}

Note that the payload object may contain more information than what is displayed above. Some of these attributes may be empty or null depending on the actual events.

Sample code #1: RequestBin

1) Find a requestbin or equivalent (example: https://requestbin.com/)2) Create a custom integration and paste the code snippet below, replace the `url` variable with the address you were given from requestbin, then click on "Test"

var url ='<your-requestbin-address>';

payload.event = event; // add event name to payload hash

payload.page_name = "MASKED"; // mask page name

needle.post(url, payload, {}, function(err, resp, body) {

// done!

});

That's it! note how in the second line we masked some data. We could also run any logic or transformation before posting.

Sample code #2: Airtable

In this exercise, we will post all events to an Airtable table that we own. Follow the steps below:

1) Create an Airtable document and prepare a table within that document. See the picture below. 

  1. Note down the "Base ID" of your table (marked as #1 in red). You will need this in step 3 when you adjust the code snippet. In the picture, the Base ID is "appXXX".
  2. Note down the "Table Name" of your table (marked as #2 in red). You will need this in step 3 as well. In the picture, the "Table Name" is "Table 1".
  3. Confirm that the column names in the table exactly match the "fields" object you will be submitting in the HTTP call in step 3. This is case-sensitive and must fully match the object you submit.

2) Create an Airtable personal token (see screenshot for scope and permissions), specify a table that the token has access to

3) Paste the code below after replacing (a) the token ID with your personal token, and (b) the base ID AND table name.

var url ='https://api.airtable.com/v0/<base-id>/<table-name>'; // two replacements: base-id, table-name

var token = '<your-token>'; // replace: your token

var options = {

headers: {

'Authorization': `Bearer ${token}`,

'Content-Type': 'application/json',

}

};

var data = {

"fields": {

id: payload.id,

event: event,

page_slug: payload.page_slug,

attendee_name: payload.attendee_name,

attendee_email: payload.attendee_email,

date_from: payload.date_from,

date_to: payload.date_to,

}

};

needle.post(url, data, options, function(err, resp, body) {

// done!

});

Still need help? Contact Us Contact Us