build-Booking-chatbot-tutorial

This handy tutorial will teach you how to build a booking chatbot in Landbot. The best part is, this bot will be able to control the number of signups for each time slot.

A use case scenario that can be leveraged in anything from online webinars, one-on-one calls, meeting room bookings to restaurant reservations.

All of this, without coding or any unnecessarily complex integrations.

Watch the video for a sneak peek of the final result:


1. Set up Your Registration Google Sheet


Before you start building your booking chatbot, you need a datasheet to hold the information about dates, time-slots, and seat availability.

Go to Google Drive and create a spreadsheet with relevant information.

Note: Ensure the date format is YEAR-MONTH-DAY otherwise the bot will have trouble recognizing it.

booking-bot-time-slots-spreadsheet

Next, set all the slot values to 0 to indicate the number of signups per slot.

All done!


2. Create a New Bot in Landbot


This step is mainly for those new to Landbot, so if you know, your way around, skip ahead!

The rest of you, go to your Landbot dashboard and click “Build a Chatbot”. Select format and when the screen with templates leads, choose to start from scratch.

You’re ready to go.


3. Ask Users for the Date


Customize your Welcome block and proceed to ask the users for the date.

To achieve that, select the designated “Date” block which automatically ensures the selected date is in a correct format as well as saves user choice under the @date variable.

Select format YEAR-MONTH-DATE.

set-up-date-block


4. Set Up Google Sheet Integration to Retrieve Data


Now is the time to integrate your spreadsheet.

Draw a green arrow from the green bubble on the Date block and select “GoogleSheets” integration.

To set up a connection with the file select:

  • Google Drive account on which the sheet is stored
  • Name of the File
  • Name of the Sheet within the file

Then, configure the type of action you want to take (insert, retrieve or update the data). At this stage set the option to “Get data from sheet”.

reservation-chatbot-get-data-from-spreadsheet-integration

This action triggers a search in a row (line) of your spreadsheet, based on the column you have selected as a reference (Reference Column).

Hence, when a user selects a particular date, the bot proceeds to retrieve the information about slot availability in that corresponding row.

To bring that data from the spreadsheet to Landbot, you need to associate each Column name with a variable that will store that information.

In our case, “Date” column will be associated with an already existing @date variable. For the time slots, I created new numeric variables with relatable names so it doesn’t get confusing.

google-sheet-block-variable-set-up

For instance, the value in column “Slot A (9am-11am)” will be stored under @slot_a and will represent the number of signups per slot on a given date.

Click SAVE and move on!


5. Make a Setup to Create an Array


Now, you need to set up a whole new variable using “Set a Variable” block called @array.

Sure, an “array” is a term used in programming but don’t let that put you off. It’s a term used to describe a data structure, which can store “a collection of elements of the same data type”.

Just think of it as a collection of variables of the same type.

If the variable in question is an email, it would be a collection of emails. In this case, the array will be a collection of data on the number of participants per slot on a specific date.

So, to set it up, create that variable and in the “Type of Value” field simply enter two square brackets.

set-a-variable-array

You need to leave the value of the array empty because it will be created in the following steps by checking the data from the spreadsheet.

Why do you need this?

The array will communicate which slots are still empty and so enable your booking chatbot to display a dynamic number of buttons based on availability.


6. Configure Conditional Block to Limit Number of Seats


Next, you need to set up the conditions that determine whether a slot is or isn’t available.

Our cutoff is 6 participants. Hence, I created a condition for each of the four slots as follows:

IF @slot_a IS LESS THAN 6, the slot is available – bot follows the green output. If it equals 6 –  if the condition is not true – the bot follows the pink output and moves on to check the next slot.

booking-chatbot-conditional-logic-setup

But what happens, when the slot is available? After all, the green arrow also loops back to check every slot.

So, what happens in between?


7. Define Formulas to Collect Data for the Array Variable


When a condition deems the slot available, we need an action that pushes this data (the name of the slot and its current value) into the @array.

For that, we need to use Formulas. This block lets you design complex operations with values inside Landbot, and save the result in an outcome variable.

It’s very similar to formulas on other platforms Excel or Google Spreadsheets.

Formulas may seem tricky at first but they are actually really handy and absolutely worth mastering. The trickiness is mainly the consequence of the sheer quantity of different formulas available and how incredibly many things they can do. But don’t worry about it for now. To make this work you only need a couple.

  • For programmers, this means they no longer need to go to extra servers to build these operations and then having to bring them back in.
  • For no-coders, this means they are actually able to do the sophisticated operations which were only possible through coding before.

Anyway…

When the condition is met and the flow proceeds through the green output, we need to use a formula to pass this info to the @array variable in an acceptable format.

The complete set up will look like this. Each green output passes through a formula before proceeding to check the next slot availability.

set-up-formulas-to-form-array-landbot

There are two key sections to successfully set up the Formulas block. The output and the actual formula.

Tip: Scrolling down the Formulas block settings, you will discover a library of formulas and actions you can achieve with these formulas.

landbot-formulas-tips-section

Our output will be @array.

formula-outputAs per the second key field, we will use a complex formula which is a formula that encompasses another formula inside it.

formuals-set-up-landbot

It does look a bit offputting, but let me break it down!

I am using:

  • “Push” formula to “push” the name of the slot and its value to the @array;
  • “ToJSON” formula to store that data. (JSON is just a fancy programming name for a human-readable text that stores data in the form of values and arrays.)

Merged together, they look complex:

Push(@array,ToJSON('{"slot_name":"Slot A (9am-11am)","amount":"@{slot_a}"}'))

