How to integrate Nylas Scheduler to your user flow

4 min read

Intro

We’re excited to announce the launch of the Nylas Scheduler. Earlier this year, we launched the Nylas API v3.

Supporting in-app user scheduling is a must-have for products and services. Examples of features include sharing availability, booking appointments, managing meetings, coordinating teams.

This blog post is an overview of how to add scheduling functionality to your user flow using the Nylas Scheduler!

Overview of Nylas Scheduler

Let’s break down the different features available in the Nylas Scheduler before we add the Nylas Scheduler to our user flow. The Scheduler is broken down into three core features:

  • Scheduler Editor UI to manage scheduling pages
  • Scheduling UI for end-users to book appointments
  • Scheduler API for programatically creating and configuring scheduling pages

The Nylas Scheduler UI supports all frontend frameworks including vanilla HTML. We provide out-of-the-box web and react components for adding the Scheduler UI to your front-end application.

In the following section we will take a look at adding the Nylas Scheduler to a React application.

Getting started with Nylas v3

Here are the steps to get started:

  1. Sign up for a Nylas account for free!
  2. Create a new application, using our sandbox environment to skip adding a connector step. The sandbox environment allows for easy access to our APIs and is not recommended to use for going to production:
  1. Take note of the applications ID, Client ID, which we’ll use as NYLAS_CLIENT_ID in our application:

Before continuing to the next section, we will need to set up hosted authentication so we can access users’ calendar to share availability in the Scheduler. Take a look at this section in our developer documentation on setting up hosted authentication using our sandbox environment.

Now we’ve configured Nylas and next will add the Scheduler to our React application using the npm package @nylas/react.

Setting Up Nylas Scheduler

Now let’s setup the Nylas Scheduler in our frontend application. All the code can be found here.

We’ll be adding the scheduler to a react application, so all code that follows will be for a React frontend. We will consider two different frontend paths:

  • /scheduler-editor will be where an admin user can create and manage schedulers, where NYLAS_SCHEDULER_CONFIGURATION_ID represents each Scheduler created
  • /?config_id=NYLAS_SCHEDULER_CONFIGURATION_ID where the Scheduler will be displayed for a user to book time slots

Here is the React code for displaying both the Scheduler Editor and Scheduler:

import { NylasSchedulerEditor, NylasScheduling } from "@nylas/react";

function App() {
  // Get the configuration ID from the URL query string
  const urlParams = new URLSearchParams(window.location.search);
  const configId = urlParams.get("config_id") || "";

  return (
    { 
      configId.length > 0 ? (
      <div>
        <NylasScheduling
          configurationId={configId}
          schedulerApiUrl="https://api.us.nylas.com" 
        />
      </div>
      ) : (
      <div>
      <NylasSchedulerEditor
        schedulerPreviewLink={`${window.location.origin}/?config_id={config.id}`}
        nylasSessionsConfig={{
          // Replace with your Nylas client ID from the previous
          clientId: "NYLAS_CLIENT_ID",
          redirectUri: `${window.location.origin}/scheduler-editor`,
          domain: "https://api.us.nylas.com/v3",// or 'https://api.eu.nylas.com/v3' for EU data center
          hosted: true,
          accessType: 'offline',
        }}
        defaultSchedulerConfigState={{
            selectedConfiguration: {
              // Creates a public configuration which doesn't require a session
              requires_session_auth: false, 
              scheduler: { 
                // The callback URLs to be set in email notifications
                // The URL of the email notification includes the booking reference
                rescheduling_url:`${window.location.origin}/reschedule/:booking_ref`, 
                cancellation_url:`${window.location.origin}/cancel/:booking_ref`
              }
            }
          }}
        />
      </div>
    )}
  );
export default App;

Ensure to replace the NYLAS_CLIENT_ID with the Client Id from the Nylas dashboard. For now, we’ve only shared the rescheduling and cancellation URLs as part of the email notification sent out, however, the React frontend for those pages is not part of the above code.

In addition to using the Scheduling Editor and Scheduler user interface, developers can consider programmatically managing the Scheduler using our Scheduler API.

Now we’ve added the Scheduler to our application to both manage scheduler configurations and also allow users’ to book time slots:

Build Time

In this blog post, we explored how developers can add the Nylas Scheduler to build powerful scheduling functionality. Using the Scheduler API developers can enhance user workflows and deliver a seamless scheduling experience.

You can sign up for Nylas for free and start building! Continue building with Nylas by exploring different quickstart guides or by visiting our developer documentation.

Related resources

How to build a CRM in 3 sprints with Nylas

What is a CRM? CRM stands for Customer Relationship Management, and it’s basically a way…

How to create an appointment scheduler in your React app

Learn how to create an appointment scheduler in your React app using Nylas Scheduler. Streamline bookings and UX with step-by-step guidance.

Beyond APIs: Designing elegant, smart Web Components

Dive into the world of smart Web Components for advanced API integration solutions. Design elegant, customizable elements to elevate user experiences.