Use Airtable as a database for your chatbot

Bastien Botella
Clevy.io
Published in
3 min readJun 18, 2020

Building a chatbot often rhymes with creating conversations and it usually boils down to understanding the user intent, getting the chatbot to ask a question, and basically going down a decision tree to eventually get some informations about the user, but where do we store these gathered datas now ?

The obvious answer would be to get a Mysql or Mongodb database on a server somewhere and interact with it. This idea sure is the way to go when build a big project that needs to scale to millions of rows but more often than not we just need a few thousands rows at most, to store some user datas (answers to a survey for instance).

That’s when Airtable comes into play!

Airtable allows you to quickly create spreadsheets that can be used as databases for your chatbots.

How to use Airtable with CSML ?

The CSML studio offers some plug-and-play apps. Let’s have a look and see how that works.

Step 1: Create a database on Airtable

First sign in or create an account on the Airtable if you don’t already have one, there is a free plan that’s perfect! Create a new database. For the sake of this exercise we will create a table to manage subscriptions to an event. So here are the 3 fields of our database’s only table: first_name, last_name, email.

Step 2: Get your API key, database id and table name

To get your API key, go to https://airtable.com/account, copy the API key and keep it safe!

Then go to https://airtable.com/api, click on your database and then on the table you want to use (in the sidebar), the database id and table name are in the url as follow: https://airtable.com/{DATABASE_ID}/api/docs#curl/table:{TABLE_NAME}

Step 3: Create your chatbot

Let’s build a small chatbot that we’ll use to register people to an event.

To do so, sign in or create a free account on the CSML Studio. Create a new chatbot and paste the code below.

This 30 lines chatbot will:

  • ask the user his/her first name, last name, email
  • check the email address contains a “@”
  • save the user on Airtable

Make sure you replace the spreadsheet_id (also called database id) and the table name.

Build the chatbot by clicking on the “Build” button on the top right of the window.

Step 4: Install the Airtable App

Click on the “Functions” link in the sidebar, then on “Apps directory” in the topbar and on the Airtable box. Go down to the bottom of the modal, enter the api key in the input box and then install the app.

Step 5: Test and deploy

That’s it! Now you can come back to the editor, click on “Build and run” to make sure everything works fine and as you finish the conversation with the chatbot, you’ll see the informations being sent to Airtable.

If you want to go a step further and deploy your chatbot, click on “Channels”, we got a Webapp that is available with a single click install.

If anything goes wrong, you can join our Slack to get support from our team and the CSML community made of hundreds of chatbot developers.

--

--