But what it really is:

  1. Push(@array)
  2. ToJSON(‘{“slot_name”:”Slot A (9am-11am)“,”amount”:”@{slot_a}”}’)
  3. Push(@array,ToJSON(‘{“slot_name”:”Slot A (9am-11am)”,”amount”:”@{slot_a}”}’))

Translated into no-code language: Store this data in @array.

JSON clarifies which part of the information is the slot name and which is the amount. To modify it, just substitute the bold passages with the name of your column and the name of your variable.

That reminds me, you need to make sure that each formula has the slot name and variable that correspond with the condition that precedes it. So, formula following @slot_b condition block would look like this:

formulas-setup-example-2

OK! You did it! The hardest part is behind you!


8. “Clean” Your Array


Before we move on to the fun part of setting up the dynamic buttons you need to clean your array of any “debris”-

In other words, we need to get rid of the first “value” we had to assign to the @array variable to activate it in the first place – the two brackets with nothing in it – they would just cause trouble.

To do that, I used another fun formula called Slice. It basically lets you slice pieces of collected data away.

slice-formula-to-clean-array

Tip: Slice comes in handy when you want to hide part of the information; E.g., when you only want to show the last 4 digits of users’ credit card; just a part of the email address to verify identity; etc.

So, I created a new output for our “clean” array called @arraydef. And, following the instructions in the bottom section of the Formulas settings, I configured it to slice away the first input – the brackets. (To put things in context, have I written Slice(@array, 2) it would have sliced away the first two array inputs.)

slice-array-formula-setup


9. Eliminate Dead Ends


Next, you need to take care of the impending dead end – you don’t want to have these in the conversation flow.

To deal with the instance that no slots are left available on a selected date, I set up one more condition but this time more complex.

For it to be true ALL of the slot variables must be equal to 6 – in other words, fully booked.

The true (green) output sends the user to the message block which informs them that no slots are available and loops back to the “Date” so the user can try availability on a different day.

close-dead-ends-in-conversational-flow

If it’s not true – meaning AT LEAST ONE of slots has a smaller value, the flow continues to the array-cleaning Formulas block.

Now we can move on!


10. Configure Dynamic Data Block


The dynamic data block is the whole reason we needed to store our data as an array because we only want the user to see buttons (options) that are actually available.

To set up the block:

  • Define the question for the user
  • Insert the array variable you want to display in this block
  • Make sure the array type is set to “OBJECTS”
  • Set “Show data as” to “buttons” option

dynamic-data-booking-chatbot

Next, define text for the button and the value you want to store. To do that use the same format you saw in the JSON formula: slot_name

set-up-dynamic-data-block-buttons

And, ultimately, create the variable under which you want to store the users’ answer.
save-dynamic-data-block-user-choice


11. Do The Math (Conditions + Calculations)


Ok, so far, we have managed to provide the user with only the relevant options and let him or her choose the time slot they prefer.

That’s great but it’s not over.

We need to update the spreadsheet with every new participant.

The good news is that after all we have been through here, this is just a piece of cake!

So, the next step involves setting up a condition and the following calculation for each of the four timeslot options:

booking-bot-conditional-logic-landbot

I decided to base the condition on whether the users’ answer – @slot – equals to the names of the columns in the spreadsheets: Slot A (9am-11am), Slot B (2pm-4pm), Slot C (4pm-6pm), Slot D (6pm-8pm).

IF @slot EQUALS TO Slot A (9am-11pm) THEN proceed to calculation.

However, at this point, you can choose the condition that best fits your needs. For example, check if the user’s answer CONTAINS a specific phrase/letter/number etc.

When the answer doesn’t match the condition, the bot follows the pink route to check the next option and the next until it finds a match.

The green output leads the bot a “Set a Variable” block which we’ll use to add value to the variables representing the columns in the spreadsheet:

@slot_a
@slot_b
@slot_c
@slot_d

reservation-chatbot-set-a-variable-calculation

For instance, when @slot contains “Slot A (9am-11am)”, the bot sums the existing value of @slot_a + 1, etc.

Repeat the calculation for each option and we are ready to get this new data back to the spreadsheet we started with!


12. Update Your Spreadsheet


It’s time for the Google Spreadsheet integration once and again.

You can set it up all over, or do the smart thing and just copy the initial block and drag the copy to the right spot!

The only thing you need to change (or do differently) in the configuration is to change the action from “Get Data” to “Update a Row”.

booking-chatbot-google-sheet-integration-update-data

The reference column, as well as the column-variable pairing, remain the same.

Now, every new choice will reflect on the spreadsheet.


13. Wrap it Up!


And we did it, it’s time to wrap it up!

final-block-reservation-confirmation

I just threw in a lame goodbye message, but you can do so much more:

  • Enrich the conversation flow at the beginning to provide more information about the course or answer frequently asked questions about the booking.
  • Extend the dialogue to gather user data such as name, email, age, phone number, etc.
  • Make the dynamic choice more visual with cards instead of buttons
  • Throw in some more complex formulas to make it even better

I’m not gonna pretend this bot can handle thousands of booking requests but it’s a booking chatbot anyone can build in about an hour.

So whether you are

  • Running a webinar
  • Teaching an online course
  • In need of booking chatbot to schedule one-on-one meetings with potential clients or students
  • Trying to improve your lead generation
  • Looking for a booking system so people don’t queue for hours in front of your brick-and-mortar shop…

This is it! Your way to provide superb customer service as well as gain the personal assistant you always wanted 😁.

It’s super quick and, once you get into it, extremely easy.

Not all bots need artificial intelligence to be smart!

When you do build your own booking system, make sure to share it with us on social media!

Related Post