ANTIGRAVITY LABJP
Articles/Integrations
Integrations/2026-04-04Intermediate

Automating Your Antigravity Development Workflow with n8n and Google AI Studio

Learn how to combine n8n's no-code automation with Google AI Studio's Gemini API to intelligently streamline your Antigravity development process — including PR reviews, error analysis, and more.

n8n3google-ai-studiogemini-api7automation79antigravity429integrations20

Bridging n8n and Google AI Studio in Your Antigravity Workflow

Antigravity is a powerful AI-native development environment, but the surrounding workflow — PR reviews, error triage, deployment quality checks — still involves a lot of manual effort. That's where n8n (a visual, no-code workflow automation tool) and Google AI Studio (the developer portal for the Gemini API) come in.

By connecting these two tools, you can build intelligent automation around your Antigravity development cycle:

  • When a GitHub PR is opened, Gemini automatically drafts a code review and posts it to Slack
  • When an error log appears in Slack, Gemini analyzes the cause and suggests a fix — automatically
  • Periodically call the Gemini API to generate code quality summaries and log them to Notion

This guide walks through both workflows with full setup instructions and troubleshooting tips.


What You'll Need

  • An n8n account (free n8n.cloud tier works)
  • A Gemini API key from Google AI Studio (aistudio.google.com)
  • GitHub, Slack, and/or Notion accounts depending on which workflow you build

Getting Your API Key from Google AI Studio

Google AI Studio is where you experiment with Gemini models and manage API access.

  1. Go to aistudio.google.com and sign in with your Google account
  2. Click Get API key in the left sidebar
  3. Click Create API key, select or create a project
  4. Copy the key immediately — it's only shown once

Security tip: Store your API key in n8n's Credentials manager. Never hardcode it in workflow nodes or expose it in logs.


Setting Up the Gemini API Credential in n8n

  1. In n8n, go to Credentials → Add Credential → Header Auth
  2. Set:
    • Name: Gemini API (AI Studio)
    • Header Name: x-goog-api-key
    • Header Value: your API key
  3. Click Save

Workflow 1: Automated PR Code Review with Gemini

When a PR is opened in your repo, this workflow fetches the code diff and sends Gemini's review comments to Slack — instantly.

Workflow Structure

GitHub Trigger (PR opened)
  ↓
HTTP Request (fetch PR diff via GitHub API)
  ↓
HTTP Request (Gemini API: generate review)
  ↓
Slack (post review to channel)

Step 1 — GitHub Trigger

Add a GitHub Trigger node:

  • Connect your GitHub account (Personal Access Token)
  • Event: pull_request, Action: opened

Step 2 — Fetch the Diff

The trigger gives you PR metadata, not the actual diff. Add an HTTP Request node:

Method: GET
URL: {{ $json.pull_request.url }}/files
Authentication: Header Auth (GitHub PAT as Bearer token)

Step 3 — Call Gemini API

Add another HTTP Request node:

Method: POST
URL: https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent
Authentication: Header Auth → Gemini API credential
Content-Type: application/json

Request Body:

{
  "contents": [
    {
      "parts": [
        {
          "text": "Please review the following code diff. Identify improvements, potential bugs, and security concerns. Also acknowledge what's done well. Be concise and constructive.\n\n```\n{{ $json[0].patch }}\n```"
        }
      ]
    }
  ],
  "generationConfig": {
    "temperature": 0.3,
    "maxOutputTokens": 1024
  }
}

Step 4 — Post to Slack

Add a Slack node and set the message body:

🤖 *Auto PR Review*: {{ $json.pull_request.title }}

{{ $json.content[0].text }}

Workflow 2: Gemini-Powered Error Log Analysis

When an error appears in your Slack channel (from Antigravity, Cloudflare Workers, or any service), Gemini automatically replies with a root cause analysis and fix suggestions.

Workflow Structure

Slack Trigger (message received)
  ↓
