Conversational AI
  • Introduction
  • Getting started
    • Getting started
    • Adding content to your bot
    • Capture information with entities
    • Capture information with input validation
    • Reusing intents with context
    • Flow navigation with variables
    • Adding new users to your account
  • Understanding users
    • Natural Language Processing (NLP)
      • NLP threshold
      • NLP Import & Export
      • Train your bot with actual user messages
      • NLP Dashboard & NLP Improve
      • Synonym entities
      • System entities
      • Supported languages
      • Intent templates
    • Expression generator
    • Context
    • Multi-language bots
  • Bot answers
    • Bot dialogs
      • Message components
      • Go To
      • Input Validation
      • Action
      • Translations
    • Conversations
    • Analytics
      • User flow
    • Publishing your bot
    • Events
    • Reuse flows
    • Settings
      • Variables
  • Integrations
    • API integration
      • Advanced API integrations
    • Chat message structure for API's
    • Retrieving data from Airtable (GET)
    • Sending data to Airtable (POST)
    • Human handover & live chat
      • #Interact
      • RingCentral Engage Digital
      • Genesys Cloud
      • Help Scout
      • Zendesk Chat
      • Intercom
      • Sparkcentral (beta)
      • Offloading Webhook
  • Channels
    • Channels
    • Facebook Messenger
      • Facebook Admin Removal
      • Facebook Webview Whitelisting
    • WhatsApp Business API
    • Google Assistant
    • Webhook Channel API
    • Chat widget
    • Phone & voice
    • Workplace from Facebook
    • Sinch Conversation API (beta)
  • Tips & Best practices
    • How to NLP
    • Creating diverse expressions
    • Why is my bot not responding the way I want it to?
    • What makes a good chatbot?
    • How to recognize a returning bot user
    • Gathering user feedback
    • Using time in your chatbot
Powered by GitBook
On this page

Was this helpful?

  1. Integrations

Retrieving data from Airtable (GET)

PreviousChat message structure for API'sNextSending data to Airtable (POST)

Last updated 4 years ago

Was this helpful?

Bots are often used to show data from external sources to your user. An easy way to manage this data is by using . Airtable is a tool that allows you to create a spreadsheet that you can talk to with an API.

In this tutorial we will set up an integration with Airtable. Because of all the code it looks quite technical, but in fact it's pretty easy.

If you're new to using variables in Chatlayer.ai, follow tutorial first.

As an example we're going to be building a bot that shows information about chatbot meetups.

  • The first thing we have to do is create some meetup data. In this example, we will be using . Feel free to reuse it!

  • Start by building a short flow that states the purpose of the bot and that asks about which month the user wants to know meetup info.

  • Configure the action bot dialog that is triggered after the input validation with a code plug-in. Add the "month" variable as an argument, as shown in the screenshot:

  • Next, add this code snippet:

const { month } = args;

const { records = [] } = await fetch(
  "https://api.airtable.com/v0/(yourAppId)/(yourTableName)",
  {
    method: "GET",
    headers: {
      Authorization: "Bearer (insert token here)",
    },
  }
).then((res) => res.json());

const found = records.filter((rec) => rec.fields.Month === month.toLowerCase());

const builder = ChatlayerResponseBuilder();

if (found.length) {
  builder.setSessionVariable("meetups", found);
} else {
  builder.setSessionVariable("nomeetups", found);
}

builder.send();
  • This code block searches the table for a meetup in the month that the user said, and if it finds one, returns that information to Chatlayer.ai. If there is no meetup found, the nomeetups variable is saved to the session of the user.

  • If you follow the flow to this point, it will look something like this:

  • And the following data is saved on the session:

  • Now all we need to do is show that data! Add a Go To at the end of the Action bot dialog where you have added the code block.

  • Configure this Go To as following:

  • This way, the user will get a different response if there are no meetups in the month that they've asked about.

  • Finally, configure the messages in "show meetup info" to show the retrieved info from the Airtable sheet.

  • All done! You can now test the full flow.

For the month question, make sure you're using an that saves the response as themonth variable and that continues to the next step: an action bot dialog.

Remember to get the right app id, table name and bearer token for your Airtable. You can find it .

input validation
here
Airtable
this
this Airtable