Building Adaptive Learning Agents with A2UI, Gemini, and Google Apps Script

Gists

Building Adaptive Learning Agents with A2UI, Gemini, and Google Apps Script

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:

Building upon the foundation laid in those publications, this article takes a step forward by introducing 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.

For 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. Crucially, 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

The detailed workflow operates as follows:

Building Adaptive Learning Agents with A2UI, Gemini, and Google Apps Script

Mermaid Chart Playground

In the official sample script for A2UI (Restaurant finder), the client communicates with the server via A2A (Agent2Agent) protocols. However, in this article, we optimize the architecture for GAS. To reduce the overhead of HTTP requests associated with A2A communication, the client (HTML) communicates directly with the AI agent built on Google Apps Script using google.script.run.

Demonstration: The AI Tutor in Action

Application Demo

The video demonstration highlights two distinct capabilities: Deep Learning Support and General Versatility. This demonstration utilizes a dialog within Google Sheets to highlight the integration with Google Apps Script. However, this application can easily be deployed as a standalone Web App. By deploying the project as a Web App, the doGet function captures the request, allowing the interface to function independently of the spreadsheet UI.

1. Maximizing Learning Efficiency

In the first segment, the user prompts: Create a quiz about Google Apps Script basics. Especially, I want to manage Google Sheets using Google Apps Script.

The past data is stored in Google Sheets as follows.

Building Adaptive Learning Agents with A2UI, Gemini, and Google Apps Script

2. Versatility Verification: Restaurant Finder

To prove the system’s flexibility, we switch contexts entirely without changing code.

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

To deploy this adaptive learning agent in your environment:

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: https://docs.google.com/spreadsheets/d/1eckORqs3JtTIJZTB0I5VpqduZw9g3-mM764s4neG7Fo/copy

3. Configure the Script Open the script editor (Extensions > Apps Script), open main.gs, and paste your API key into the apiKey variable. Finally, save the script and reload the Spreadsheet.

Important Note

This project serves as a foundational methodology for building Agentic UIs. When implementing this 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 the historical data trends specific to that context, allowing for simultaneous progress across different fields.

Summary

 Share!