Building Adaptive Learning Agents with A2UI, Gemini, and Google Apps Script
Source: Dev.to
Abstract
This article demonstrates how to build an adaptive learning agent using Agent‑to‑User Interface (A2UI), Gemini, and Google Apps Script. We explore a system that generates personalized quizzes, tracks performance in Google Sheets, and dynamically adjusts difficulty to maximize learning efficiency within the Google Workspace ecosystem.
Introduction
A2UI (Agent‑to‑User Interface) represents a paradigm shift in how users interact with generative AI. Originally open‑sourced by Google and implemented in TypeScript and Python — Ref — A2UI becomes even more powerful when integrated with Google Apps Script (GAS). This combination enables seamless access to the Google Workspace ecosystem, transforming static documents into intelligent, agentic applications.
To explore this potential, I have previously published several articles detailing the technical foundations:
- A2UI for Google Apps Script
- Bringing A2UI to Google Workspace with Gemini
- Beyond Chatbots: Building Task‑Driven Agentic Interfaces in Google Workspace with A2UI and Gemini
Building upon the foundation laid in those publications, this article introduces an educational support framework powered by A2UI and Google Apps Script. In this system, the AI does not simply answer questions; it acts as an active tutor.
Example: When a user provides a prompt such as
I want to study Google Apps Script, Gemini generates specialized questions on the backend. A2UI then renders these as an interactive quiz on the frontend. The system utilizes Google Sheets as a persistent memory store; by analyzing historical performance data, the agent generates increasingly challenging content for subsequent sessions, facilitating a personalized and effective learning progression.
The Adaptive Learning Engine
The core value of this application lies in its ability to improve learning efficiency through a “Feedback‑Loop Architecture.” Unlike static quiz apps, this agent utilizes Google Sheets as a persistent memory store to track cognitive growth.
Workflow and Architecture
- Goal Definition – The user opens the sidebar and sets a learning target (e.g., “Master Google Apps Script”).
- Context Retrieval – The system scans the active Spreadsheet for past performance data, identifying previously answered questions, success rates, and specific topic weaknesses (e.g., “Batch Operations”).
- Generative Logic (Gemini) – Using the context, Gemini generates a structured JSON response containing new, targeted questions and the specific UI components (radio buttons, code blocks) required to render them.
- Dynamic Rendering (A2UI) – The frontend constructs the interface instantly; no hard‑coded HTML is required.
- Immediate Feedback & Persistence – As the user interacts, results are validated in real‑time and immediately logged back to the Spreadsheet, refining the dataset for the next session.
The detailed workflow operates as follows:
In the official sample script for A2UI (Restaurant finder), the client communicates with the server via A2A (Agent2Agent) protocols. In this article, we optimize the architecture for GAS: the client (HTML) communicates directly with the AI agent built on Google Apps Script using goo.
Demonstration: The AI Tutor in Action
The video demonstration highlights two distinct capabilities: Deep Learning Support and General Versatility. It utilizes a dialog within Google Sheets to showcase the integration with Google Apps Script, but the same application can be deployed as a standalone Web App. Deploying the project as a Web App lets the doGet function capture requests, allowing the interface to function independently of the spreadsheet UI.
1. Maximizing Learning Efficiency
Prompt
Create a quiz about Google Apps Script basics. Especially, I want to manage Google Sheets using Google Apps Script.
-
Targeted Question Generation – The AI generates technical questions ranging from basic range selection (
sheet.getRange()) to advanced data handling (sheet.getValues()). -
Active Recall – The system presents a challenge question on Batch Operations (
SpreadsheetApp.flush()) to test depth of knowledge. -
Comprehensive Performance Analysis – A2UI renders a “Performance Analysis” dashboard.
- Strengths Identified: Mastery in Range & Data Manipulation.
- Weakness Assessment: No current weaknesses detected in this session.
- Strategic Next Steps: Suggest moving on to Custom Menus or Simple Triggers, effectively guiding the user’s curriculum path.
Note: Upon completion of the initial quiz, using the same prompt triggers a new session where questions are generated based on the refined historical data.
The past data is stored in Google Sheets as follows:
2. Versatility Verification: Restaurant Finder
Prompt
Find 3 Chinese restaurants in New York
- Multimodal UI – The agent renders rich cards with images for Han Dynasty and RedFarm.
- Complex Action Handling – The user clicks “Book Now,” triggering a multi‑field form (Party Size, Date, Dietary Requirements).
- Significance – Demonstrates that the A2UI protocol on GAS can handle complex transactional flows just as easily as educational logic.
Repository
The full source code and sample implementation are available here:
https://github.com/tanaikech/A2UI-for-Google-Apps-Script/tree/master/samples/A2UI-Lerning-Agent
Application Setup Guide
1. Obtain an API Key
You must have a valid Gemini API Key. Get one here.
2. Copy the Sample Script
Copy the pre‑configured Spreadsheet containing the A2UI engine:
3. Configure the Script
- Open the script editor (
Extensions > Apps Script). - Open
main.gs. - Paste your API key into the
apiKeyvariable. - Save the script and reload the Spreadsheet.
Important Note
This project serves as a foundational methodology for building Agentic UIs. When implementing it in a production environment, ensure the scripts are modified to meet your specific security requirements and workflow constraints.
Users can also study multiple subjects concurrently. When switching topics, Gemini generates new questions by analyzing historical data trends specific to that context, allowing simultaneous progress across different fields.
Summary
- Adaptive Learning Loop: Google Sheets stores user history, enabling Gemini to tailor future questions based on identified strengths and weaknesses.
- Dynamic UI Generation: A2UI eliminates static HTML templates, allowing the AI to generate quizzes, charts, and booking forms on‑the‑fly based on context.
- Detailed Performance Analytics: The agent provides qualitative feedback—not just scores—offering specific “Next Steps” to guide the user’s learning path efficiently.
- Cross‑Domain Versatility: The architecture handles educational code quizzes and restaurant‑booking transactions with equal fluency.
- Seamless Workspace Integration: Combining GAS and Gemini transforms standard Google Sheets into intelligent, persistent databases that drive agentic behavior.


