How to generate ideas with OpenAI’s GPT-3 automatically

How to generate content with OpenAI’s GPT-3 and Baserow

The rise of artificial intelligence has led to the disruption of sectors and reshaping how we function. AI has already demonstrated its vast potential to boost performance and output in many industries, learning from data we input and carrying out functions that were previously only performed by humans.

Generating new ideas can help you approach a challenge or opportunity from a different angle. An excellent growth hack for quickly coming up with new ideas is integrating OpenAI with Baserow. You can ask a question, come up with a title for a blog post, or get assistance in formulating a response to a message.

With a relational database like Baserow, you can organize your data in a structured way with the familiarity of a spreadsheet interface. However, Baserow databases are far more powerful than traditional spreadsheets, and can handle larger amounts of data. If you haven’t already, try one of our 60+ templates to help quickly create databases for your website, CRM, apps, or CMS.

What we’ll do

This tutorial will show you how to integrate OpenAI’s GPT-3.5 and GPT-4 with Baserow. We will set up automation to generate new and innovative ideas from new topics added to a table, without leaving the database.

These are the steps we’ll take:

integrate OpenAI’s GPT-3.5 and GPT-4

What we’ll need

We will integrate no-code tools to create ideas stories, business plans, character descriptions, and marketing slogans.

These are the tools we need:

Make.com (formerly Integromat) is an automation tool that lets you connect different apps and services to automate workflows and repetitive operations.

The OpenAI API is powered by a diverse set of models with different capabilities which include language models that can understand and generate text: GPT-4, GPT-3.5 and GPT-3. ChatGPT is an AI chatbot that uses GPT-3’s language model to interact with humans in a conversational way.

By the end of this tutorial, you’ll have a fully automated workflow to create ideas stories, business plans, character descriptions, and marketing slogans, saving you time and effort. We’ll demonstrate how to use Make to prompt GPT-3 to generate text automatically depending on a given prompt in a Baserow table.

1. Set up a Baserow database

First, log into Baserow. Then, create a workspace by selecting the + Create workspace button in the dashboard.

Name your workspace, and select the Add workspace button.

Once you’ve created a workspace, add a database from scratch to the newly-created workspace.

When you create a new database from scratch, a new table will be created. The database contains key tables for our idea generation.

In this tutorial, we will create a Baserow database called “Idea generation” and within it, are two tables. One for qualifying prompts (Table A - Topics) and the other for generated ideas (Table B - Ideas).

Create table A - Topics

In table A, we want to add the list of topics and prompts. Add the following fields to the table:

Field name Field type
Topics Single line text
Prompt Formula

We want to use the formula field to dynamically create creative prompts based on our Topics field to brainstorm some ideas on a topic or question.

Create table A - Topics

The prompt serves as an instruction and makes it clear the list of ideas we want to generate.

Giving the model a clear and specific prompt to write about will help it produce more focused and relevant content. Brainstorm new ideas for creative content, messaging or marketing campaigns.

Create table B - Ideas

We’ll use the help of OpenAI and Make to use our topics or questions from table A to generate 5 creative ideas in our Ideas table.

In table B, we want to populate the list of generated ideas and link to the corresponding rows in table A. Baserow provides a graphical interface that allows users to create tables and define relationships easily. Add the following fields to the database table:

Field name Field type
Ideas Single line text
Prompt Link to table

Create table B - Ideas

2. Create a database token

Within your Baserow user account, you can create multiple unique database tokens that allow Baserow to connect with other apps. You can create and find the database token under your account settings.

  1. Go to your profile, then navigate to your ‘Settings’ page
  2. Click on the ‘Database tokens’ tab
  3. Click on the ‘Create token +’ button
  4. Write a descriptive name for the token, and select the existing workspace that you want to tie the token to
  5. Click on the ‘Create token’ button to create a new database token for the selected workspace and for the authorized user.

Create a database token

Database tokens provide similar functionality to login credentials, but they provide additional security and flexibility. A token, like your username and password, should be kept secure and handled with the utmost confidentiality.

Creating database tokens is available to all Baserow users; you don’t need to be on a paid plan.

3. Generate an OpenAI API key

OpenAI endpoints can be used for various tasks such as content or code generation, summarization, expansion, conversation, creative writing, style transfer, and others. OpenAI API uses API keys for authentication.

Create a free OpenAI account. After logging in, click on the account tab at the top right corner of the screen. Then select “View API keys” from the menu options to retrieve the API key we’ll use in our requests.

Generate an OpenAI API key

Remember that your API key is a secret. Do not share it with others or expose it in any client-side code.

Next, we want to make requests via Make (formerly Integromat).

4. Add Baserow module to watch new rows

We want OpenAI to produce a list when prompted. Once we have our list, we can populate these ideas as new rows on Baserow.

