Build an AI-Powered Learning App with Gemini and GuidedTrack
Google’s Gemini is one of the fastest and most cost-effective AI models available today. It handles complex reasoning, follows detailed instructions reliably, and generates personalized responses at scale, making it a great fit for GuidedTrack programs that need to process a high volume of participant responses quickly.
This tutorial walks you through a concrete example: a participant writes about something they’ve been curious about, and Gemini responds with a short, engaging explanation tailored to what they wrote, including a surprising fact and a question to spark further exploration. But the underlying pattern is the same whether you want the AI to generate personalized quiz feedback, turn a participant’s free-text response into a structured summary, suggest resources based on what someone is interested in, explain a concept at a reading level matched to the audience, or do almost anything else with language. Once you understand how to connect Gemini to a GuidedTrack program, you can adapt it to a huge range of applications.
What You’ll Need
- A Gemini API key (from aistudio.google.com)
- A GuidedTrack account with Custom Services enabled
Step 1. Generate a Gemini API key
Log in to Google AI Studio at aistudio.google.com, or sign up for a free account if you don’t have one. Once signed in, click Get API key, then Create API key. Copy the key and store it somewhere safe, you’ll need it in the next step.
Step 2. Create and configure your GuidedTrack program
If you already have a GuidedTrack account, go here to login. If you don’t have a GuidedTrack account yet, go here to create one for free! Now, go to your programs page in GuidedTrack, and create a new GuidedTrack program and name it whatever you like.
Select Settings on the navigation bar, go to the Services tab and click on “+ Add external service”:

Use these values to fill in these fields:
| Name | Gemini API |
| URL | https://generativelanguage.googleapis.com/v1beta |
Add a header with the name x-goog-api-key and the value [your API key]. Click Save.

Step 3. Write your GuidedTrack program
Here’s a complete example, a curiosity-driven learning tool that takes a topic the participant wants to understand better and returns a short, engaging explanation from Gemini:
*question: What's one thing you've been wanting to learn about lately?
*type: paragraph
*save: curiosity_text
>> prompt_for_gemini = "You are an enthusiastic teacher who loves making ideas accessible. The person wrote this about something they want to learn: '{curiosity_text}'. Give them a short, engaging explanation that builds their curiosity. Include one surprising fact and end with a question that encourages them to explore more. Keep it under 150 words."
Please wait, generating your response...
*service: Gemini API
*path: /models/gemini-2.5-flash:generateContent
*method: POST
*send: { "contents" -> [ { "parts" -> [ { "text" -> prompt_for_gemini } ] } ] }
*success
>> raw_from_gemini = it["candidates"]
>> content_from_gemini = raw_from_gemini[1]["content"]
>> part_from_gemini = content_from_gemini["parts"]
>> text_from_gemini = part_from_gemini[1]["text"]
*error
>> error_with_ai = 1
>> full_error_message = it
*wait: data
*clear
*if: error_with_ai
The AI had an error.
Full response including error: {full_error_message}
Please report this bug.
*if: not (error_with_ai)
*You wanted to learn about:*
{curiosity_text}
*Here's something to get you started:*
{text_from_gemini}
How the code works
The program runs in three stages.
Stage 1 – Collect input
The program prompts the participant to describe something they have been wanting to learn about. The participant’s response is saved in curiosity_text. The program then constructs prompt_for_gemini, which combines the participant’s input with instructions for Gemini to provide a short, engaging explanation, including a surprising fact and a question to encourage further exploration. While GuidedTrack processes the request, the participant sees “Please wait, generating your response…”
*question: What's one thing you've been wanting to learn about lately?
*type: paragraph
*save: curiosity_text
>> prompt_for_gemini = "You are an enthusiastic teacher who loves making ideas accessible. The person wrote this about something they want to learn: '{curiosity_text}'. Give them a short, engaging explanation that builds their curiosity. Include one surprising fact and end with a question that encourages them to explore more. Keep it under 150 words."
Please wait, generating your response...
This is what the user will see:


Stage 2 – Call the API
The *service block sends the participant’s input to Gemini’s generateContent endpoint. The request uses prompt_for_gemini as the input. On success, the response is parsed in several steps:
- The candidates are stored in raw_from_gemini,
- the content is extracted and stored in content_from_gemini,
- the response parts are stored in part_from_gemini,
- and the generated text is then extracted and stored in text_from_gemini.
If the API call fails, error_with_ai is set to 1, and the full error response is stored in full_error_message for further handling.
*service: Gemini API
*path: /models/gemini-2.5-flash:generateContent
*method: POST
*send: { "contents" -> [ { "parts" -> [ { "text" -> prompt_for_gemini } ] } ] }
*success
>> raw_from_gemini = it["candidates"]
>> content_from_gemini = raw_from_gemini[1]["content"]
>> part_from_gemini = content_from_gemini["parts"]
>> text_from_gemini = part_from_gemini[1]["text"]
*error
>> error_with_ai = 1
>> full_error_message = it
Stage 3 – Display the result
*wait: data ensures the API response and updated variables are fully synced before the program continues. *clear removes the loading message. If an error occurred during the API call, the participant is shown an error message along with the full error response. Otherwise, the participant sees the topic they wanted to learn about followed by the response generated by Gemini.
*wait: data
*clear
*if: error_with_ai
The AI had an error.
Full response including error: {full_error_message}
Please report this bug.
*if: not (error_with_ai)
*You wanted to learn about:*
{curiosity_text}
*Here's something to get you started:*
{text_from_gemini}
This is what the user will see:

Adapting This for Your Use Case
The same pattern works for any scenario where you want Gemini to respond to something a participant wrote:
- Wellbeing check-ins: Ask participants how they’ve been feeling this week and have Gemini suggest one small, evidence-based activity to try based on their response.
- Habit journaling: Participants describe a habit they’re working on, and Gemini generates a personalized three-day micro-plan based on what they wrote.
- Open-text summarization: Collect free-text responses across multiple questions and use Gemini to generate a plain-language summary of each participant’s overall input.
- Prompt variations: Adjust Gemini’s output format, reading level, or tone by modifying the instruction text. Everything about how Gemini responds is controlled there.
Also Read
Build an AI-Powered Personal Coaching App with ChatGPT and GuidedTrack
Build a Psychology Reflection Tool with Claude and GuidedTrack
Use GuidedTrack to Build a ChatGPT-Style Web App with the OpenAI API
The basic of using *service to embed other apps and tools
