๐Ÿ”ŒWorking with data sources

Methods for connecting and working with data sources in Databutton apps

You'll often want to connect to and utilize a data source via API in your Databutton app. This could be for several cases (non-exhausted list):

  • AI workflows/automation for manual tasks that are related to data in one or many systems

  • AI-aided business intelligence or dashboarding

  • Content generation based on data in a system

  • Building a chat interface on a knowledge base or other systems of record

Most data sources you need to use will require an API Key, Personal Access Token, Service Credentials, or a similar concept in order to utilize it. Because Databutton capabilities, or backends, are built on Python, you will be able to use almost any data source in your app.

Below, we give an example of working with Airtable. This method of prompting, connecting, and utilizing will work for most sources. Over time, we'll have more content for specific sources. If there are any data sources or APIs you are struggling to work with, make sure to reach out on Discord or using the Intercom chat bubble inside the product.

Start with a capability

You might need to create a new capability, or may already have a relevant placeholder capability generated via earlier discussion with Databutton. The scope of your capability can simply be retrieving data from a source, but you can also have another intent such as doing data operations, filtering the results, doing some AI magic with it, and more.

In this example, we will connect to Airtable and discuss ideas with Databutton on what to do.

Connect to the API

First, describe your intent and Databutton will come up with a plan. If you already know how Airtable's API key and Base IDs work, you can just let it know.

Communication is the key to solving your problem. If you have a question, ask Databutton, and Databutton will try to help you.

OK great, so I go and generate a key from Airtable. Turns out they have deprecated API keys and only have personal access tokens now, but the advise still led me the right way.

Once I create a token, I just let Databutton know and we're good to go. Databutton asks for your token and stores it securely.

And you can even have Databutton extract the information it needs sometimes. I provide a URL here and Databutton gets the base ID and table ID needed to proceed.

Alright, after a little back and forth, we're now connected to a specific Airtable base and table! It's important to remember that while Databutton is amazing, it isn't always perfect. You might need to help sometimes.

Working with the source

Now that we're connected, the world is our oyster. We can do anything that is possible in code. This table has a bunch of example IT projects as synthetic data. Each row is a project.

Let's do something silly as an example โ€“ come up with a sassy description for each project, generated by GPT3.5 Turbo. We need to describe what we want to do and supply an OpenAI API key.

Once we have the key in, Databutton writes the code necessary to generate sassy descriptions. It runs it on one row first.

From here, you can:

  • Generate descriptions for all rows and display them in an app UI

  • Generalize the capabiity such that it accepts other base IDs and table IDs

  • Use the Airtable connection in an entirely new capability

It all depends on what your goal is with this data and who will be using your app!

Last updated