Create and Share Your AI Spreadsheet Generator in Minutes

Create and Share Your AI Spreadsheet Generator in Minutes

March 1, 2024

This tutorial will guide you through building an AI spreadsheet generator in Tablesmith. This pipeline generates a personalized 3-day meal plan based on your dietary preferences, complete with recipes, ingredients, and nutritional information.

You can also take a look the final shared pipeline directly. The following shows the first row in the generated CSV file.

diet day meal recipe_name ingredients nutrition_per_serving
Vegan Day 1 Breakfast Tofu Scramble with Roasted Vegetables tofu, turmeric, cumin, garlic powder, onion powder, salt, black pepper, olive oil, bell peppers, onions, zucchini, cherry tomatoes, spinach, nutritional yeast. “FAT: 10g”, “PROTEIN: 15g”, “CALORIES: 250”

Get Started

Before you begin, you’ll need to log in or create a Tablesmith account. Since this pipeline uses AI features, it requires tokens to run. New accounts receive 5,000 free tokens. If you need more, join the Tablesmith Discord and send a direct message for an additional 50,000 tokens.

Once logged in, click the “Add/+” button to create a new pipeline. Give it a descriptive name/description that reflects its purpose. Remember, this name and description will be visible if you share the pipeline.

Adding User Input Variable

We want users to choose their diet before generating the meal plan. Let’s add a variable named “Diet.” Set the variable type to “Text” and enable “Select from options” to create a dropdown menu. Here, add the various dietary options you want users to choose from.

Adding Diet Column

Let’s create a column in the output spreadsheet to display the user-selected diet. Add an “Add Column” stage. You can choose a name or leave it as the default stage type.

Click “Select Stage Type” and choose “Add Column” from the popup window. In the stage settings tab, enter a column name like “diet” Set the value of this column to a formula. Click the input box and open the formula editor. Select the “Diet” variable we created earlier and click “Save”.

Adding Day and Meal Columns

We’ll need columns to show the days (Day 1, Day 2, etc.) and meals (Breakfast, Lunch, Dinner) in the plan.

For the Day column, add an “Add Column” stage. Choose “Formula” as the value type and use the following formula: "Day " + TOTEXT(QUOTIENT(SEQUENCE(0,1),3)+1) This formula generates a sequence of numbers (1, 2, 3) and prefixes them with “Day”.

For the Meal column, follow the previous steps and use the formula: SEQPICK("Breakfast","Lunch", "Dinner") This formula picks a sequence of text options from a list, cycling through “Breakfast,” “Lunch,” and “Dinner”.

Generating Recipe Names with AI

Now comes the exciting part - using AI for autofill!

Add an “Add Column” stage and choose “AI” as the value type. Click the input box to open the prompt editor. This column will contain recipe names that match the user’s diet and meal selection, and they should be unique to avoid duplicates.

To include diet and meal information in the prompt, input an “@” sign to show column/var selector. After entering your prompt, navigate to the “Config & Test” tab and set the maximum output tokens to 50. This ensures the AI generates only a simple name, preventing lengthy text.

Important Note: To prevent duplicate recipes, enable column context awareness for this stage. Think of it like asking a question “Generate a recipe” followed by follow-up questions “Generate another one”. The AI considers the previous content in its responses.

Here’s how to enable context (columns/variables are wrapped in [] for display purposes only. Use the @ symbol when entering prompts):

[FIRST]
I need a meal plan. My Dietary Restriction is: [diet]. Return day 1 breakfast recipe's name only, no formatting or explain.
Example Output: Mapo Tofu
[END]
Return day [day] [meal]'s recipe name only, no formatting or explain.

The text between [FIRST] and [END] is the initial prompt for the first cell in this column. The text after [END] is used for subsequent rows, ensuring unique recipes for each entry.

Generating Recipe Ingredients with AI

With recipe names in place, let’s use AI to generate ingredients for each recipe. Include the diet in the prompt to ensure ingredients align with the user’s dietary restrictions.

Here’s the prompt:

I'm [diet], show me Ingredients of this recipe: [recipe_name], no formatting or explain.
Format: <ing1>,<ing2>

Tip: Enable “Save row context” in the “Basic Settings” tab for this stage. This eliminates the need to include the ingredients in the next stage.

Generating Nutritional Information with AI

Finally, let’s leverage AI to generate nutritional information based on the ingredients. Since we saved context from the previous stage, we can simply ask for the information.

Here’s the prompt:

Nutrition per serving of this recipe, return CALORIES, FAT, PROTEIN info only without explain. Format: "FAT: 2g"

Adding an Output

We’ve finished setting up the pipeline stages. Now, let’s add an output.

  • Switch to the “Output” tab.
  • Click “+ Add Output” and choose your desired format.
  • Give it a clear name and select the columns you need. You can also reorder them here.

Testing the Pipeline

To ensure each stage works correctly, use the “Test” button in the “Stages” tab. Clicking “Test” on a stage runs the pipeline up to that point.

The first time you click “Test” on any stage, you’ll see the input settings dialog, just like when you run the entire pipeline.

  • Click the “Test” button next in the “Day” stage.
  • Since we don’t need an input file for this test, choose “Empty Table.”
  • Enter a small number of rows to generate for testing purposes (e.g., 2).
  • Click “Next” to proceed.
  • Select a diet option and click “Next” to see the test results.

You might notice a bar at the top of the page that displays “Empty” or a filename. This bar indicates the current test input configuration.This configuration is specific to the “Stages” tab and disappears when you switch tabs. You can also detach it manually by clicking the delete button. Remember, test results are internal to Tablesmith and don’t reflect applied output configurations like hidden columns or number formatting. Now let’s testing the “Nutrition” Stage:

Running the Pipeline

Click the “Run” button to execute the entire pipeline. You’ll see the input configuration again. This time, enter a higher row count (e.g., 9) and click “Next.”

  • A list of stages will appear. Click “Start” and wait for all stages to complete.
  • You can then preview or download the resulting file.

Sharing the Pipeline

Finally, share your pipeline! Click the “Share” button (three connected circles) and select “Share with link.”

Enable “Share this pipeline” to reveal the share link. This link becomes active after saving. Change the input type to “Empty Table (fixed row count)” as you don’t require user input and the output has a fixed row count (9). Copy the link, click “Save,” and try it in your browser!

Last updated on