[Example] Retrieving data from Airtable (GET)
Last updated
Was this helpful?
Last updated
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.
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 block 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:
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 block 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 block.
Want to learn more about the possibilities of the Code plug-in? You can find it .
Remember to get the right app id, table name and bearer token for your Airtable. You can find it .