To get started, create a new Make account or log into your existing account. Then create a scenario and add modules to the scenario.

  1. Select the app that will trigger your scenario. Click the first “+” sign and select Baserow as the trigger app.
  2. Choose one of the actions from the list. In this case, select the ’Watch Created Rows’ action. This triggers the workflow when new rows are created in a table.
  3. Create a connection or select a previously configured connection from the dropdown options. To create a new connection:
    1. Enter your Baserow API URL. Find your Baserow API URL in your API documentation. If you are using SaaS version baserow.io, the default URL is https://api.baserow.io, otherwise, replace the URL with your self-hosted URL.
    2. Enter your Database token. Find your Database Token in Account → Settings → Database tokens as directed in step 2 above.
  4. Enter the table ID of table A. Find the Table ID by clicking on the three dots next to the table. It’s the number between brackets.
  5. Click “OK” to save this module and “Run once” to test the connection.

You should get a response back that resembles the following:

Add Baserow module to watch new rows

Now, let’s brainstorm some ideas related to a topic whenever a new row is added to a table.

5. Add OpenAI module to create a completion

Next, we will pass the command into a field to run an API request. The API will generate a list of ideas from the instructions or context in the Prompt field.

  1. Click the “+” sign and select OpenAI (DALL-E & ChatGPT) as the action app.
  2. Choose one of the actions from the list. In this case, select the ’Watch Created Rows’ action. This creates a completion for a provided prompt or chat.
  3. Create a connection or select a previously configured connection from the dropdown options.
    1. Create an API key at https://beta.openai.com/account/api-keys
    2. Get your organization ID at https://beta.openai.com/account/org-settings
  4. Select the Method as ‘Create a prompt completion’.
  5. Select the Model as GPT-3.5’s ‘text-davinci-003’ - recommended to complete tasks with higher quality, longer output, and better instruction-following.
  6. Map the command to generate completions from the Prompt field in the Baserow module.
  7. Show advanced settings and assign a figure to the N field to set how many completions to generate for each prompt. For this tutorial, we will set the N field as 5. This will make the AI deliver 5 unique ideas for our topic. Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for max_tokens and stop.
  8. Click “OK” to save this module and “Run once” to test the connection.

Add OpenAI module to create a completion

This will create an array of 5 results.

6. Add the iterator module

Now we have the results with an array. Because we want to generate a row for each idea, we need to loop through all AI responses to create new rows.

Make’s Iterator module is a special type of module that converts an array into a series of bundles. Each array item will be outputted as a separate bundle.

The goal of iteration is to prompt Make to populate all of the ideas from a single prompt to Baserow in a single operation, regardless of the number of ideas generated. As a result, this step automatically loops through all the responses to create a Baserow row for each response.

If the name of a piece of data in Make ends in brackets like this: [ ], that indicates that the data is represented as an array. In this case, “Choices” is an array, as you can see in the screenshot below, so we can input it into the array field.

  1. Click the “+” sign and select Flow controlIterator as the app.
  2. Select the ‘Choices’ array from the OpenAI module. The Array field contains the array to be converted/split into separate bundles.
  3. Click “OK” to save this module and “Run once” to test the connection.

Add the iterator module

7. Add the Baserow module to create new rows

The iterator won’t take any actions by itself. Any modules added after the iterator will instead execute once for each item in the array. Next, we want to populate table B with the ideas generated.

We’ll use the same database as in the first Baserow module. But, the table ID will be the one we want to store the AI ideas generated.

  1. Click the “+” sign and select Baserow as the app.
  2. Select the ’Create a Row’ action. This creates new rows.
  3. Select the previously configured connection from the dropdown options.
  4. Enter the table ID where the row will be created in (table B). Find the Table ID by clicking on the three dots next to the table. It’s the number between brackets.
  5. Map the ‘Ideas’ from the Flow control - Iterator module.
  6. Map the ‘Related row ID’ from the Baserow module.
  7. Click “OK” to save this module and “Run once” to test the connection.

Add the Baserow module to create new rows

8. Test & schedule the Make scenario

Our scenario is set up and ready to activate, but we may still need to run a quick test. Run the scenario, Make will load the prompt and store the data in the Baserow database.

The Iterator will split the array of results into single bundles, each bundle with one result will then be added one at a time in the selected table.

Let’s jump back to Baserow. Check your Baserow table B for the responses and there are five new creative ideas! The related row will also be populated in the linked table A.

Test & schedule Scenario

Specify when and how frequently an activated scenario runs. To do so, go to the scenario detail page and locate the Schedule tab or click on the clock icon to set a preferred schedule.

To set the schedule, adjust the Run scenario to set the time when it should run.

Test & schedule Scenario

Save and activate the scenario by toggling on the scheduling switch at the bottom left corner. Now that the automation is set up, you can create new topics in table A to generate ideas immediately, without leaving your database.

Key takeaways

Using the API to connect to our favourite apps helps us get the most out of Baserow, extending customization and functionality. You can send prompts, receive responses, and generate new ideas or versions of topics by integrating OpenAI and Baserow.

Organisations stand to gain significantly from AI automation. Still, it is helpful to carefully assess its effects and make sure that people continue to play a crucial role in business processes. While some processes may be automated, like with any new technology, people still play an essential part in designing, deploying, and maintaining these systems.

Make/Integromat workflow

If you run into an issue while following the tutorial, feel free to reach out to ask for help in the Baserow community.

What’s your use case? Tell us how you use Baserow