IF Node (message contains "Error" or "Exception")
  ↓ YES
HTTP Request (Gemini API: analyze error)
  ↓
Slack (reply to thread with analysis)

Gemini Prompt:

{
  "contents": [
    {
      "parts": [
        {
          "text": "Analyze the following error log and provide: (1) likely root cause, (2) suggested fix, (3) prevention tips.\n\nError:\n{{ $json.text }}"
        }
      ]
    }
  ]
}

Troubleshooting Common Issues

Issue 1: GitHub API Returns 403

Symptom: 403 Forbidden when fetching the PR diff.

Fix:

  • Your GitHub Personal Access Token needs the repo scope (private repos) or public_repo scope (public)
  • In n8n, configure it as a Header Auth credential with Authorization: Bearer YOUR_PAT
  • Make sure the token hasn't expired

Issue 2: Gemini Response Is Truncated

Symptom: The review comment cuts off mid-sentence.

Fix:

  • Increase maxOutputTokens to 2048 or 4096 for code review use cases
  • If the diff is very large, split it using a Set node to pass one file at a time

Issue 3: GitHub Trigger Doesn't Fire

Symptom: Opening a PR doesn't trigger the n8n workflow.

Fix:

  • In n8n.cloud, the Webhook URL is auto-generated — confirm it's registered in your GitHub repo's Settings → Webhooks
  • For self-hosted n8n, make sure the instance is publicly accessible (SSL + domain required)
  • Use GitHub's "Recent Deliveries" feature to replay the webhook payload for debugging

Issue 4: Slack Reply Goes to Wrong Thread

Symptom: The analysis posts as a new message instead of a thread reply.

Fix:

  • Set the Slack node's Thread TS field to $json.ts from the original Slack trigger
  • This ensures Gemini's response appears as a threaded reply to the original error message

Issue 5: Request Body Too Large

Symptom: Error: request body is too large for big PRs.

Fix:

  • Limit the diff size in a Set node before sending to Gemini:
{
  "limitedPatch": "{{ $json[0].patch.slice(0, 5000) }}"
}

Tuning Prompts in Google AI Studio Before Deploying

Before running a workflow in production, test your prompts in Google AI Studio's Freeform prompt interface:

  1. Go to aistudio.google.com
  2. Click New prompt → Freeform
  3. Paste a real error log or code diff and experiment with the prompt wording
  4. Once the output quality is satisfactory, copy the prompt directly into your n8n workflow

This approach saves API costs and prevents poorly-worded prompts from running thousands of times before you notice they're not working well.


Wrapping Up

Adding n8n and Google AI Studio to your Antigravity workflow doesn't require a major infrastructure change — just a few nodes and a Gemini API key. Start with automated PR reviews for a single repository, verify the output quality, and then expand from there.

The troubleshooting section covers the most common obstacles, so you should be able to get to a working workflow within an afternoon.

Share

Thank You for Reading

Antigravity Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

If you found this article helpful, a small tip ($1.50) would mean a lot to us. Your support helps keep this site ad-free and covers server and hosting costs.

Related Articles

Integrations2026-03-28
Building Custom AI Development Tools with Antigravity and Gemini API
Learn how to integrate Gemini API with Antigravity IDE to build custom AI-powered development tools — from automated code review to documentation generation and test scaffolding, with production-ready implementation patterns.
Integrations2026-07-08
When Successful Automation Quietly Stops Earning Its Keep: Designing for Value Decay and Retirement
A dashboard full of green success logs often hides the most dangerous kind of failure. Here is a design — with working code — for surfacing automations that keep succeeding while producing no value, and deciding whether to retire, repair, or keep them.
Integrations2026-06-28
Where to Start Reading an Unattended Agent's Changes — A Digest for Re-Entry
How do you review the pile of changes an unattended agent left overnight? Not the full diff, not the chat log — a re-entry digest grouped by risk class.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →