<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>slvdr510.dev - Firebase AI Logic</title>
    <subtitle>Personal blog about Linux and development.</subtitle>
    <link rel="self" type="application/atom+xml" href="https://slvdr510.dev/tags/firebase-ai-logic/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://slvdr510.dev"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2026-11-07T00:00:00+00:00</updated>
    <id>https://slvdr510.dev/tags/firebase-ai-logic/atom.xml</id>
    <entry xml:lang="en">
        <title>Build AI apps with the Google ecosystem</title>
        <published>2026-11-07T00:00:00+00:00</published>
        <updated>2026-11-07T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://slvdr510.dev/blog/0002-build-ai-apps-with-the-google-ecosystem/"/>
        <id>https://slvdr510.dev/blog/0002-build-ai-apps-with-the-google-ecosystem/</id>
        
        <content type="html" xml:base="https://slvdr510.dev/blog/0002-build-ai-apps-with-the-google-ecosystem/">&lt;h2 id=&quot;from-a-hand-drawn-sketch-to-a-deployed-ai-app&quot;&gt;From a hand-drawn sketch to a deployed AI app&lt;/h2&gt;
&lt;p&gt;This post is my walkthrough of the Google codelab &lt;a rel=&quot;external&quot; href=&quot;https://codelabs.developers.google.com/building-ai-apps-google-ecosystem&quot;&gt;Build AI apps with the Google ecosystem&lt;/a&gt;, written by Marina Coelho (last updated Oct 26, 2026). I kept the same section titles as the codelab, so you can follow both side by side.&lt;/p&gt;
&lt;p&gt;The goal is to build a complete app almost without writing code by hand. Each tool takes care of one part:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;a rel=&quot;external&quot; href=&quot;https://stitch.withgoogle.com&quot;&gt;Google Stitch&lt;/a&gt;&lt;/strong&gt; designs the UI from a sketch.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a rel=&quot;external&quot; href=&quot;https://aistudio.google.com&quot;&gt;Google AI Studio&lt;/a&gt;&lt;/strong&gt; writes the app (vibe coding) and deploys it to Cloud Run.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a rel=&quot;external&quot; href=&quot;https://console.firebase.google.com&quot;&gt;Firebase&lt;/a&gt;&lt;/strong&gt; handles sign-in (Authentication), the database (Firestore), the AI calls (Firebase AI Logic) and protection against abuse (App Check).&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;1-before-you-begin&quot;&gt;1. Before you begin&lt;/h2&gt;
&lt;p&gt;The app is called &lt;strong&gt;Decide For Me&lt;/strong&gt;. It’s a decision assistant for indecisive people: you write down your priorities in life, then give it two options (buy or keep renting, change careers or stay, etc.). The AI picks the one that minimizes long-term regret and gives you a concrete first step to take.&lt;/p&gt;
&lt;p&gt;What you need:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A Google Account. Use the same one for Stitch, Google AI Studio and Firebase.&lt;/li&gt;
&lt;li&gt;About an hour. The codelab estimates around 62 minutes.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;what-you-ll-learn&quot;&gt;What you’ll learn&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Design UIs with Google Stitch.&lt;/li&gt;
&lt;li&gt;Vibe code a web app with Google AI Studio.&lt;/li&gt;
&lt;li&gt;Use Firebase to add AI features and store data in the cloud.&lt;/li&gt;
&lt;li&gt;Deploy the web app to production with Google AI Studio (Cloud Run under the hood).&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;2-design-the-ui-with-stitch&quot;&gt;2. Design the UI with Stitch&lt;/h2&gt;
&lt;p&gt;The codelab provides a hand-drawn mockup of the app. Download it &lt;a href=&quot;https://slvdr510.dev/blog/0002-build-ai-apps-with-the-google-ecosystem/DecideForMeScreen.jpeg&quot;&gt;here&lt;/a&gt; (&lt;code&gt;DecideForMeScreen.jpeg&lt;/code&gt;) and save it somewhere you can find it.&lt;/p&gt;
&lt;p&gt;Go to &lt;a rel=&quot;external&quot; href=&quot;https://stitch.withgoogle.com&quot;&gt;Stitch&lt;/a&gt; and select the &lt;strong&gt;Web&lt;/strong&gt; option in the input field. Stitch can also generate mobile screens, but this codelab only covers the web version.&lt;/p&gt;
&lt;p&gt;Upload the mockup:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;+ &amp;gt; Upload Files &amp;gt; DecideForMeScreen.jpeg&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Since it’s a hand-drawn sketch, it’s a good test of how well Stitch understands images.&lt;/p&gt;
&lt;p&gt;Next, copy the following prompt and paste it into the input field:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;markdown&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt; General Guidance&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Create a modern, clean, and highly polished UI for a web application called&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&amp;quot;Decide For Me&amp;quot; - a hyper-rational decision assistant.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;CRITICAL: Replicate the exact layout, structure, and element placement shown in&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;the hand-drawn mockup file DecideForMeScreen.jpeg. Do not add any extra menus,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sidebars, buttons, or top/bottom navigation bars that are not explicitly drawn&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;in the file. Stick strictly to the skeleton provided in the mockup.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt; Layout &lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt; Structure&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;-&lt;/span&gt;&lt;span&gt; Two-Column Split Screen:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;  -&lt;/span&gt;&lt;span&gt; Left Side (Main Chat Area): Takes up roughly 70-75% of the screen width. It&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    should feel like a premium, focused workspace.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;  -&lt;/span&gt;&lt;span&gt; Right Side (Configuration Panel): A sidebar taking up 25-30% of the screen&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    width with a distinct, subtle background color to separate it from the&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    chat.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt; Right Panel: Configuration Screen&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;-&lt;/span&gt;&lt;span&gt; Header: Title it &amp;quot;My Priorities&amp;quot; with a clean, minimalist typography.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;-&lt;/span&gt;&lt;span&gt; Content Card: A styled card containing a text box or paragraph area&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  showcasing the user&amp;#39;s priorities.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;-&lt;/span&gt;&lt;span&gt; Interactions: Include a clear &amp;quot;Edit Priorities&amp;quot; button. When clicked, this&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  area should visually toggle into an editable textarea or input field.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt; Left Panel: Chat &lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt; Dilemma Decision Screen&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;-&lt;/span&gt;&lt;span&gt; Chat History: A clean vertical flow of message bubbles.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;  -&lt;/span&gt;&lt;span&gt; The first message bubble must be aligned to the left (system message) and&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    say: &amp;quot;Tell me your dilemma&amp;quot;. Use a friendly, neutral background color for&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    this bubble.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;-&lt;/span&gt;&lt;span&gt; Bottom Input Area: Instead of a traditional single-line chat bar, create a&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  unified, beautiful &amp;quot;Decision Submission&amp;quot; layout positioned at the bottom:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;  -&lt;/span&gt;&lt;span&gt; Dual Input Fields: Place two horizontal or cleanly stacked input fields.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    -&lt;/span&gt;&lt;span&gt; Input 1 label: &amp;quot;Option A&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    -&lt;/span&gt;&lt;span&gt; Input 2 label: &amp;quot;Option B&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;  -&lt;/span&gt;&lt;span&gt; Action Button: A prominent, styled &amp;quot;Go&amp;quot; action button to trigger the&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    reasoning loop.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt; Theme &lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt; Aesthetic&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;-&lt;/span&gt;&lt;span&gt; Vibe: Hyper-rational, clean, trustworthy, and modern. Use a sophisticated&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  color palette (e.g., deep slates, clean whites/grays, and a sharp accent&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  color like a subtle indigo or teal for active states and buttons).&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;-&lt;/span&gt;&lt;span&gt; Spacing &lt;/span&gt;&lt;span&gt;&amp;amp;&lt;/span&gt;&lt;span&gt; Typography: Use generous whitespace, soft rounded corners&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  (border-radius) for cards and buttons, and a highly legible sans-serif font.&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Click the generate arrow in the bottom-right corner of the input field. Stitch generates the screen and also a full design system: color palette, fonts, icons and the general style of the UI elements.&lt;/p&gt;
&lt;blockquote class=&quot;markdown-alert-warning&quot;&gt;
&lt;p&gt;If it takes more than 5 minutes to generate the screen, reload the page and submit the prompt again.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;You can download the design Stitch generated for me &lt;a href=&quot;https://slvdr510.dev/blog/0002-build-ai-apps-with-the-google-ecosystem/stitch_decide_for_me_ui.zip&quot;&gt;here&lt;/a&gt;. It contains the screen (&lt;code&gt;screen.png&lt;/code&gt;), its HTML (&lt;code&gt;code.html&lt;/code&gt;) and the design system (&lt;code&gt;DESIGN.md&lt;/code&gt;).&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;3-build-the-app-with-google-ai-studio&quot;&gt;3. Build the app with Google AI Studio&lt;/h2&gt;
&lt;p&gt;First, create a Firebase project:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Sign in to the &lt;a rel=&quot;external&quot; href=&quot;https://console.firebase.google.com/&quot;&gt;Firebase console&lt;/a&gt; with the same Google Account you used for Stitch.&lt;/li&gt;
&lt;li&gt;Create a new project and give it a name, for example &lt;code&gt;Decider App&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Continue&lt;/strong&gt; and accept the Firebase terms if prompted.&lt;/li&gt;
&lt;li&gt;Optionally, enable Gemini in Firebase (AI assistance inside the console).&lt;/li&gt;
&lt;li&gt;Turn &lt;strong&gt;off&lt;/strong&gt; Google Analytics, it’s not needed here.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Create project&lt;/strong&gt;, wait until it’s ready and click &lt;strong&gt;Continue&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;blockquote class=&quot;markdown-alert-tip&quot;&gt;
&lt;p&gt;Write down the project ID shown below the project name. You’ll need it in the prompt below. If you lose it, it’s also in &lt;strong&gt;Project Settings&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Now export the Stitch design to Google AI Studio:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;Click the generated design &amp;gt; Export (top-right corner) &amp;gt; Google AI Studio &amp;gt; Description field&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Copy the following prompt and paste it into the &lt;strong&gt;Description&lt;/strong&gt; field. &lt;strong&gt;Replace &lt;code&gt;[FIREBASE_PROJECT_ID]&lt;/code&gt; with your project ID.&lt;/strong&gt;&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;markdown&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt; General Guidance&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Build the &amp;quot;Decide For Me&amp;quot; app: A hyper-rational decision assistant for&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;chronically indecisive people facing life choices (moving apartments, changing&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;careers, picking a hobby). The user enters a dilemma and their top priorities&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;in life. The app will help with the decision. Follow the instructions below to&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;build it:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt; UI Instructions&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Using the design artifacts exported from Stitch (the PNG image and HTML file),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;build a fully functional web application that accurately mirrors the design and&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;layout.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt; App Architecture &lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt; Initialization Instructions&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;-&lt;/span&gt;&lt;span&gt; Initialize the latest Firebase JS SDK for client-side services. Use the&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  Firebase project with ID &lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;FIREBASE_PROJECT_ID&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;-&lt;/span&gt;&lt;span&gt; Enable Firebase Authentication in this project using the Google provider.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  If a user is not logged in, show a clean, minimalist sign-in state. If the&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  user is logged in, take them directly to the dilemma decision screen.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;-&lt;/span&gt;&lt;span&gt; Initialize Firebase App Check in debug mode with the following code:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  `&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;self.FIREBASE_APPCHECK_DEBUG_TOKEN = true;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;`&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  `&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;initializeAppCheck(app, { /* App Check options */ });&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;`&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt; State &lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt; Database Management Instructions&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;-&lt;/span&gt;&lt;span&gt; User Priorities:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;  -&lt;/span&gt;&lt;span&gt; Once authenticated, pull the user&amp;#39;s saved priorities from Firebase&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    Firestore at the path: &lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;`&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;users/{userId}&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;`&lt;/span&gt;&lt;span&gt;. Each document should contain one&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    string field: &amp;#39;priorities&amp;#39;.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;  -&lt;/span&gt;&lt;span&gt; Bind this data to the Right Panel (&amp;quot;My Priorities&amp;quot;).&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;  -&lt;/span&gt;&lt;span&gt; When the user clicks the &amp;quot;Edit&amp;quot; button, toggle the view to a textarea, with&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    a &amp;#39;save&amp;#39; button. When saved, write the updated string back to&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;    `&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;users/{userId}&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;`&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;  -&lt;/span&gt;&lt;span&gt; Make sure to implement and deploy strong Security Rules for Firestore.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt; UI Stream Update &lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt; Display Instructions&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;-&lt;/span&gt;&lt;span&gt; Once the user submits option A and option B in the dilemma decision screen,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  display both options as a single message on the user side of the chat. Then,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  display a sleek loading state in the main chat panel. Leave the app in this&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &amp;quot;loading&amp;quot; state and do nothing else, we will process both options and build&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  the server-side thinking later.&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Click &lt;strong&gt;Build with Google AI Studio&lt;/strong&gt;. It opens Google AI Studio in a new tab with the design files and the prompt. Check that the whole prompt was carried over; if only part of it shows up, paste it again.&lt;/p&gt;
&lt;p&gt;Click &lt;strong&gt;Build&lt;/strong&gt;. While it generates the app, Google AI Studio suggests alternative UI designs. You can ignore them for this codelab. When it asks you to enable Firebase, click &lt;strong&gt;Enable&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;When it finishes, inspect the result:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Preview&lt;/strong&gt; tab: try the app.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Code&lt;/strong&gt; tab: review the generated files.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Google AI Studio also sets up a Firebase project with &lt;a rel=&quot;external&quot; href=&quot;https://firebase.google.com/docs/auth&quot;&gt;Firebase Authentication&lt;/a&gt; and &lt;a rel=&quot;external&quot; href=&quot;https://firebase.google.com/docs/firestore&quot;&gt;Firestore&lt;/a&gt; enabled, and adds the Firebase configuration to the code. We’ll work with that project in the next step.&lt;/p&gt;
&lt;blockquote class=&quot;markdown-alert-warning&quot;&gt;
&lt;p&gt;If generating the app takes more than 10 minutes, close the tab, go back to Stitch and start again from the &lt;strong&gt;Export&lt;/strong&gt; step.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;4-register-your-app-check-debug-token&quot;&gt;4. Register your App Check debug token&lt;/h2&gt;
&lt;p&gt;Google AI Studio connected the app to a Firebase project. Now we need to find that project and register our development environment in &lt;strong&gt;Firebase App Check&lt;/strong&gt;.&lt;/p&gt;
&lt;h3 id=&quot;access-your-firebase-project&quot;&gt;Access your Firebase project&lt;/h3&gt;
&lt;p&gt;Find the project ID that Google AI Studio is actually using:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;Code tab &amp;gt; firebase-applet-config.json &amp;gt; copy the value of projectId&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Then search for that ID in the &lt;a rel=&quot;external&quot; href=&quot;https://console.firebase.google.com&quot;&gt;Firebase console&lt;/a&gt;. Don’t assume it’s the project you created in step 3, check the ID.&lt;/p&gt;
&lt;blockquote class=&quot;markdown-alert-note&quot;&gt;
&lt;p&gt;If this is your first Firebase project, there’s only one project in the list: the one created by Google AI Studio.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote class=&quot;markdown-alert-warning&quot;&gt;
&lt;p&gt;If &lt;code&gt;firebase-applet-config.json&lt;/code&gt; doesn’t exist, or the project isn’t in the console, the project wasn’t created. Ask Google AI Studio: “Please add Firebase Auth and Firestore to this app.”&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id=&quot;register-your-debug-token&quot;&gt;Register your debug token&lt;/h3&gt;
&lt;p&gt;&lt;a rel=&quot;external&quot; href=&quot;https://console.firebase.google.com/project/_/appcheck/?useAutoProject=true&quot;&gt;App Check&lt;/a&gt; protects your backend and AI models from abuse by making sure requests come from your real app, not from a script calling your APIs directly.&lt;/p&gt;
&lt;blockquote class=&quot;markdown-alert-important&quot;&gt;
&lt;p&gt;Initializing App Check or registering a debug token doesn’t protect anything on its own. You have to &lt;strong&gt;enforce&lt;/strong&gt; App Check for each service you want to protect. Firebase AI Logic gets enforced later in this post. For Firestore, you can enforce it in the App Check settings once you’ve verified the incoming traffic.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The app runs inside the Google AI Studio preview, so it uses the App Check debug provider (&lt;code&gt;self.FIREBASE_APPCHECK_DEBUG_TOKEN = true&lt;/code&gt;). When the app loads, Firebase prints a debug token in the browser console.&lt;/p&gt;
&lt;p&gt;Open the developer tools while viewing the preview:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Chrome, Edge or Firefox:&lt;/strong&gt; press &lt;code&gt;F12&lt;/code&gt; (or right-click the preview &amp;gt; &lt;strong&gt;Inspect&lt;/strong&gt;) and open the &lt;strong&gt;Console&lt;/strong&gt; tab.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;macOS:&lt;/strong&gt; press &lt;code&gt;Cmd+Option+I&lt;/code&gt; and open the &lt;strong&gt;Console&lt;/strong&gt; tab.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Look for a message like this one:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;AppCheck debug token: &amp;quot;123a4567-b89c-12d3-e456-789012345678&amp;quot;.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;You will need to safelist it in the Firebase console for it to work.&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Copy the token without the quotes and register it in the Firebase console:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;Security &amp;gt; App Check &amp;gt; Apps tab &amp;gt; ⋮ on your web app &amp;gt; Manage debug tokens &amp;gt; Add debug token&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Paste the token, give it a name like &lt;code&gt;Google AI Studio Preview&lt;/code&gt; and click &lt;strong&gt;Save&lt;/strong&gt;.&lt;/p&gt;
&lt;blockquote class=&quot;markdown-alert-note&quot;&gt;
&lt;p&gt;If the token doesn’t appear in the console, refresh the preview or ask the Google AI Studio agent: “Please ensure Firebase App Check is initialized in debug mode using self.FIREBASE_APPCHECK_DEBUG_TOKEN = true.”&lt;/p&gt;
&lt;/blockquote&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;5-test-the-app&quot;&gt;5. Test the app&lt;/h2&gt;
&lt;p&gt;With the project connected and the debug token registered, let’s test the basics: Authentication and Firestore.&lt;/p&gt;
&lt;p&gt;In the app preview inside Google AI Studio:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Sign in with a Google Account.&lt;/li&gt;
&lt;li&gt;Save your priorities in the &lt;strong&gt;My Priorities&lt;/strong&gt; panel.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Then check the Firebase console:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;a rel=&quot;external&quot; href=&quot;https://console.firebase.google.com/project/_/authentication/?useAutoProject=true&quot;&gt;Authentication&lt;/a&gt;:&lt;/strong&gt; the Google Account you signed in with should be listed.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a rel=&quot;external&quot; href=&quot;https://console.firebase.google.com/project/_/firestore/?useAutoProject=true&quot;&gt;Firestore&lt;/a&gt;:&lt;/strong&gt; there should be a document under &lt;code&gt;users/{userId}&lt;/code&gt; with your priorities.&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote class=&quot;markdown-alert-warning&quot;&gt;
&lt;p&gt;If there are no documents in Firestore, open the &lt;strong&gt;Rules&lt;/strong&gt; tab. If the rules are empty or return &lt;code&gt;false&lt;/code&gt; for every request, the app can’t write anything. Go back to Google AI Studio and ask it to deploy strong security rules for the app.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;For reference, a minimal rule where each user can only read and write their own document looks like this:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;rules_version&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;service&lt;/span&gt;&lt;span&gt; cloud&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;firestore&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  match&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; /&lt;/span&gt;&lt;span&gt;databases&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;/&lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;span&gt;database&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;/&lt;/span&gt;&lt;span&gt;documents&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    match&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; /&lt;/span&gt;&lt;span&gt;users&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;/&lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;span&gt;userId&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      allow&lt;/span&gt;&lt;span&gt; read&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; write&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; if&lt;/span&gt;&lt;span&gt; request&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;auth&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; !=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; null&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; &amp;amp;&amp;amp;&lt;/span&gt;&lt;span&gt; request&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;auth&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;uid&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ==&lt;/span&gt;&lt;span&gt; userId&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;6-build-an-ai-powered-decider-flow-using-firebase&quot;&gt;6. Build an AI-powered Decider flow using Firebase&lt;/h2&gt;
&lt;p&gt;Now for the interesting part: the AI that makes the decision. We’ll build it in Firebase.&lt;/p&gt;
&lt;h3 id=&quot;set-up-firebase-ai-logic&quot;&gt;Set up Firebase AI Logic&lt;/h3&gt;
&lt;p&gt;Open &lt;a rel=&quot;external&quot; href=&quot;https://console.firebase.google.com/project/_/ailogic/?useAutoProject=true&quot;&gt;Firebase AI Logic&lt;/a&gt; in the Firebase console, click &lt;strong&gt;Get started&lt;/strong&gt;, select &lt;strong&gt;Gemini Developer API&lt;/strong&gt; and follow the steps to enable it.&lt;/p&gt;
&lt;blockquote class=&quot;markdown-alert-note&quot;&gt;
&lt;p&gt;At this point App Check is enforced automatically for Firebase AI Logic. That’s why we registered the debug token before: without it, requests from the Google AI Studio preview would be rejected.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Then, in the &lt;strong&gt;Settings&lt;/strong&gt; tab, set both options to &lt;strong&gt;Enforced&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Enforce template-only mode:&lt;/strong&gt; the app can only call server prompt templates, not send its own prompts.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Enforce authenticated-users mode:&lt;/strong&gt; only signed-in users can call the model.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;create-a-server-prompt-template&quot;&gt;Create a server prompt template&lt;/h3&gt;
&lt;p&gt;Instead of writing the prompt in the client code, we’ll store it in Firebase as a &lt;strong&gt;server prompt template&lt;/strong&gt;. This has three advantages:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Protecting your intellectual property:&lt;/strong&gt; the prompt stays on the backend, not on the user’s device.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Preventing prompt injection:&lt;/strong&gt; the client can only fill in specific variables, and the backend validates them against a schema.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Updating without releasing a new version:&lt;/strong&gt; you can change the prompt, system instructions or model from the console.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Create the template:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;Prompt templates tab &amp;gt; Create template &amp;gt; Blank template&lt;/code&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Template name:&lt;/strong&gt; &lt;code&gt;Decider Flow&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Template ID:&lt;/strong&gt; &lt;code&gt;decider-flow&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Configuration (frontmatter):&lt;/strong&gt; the model, the input variables and the JSON output schema.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;yaml&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;m&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;odel&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;gemini-3.5-flash-lite&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;nput&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;  s&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;chema&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;    p&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;riorities&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;string, user&amp;#39;s core priorities&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;    o&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;ptionA&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;string, option A under consideration&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;    o&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;ptionB&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;string, option B under consideration&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;o&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;utput&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;  f&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;ormat&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; j&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;son&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;  s&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;chema&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;    v&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;erdict&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;tring&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;    j&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;ustification&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;tring&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;    f&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;irstStep&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;tring&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Prompt and system instructions:&lt;/strong&gt; the system part defines the “Decider Agent” persona, and the user part receives the three inputs and reasons through three phases.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;markdown&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{{role &amp;quot;system&amp;quot;}}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;You are the Decider Agent, a multi-stage reasoning engine that&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;combines the roles of an honest and polite behavioral economist, a&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;long-term strategic forecaster, and an executive decision coach.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Your job is to take a user&amp;#39;s dilemma and their core priorities, run&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;them through a rigorous, adversarial 3-phase thinking process, and&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;output a highly analytical, reasoning-backed final verdict. You must be&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;direct, sharp, and realistic. Do not give generic platitudes or claim&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;that &amp;quot;both options are great.&amp;quot; You must force a clear choice.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{{role &amp;quot;user&amp;quot;}}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt; Context &lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt; Inputs&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;You are analyzing a critical life decision for the user. Base your&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;entire multi-phase reasoning flow strictly on these three specific&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;inputs:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;-&lt;/span&gt;&lt;span&gt; User&amp;#39;s Core Priorities: {{priorities}}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;-&lt;/span&gt;&lt;span&gt; Option A under consideration: {{optionA}}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;-&lt;/span&gt;&lt;span&gt; Option B under consideration: {{optionB}}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Execute your reasoning flow through the following three phases:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt; Phase 1: Cynical Breakdown (Input-Driven Analysis)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Analyze {{optionA}} and {{optionB}} strictly through the lens of the&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;user&amp;#39;s explicit {{priorities}}. Do not evaluate them in a vacuum.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;-&lt;/span&gt;&lt;span&gt; Identify the hidden flaws, compromises, and psychological costs&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  embedded in both choices.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;-&lt;/span&gt;&lt;span&gt; Pinpoint exactly how {{optionA}} could directly conflict with or&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  undermine their {{priorities}}.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;-&lt;/span&gt;&lt;span&gt; Pinpoint exactly how {{optionB}} could directly conflict with or&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  undermine their {{priorities}}.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;-&lt;/span&gt;&lt;span&gt; Uncover any cognitive biases (like status quo bias or loss aversion)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  the user might be falling for in either option.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt; Phase 2: Long-Term Regret Projection&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Project the user 5 years into the future. Apply the Regret Minimization&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Framework to both paths:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;-&lt;/span&gt;&lt;span&gt; The {{optionA}} Timeline: Quantify the absolute worst-case, deep,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  structural 5-year regret of choosing this path. Focus heavily on&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  failures of courage vs. failures of action based on their&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  {{priorities}}.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;-&lt;/span&gt;&lt;span&gt; The {{optionB}} Timeline: Quantify the matching 5-year regret for&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  this path.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;-&lt;/span&gt;&lt;span&gt; Contrast these two timelines. Which option carries the kind of regret&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  that fundamentally breaks the user&amp;#39;s {{priorities}}?&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt; Phase 3: Final Recommendation &lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);font-weight: bold;&quot;&gt; Action Step&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Synthesize the cynical critiques and long-term regret scores.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Weigh them against the user&amp;#39;s {{priorities}} to determine which&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;choice minimizes long-term disappointment.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;-&lt;/span&gt;&lt;span&gt; Verdict: You must declare either {{optionA}} or {{optionB}} as the&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  definitive winner. No compromise, no &amp;quot;it depends,&amp;quot; and no hybrid&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  options.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;-&lt;/span&gt;&lt;span&gt; Justification: Provide a sharp, reasoning-backed explanation showing why&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  the losing option was eliminated based on the Phase 1 and Phase 2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  analysis.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;-&lt;/span&gt;&lt;span&gt; First Step: Give one microscopic, low-friction task the user can&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  execute within the next 15 minutes to commit to or move toward the&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  chosen verdict.&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote class=&quot;markdown-alert-important&quot;&gt;
&lt;p&gt;The roles need double braces: &lt;code&gt;{{role &quot;system&quot;}}&lt;/code&gt; and &lt;code&gt;{{role &quot;user&quot;}}&lt;/code&gt;. The codelab displays them with single braces (&lt;code&gt;{role &quot;system&quot;}&lt;/code&gt;) and asks you to add the extra pair; the prompt above already has them.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;strong&gt;Test input:&lt;/strong&gt;&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;json&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;  &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;priorities&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Be financially stable, have a good work-life balance where I can travel twice a year&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;  &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;optionA&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Buy a house for 615000 British pounds with a mortgage of 2800 per month for the next 35 years&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;  &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;optionB&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Keep renting for 2400 per month for the foreseeable&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Click &lt;strong&gt;Save template&lt;/strong&gt;, then &lt;strong&gt;Run prompt test&lt;/strong&gt;. Check that the &lt;strong&gt;Test response&lt;/strong&gt; contains all three fields: &lt;code&gt;verdict&lt;/code&gt;, &lt;code&gt;justification&lt;/code&gt; and &lt;code&gt;firstStep&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If everything looks right, lock the template with the lock icon in the top-right corner. This keeps the version stable and prevents accidental changes.&lt;/p&gt;
&lt;p&gt;The template is ready to be used by the app.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;7-use-the-decider-prompt-template-in-the-app&quot;&gt;7. Use the Decider prompt template in the app&lt;/h2&gt;
&lt;p&gt;Go back to the app in Google AI Studio, copy the following prompt into the chat and click &lt;strong&gt;Send&lt;/strong&gt;:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Now let&amp;#39;s implement the &amp;quot;Decide For Me&amp;quot; button action. When clicked, it&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;should call the Firebase AI Logic SDK using a Template Generative Model.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;The prompt is stored in a prompt template with the id &amp;quot;decider-flow&amp;quot;. When&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;calling the API, pass the following variables as the input payload object:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;- priorities&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;- optionA&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;- optionB&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;The API will return a JSON object. Handle the response asynchronously and&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;extract:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;- verdict&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;- justification&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;- firstStep&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Once the data is received, update the UI state to append a new message to&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;the chat array. Ensure it renders as a system chat bubble positioned on&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;the left side of the chat screen, mapping these three fields clearly into&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;the bubble&amp;#39;s layout.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Please provide the necessary front-end component state updates and the&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Firebase SDK call.&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Wait until Google AI Studio finishes adding Firebase AI Logic to the app.&lt;/p&gt;
&lt;p&gt;Before testing, open the &lt;strong&gt;Code&lt;/strong&gt; tab and check that &lt;code&gt;firebase-applet-config.json&lt;/code&gt; contains an API key. If it’s missing, ask Google AI Studio to import it.&lt;/p&gt;
&lt;p&gt;Then go to the &lt;strong&gt;Preview&lt;/strong&gt; tab, fill in Option A and Option B, and check that the AI returns the verdict, the justification and the first step.&lt;/p&gt;
&lt;blockquote class=&quot;markdown-alert-warning&quot;&gt;
&lt;p&gt;If the call still fails with the API key in place, ask the Google AI Studio agent to fix it with this prompt:&lt;/p&gt;
&lt;p&gt;“Please make sure the Firebase AI Logic call uses &lt;code&gt;getAI(app)&lt;/code&gt; and &lt;code&gt;getTemplateGenerativeModel(aiInstance)&lt;/code&gt; with the &lt;code&gt;decider-flow&lt;/code&gt; template, parses the JSON response correctly into &lt;code&gt;verdict&lt;/code&gt;, &lt;code&gt;justification&lt;/code&gt;, and &lt;code&gt;firstStep&lt;/code&gt;, and doesn’t contain any timeout constraints or unnecessary function checks.”&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;For reference, the code generated by Google AI Studio should look similar to this:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;typescript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; aiInstance&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; getAI&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;app&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; templateModel&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; getTemplateGenerativeModel&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;aiInstance&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; result&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; await&lt;/span&gt;&lt;span&gt; templateModel&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;generateContent&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;decider-flow&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  priorities&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt; priorities&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  optionA&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt; optA&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  optionB&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt; optB&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; rawText&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; result&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;response&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;text&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Parse response text to extract fields&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; cleaned&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; rawText&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;replace&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;```json&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;```&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;g&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;trim&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; parsedData&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;:&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; verdict&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; string&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; justification&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; string&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; firstStep&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; string&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; JSON&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;parse&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;cleaned&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; verdict&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; parsedData&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;verdict&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; justification&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; parsedData&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;justification&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; firstStep&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; parsedData&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;firstStep&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;debug-and-monitor-requests&quot;&gt;Debug and monitor requests&lt;/h3&gt;
&lt;p&gt;If something fails, or you just want to see what’s going on, Firebase AI Logic has built-in monitoring:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;AI Services &amp;gt; AI Logic &amp;gt; AI monitoring tab&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The dashboard shows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Request volume and status:&lt;/strong&gt; whether requests reach the backend and return &lt;code&gt;200 OK&lt;/code&gt; or fail with a client or server error.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Latency:&lt;/strong&gt; the end-to-end response time.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Token counts:&lt;/strong&gt; input and output tokens per request.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Click a request in the traces table to inspect it:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Inputs:&lt;/strong&gt; check that &lt;code&gt;priorities&lt;/code&gt;, &lt;code&gt;optionA&lt;/code&gt; and &lt;code&gt;optionB&lt;/code&gt; arrived correctly from the app.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Outputs:&lt;/strong&gt; the raw text from the model, to check it’s valid JSON matching the schema.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Error details:&lt;/strong&gt; invalid App Check tokens, rejected authentication, quota limits or prompt validation errors.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you find an error in a trace (malformed JSON, a missing parameter…), copy the message or payload, paste it into Google AI Studio and ask it to fix the code.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;8-optional-deploy-the-app&quot;&gt;8. Optional: Deploy the app&lt;/h2&gt;
&lt;p&gt;The app works in preview, so let’s put it in production.&lt;/p&gt;
&lt;p&gt;The debug token only works for our own development environment. In production, App Check needs a real attestation provider. This codelab uses &lt;strong&gt;reCAPTCHA v3&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;We deploy first because we need the exact live URL. That way we register only our domain in reCAPTCHA, instead of allowing every &lt;code&gt;ai.studio&lt;/code&gt; app.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1. Deploy the app with Google AI Studio&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;Publish (top bar) &amp;gt; Get started &amp;gt; review the name and description &amp;gt; Publish your app&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;It takes 1-2 minutes. Copy the generated URL (for example &lt;code&gt;https://decide-for-me-123.ai.studio&lt;/code&gt;) and note its domain (&lt;code&gt;decide-for-me-123.ai.studio&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2. Create the reCAPTCHA v3 keys&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;In the &lt;a rel=&quot;external&quot; href=&quot;https://www.google.com/recaptcha/admin/create&quot;&gt;Google reCAPTCHA Admin Console&lt;/a&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Label:&lt;/strong&gt; something like &lt;code&gt;Decide For Me - Production&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;reCAPTCHA type:&lt;/strong&gt; reCAPTCHA v3 (score-based).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Domains:&lt;/strong&gt; your exact domain, without &lt;code&gt;https://&lt;/code&gt; or any path. You can also add a custom domain if you plan to use one.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Accept the terms and click &lt;strong&gt;Submit&lt;/strong&gt;. Keep the tab open: you’ll need the &lt;strong&gt;Site Key&lt;/strong&gt; (public, used by the client) and the &lt;strong&gt;Secret Key&lt;/strong&gt; (private, used by the server).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;3. Register the secret key in Firebase&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;App Check &amp;gt; Apps tab &amp;gt; your web app (or ⋮) &amp;gt; reCAPTCHA v3&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Paste the &lt;strong&gt;Secret Key&lt;/strong&gt; and click &lt;strong&gt;Save&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;4. Switch the client to &lt;code&gt;ReCaptchaV3Provider&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;In the Google AI Studio chat, ask the assistant to update the App Check configuration for production:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Please update our Firebase App Check initialization to use&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ReCaptchaV3Provider with the reCAPTCHA site key &amp;quot;YOUR_RECAPTCHA_SITE_KEY&amp;quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;while retaining support for debug tokens in non-production environments.&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you check the &lt;strong&gt;Code&lt;/strong&gt; tab, the App Check initialization should match this structure:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;import&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt; initializeAppCheck&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; ReCaptchaV3Provider&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;firebase/app-check&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; appCheck&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; initializeAppCheck&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;app&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  provider&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; new&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; ReCaptchaV3Provider&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;YOUR_RECAPTCHA_SITE_KEY&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  isTokenAutoRefreshEnabled&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; true&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then publish the app again so the live site gets the new configuration.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;5. Verify production traffic&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Open the live URL in an incognito window, sign in with Google and submit a dilemma. Then go back to &lt;a rel=&quot;external&quot; href=&quot;https://console.firebase.google.com/project/_/appcheck/?useAutoProject=true&quot;&gt;App Check&lt;/a&gt; and check the &lt;strong&gt;APIs&lt;/strong&gt; and &lt;strong&gt;Monitoring&lt;/strong&gt; tabs: requests to Firestore and Firebase AI Logic should show up as verified.&lt;/p&gt;
&lt;blockquote class=&quot;markdown-alert-note&quot;&gt;
&lt;p&gt;App Check is already enforced for Firebase AI Logic. Once you see that 100% of legitimate traffic is verified, you can also set &lt;strong&gt;Firestore&lt;/strong&gt; to &lt;strong&gt;Enforce&lt;/strong&gt; so unverified requests are rejected automatically.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;9-conclusion&quot;&gt;9. Conclusion&lt;/h2&gt;
&lt;p&gt;That’s it! We went from a hand-drawn sketch to a deployed app with sign-in, a database and an AI feature, and AI did most of the coding. As a bonus, you end up with a Firebase and Google Cloud project you can keep exploring.&lt;/p&gt;
&lt;p&gt;Some links to keep going:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Claim the &lt;strong&gt;Completed Builder Journey&lt;/strong&gt; badge &lt;a rel=&quot;external&quot; href=&quot;https://developers.google.com/profile/badges/builder/milestone1/award&quot;&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The next lab is at &lt;a rel=&quot;external&quot; href=&quot;https://goo.gle/builders&quot;&gt;goo.gle/builders&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;If you use &lt;a rel=&quot;external&quot; href=&quot;https://antigravity.google/product/antigravity-2&quot;&gt;Antigravity 2.0&lt;/a&gt;, Google’s platform for orchestrating multiple agents in parallel, you can export the project from Google AI Studio and keep working on it locally. It also has &lt;a rel=&quot;external&quot; href=&quot;https://github.com/firebase/agent-skills&quot;&gt;Agent Skills for Firebase&lt;/a&gt; that you can install with one click, including support for Android and iOS if you want to port the app to mobile.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;p&gt;This post is adapted from the codelab &lt;a rel=&quot;external&quot; href=&quot;https://codelabs.developers.google.com/building-ai-apps-google-ecosystem&quot;&gt;Build AI apps with the Google ecosystem&lt;/a&gt; by Marina Coelho, licensed under &lt;a rel=&quot;external&quot; href=&quot;https://creativecommons.org/licenses/by/4.0/&quot;&gt;CC BY 4.0&lt;/a&gt;. The prompts, code samples and the &lt;code&gt;DecideForMeScreen.jpeg&lt;/code&gt; mockup come from the codelab; code samples are under the &lt;a rel=&quot;external&quot; href=&quot;https://www.apache.org/licenses/LICENSE-2.0&quot;&gt;Apache 2.0 License&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Thank you for reading. &amp;lt;3&lt;/p&gt;
</content>
        
    </entry>
</feed>
