Back to Blog

Dialogflow and Airtable Database

If you're not familiar with Airtable yet, I highly recommend looking at this service. Airtable is not just an alternative to Google Sheets, but a full-fledged database that integrates very easily with any service, including Dialogflow.

Using Airtable, you can implement a data collection system of any complexity (order taking, customer accounting, etc.). Additionally, Airtable will replace your CRM and content management system. Instead of creating hundreds of intents in your chatbot, you can place all the content in a convenient tabular form in Airtable, and the chatbot will read information from the database and quickly form a response.

Surprisingly, Airtable is easier to "befriend" with Dialogflow than Google Sheets. It's no more complicated than Firebase, which I also wrote about in the blog.

Let's start by creating a simple test database. Airtable's free tier allows us to create an unlimited number of databases, but no more than 1200 records in each. This will be enough for simple projects.

So, for example, I created a database with one table (Table1) with the following structure:

  • Name
  • Email
  • Message
  • Location

The chatbot will receive contact data from the user and enter it directly into the database.

Let's return to Dialogflow and create a test intent where we'll request the necessary data from the user. I'll make three parameters for now.

Blog post image

Don't forget to activate the "Enable webhook call for this intent" parameter to pass intent processing to the server function.

We leave the Response empty because we'll generate it in the server function as well.

Initialization

And, actually, the program code in the Fulfillment section. We connect the "airtable" package, initialize the database:

var base = new Airtable({apiKey: 'API_KEY'}).base('API_BASE_NAME');

where API_KEY is your personal key that needs to be generated here https://airtable.com/account