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.
- Go to aistudio.google.com and sign in with your Google account
- Click Get API key in the left sidebar
- Click Create API key, select or create a project
- 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
- In n8n, go to Credentials → Add Credential → Header Auth
- Set:
- Name:
Gemini API (AI Studio) - Header Name:
x-goog-api-key - Header Value: your API key
- Name:
- 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
reposcope (private repos) orpublic_reposcope (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
maxOutputTokensto 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.tsfrom 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:
- Go to aistudio.google.com
- Click New prompt → Freeform
- Paste a real error log or code diff and experiment with the prompt wording
- 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.