Skip to main content

Query GA4 data with Google Gemini AI in a Slack channel

Workflow preview

Workflow preview
100%
Query GA4 data with Google Gemini AI in a Slack channel preview
Open on n8n.io

1. Workflow Overview

This workflow integrates Google Analytics 4 (GA4) with Slack, enabling users to query their website data using natural language inside a dedicated Slack chan...

Best for

  • Market Research automation workflows
  • AI Chatbot automation workflows
  • intermediate n8n builders looking for reusable templates

Tools used

n8n-nodes-base.slacktrigger, n8n-nodes-base.set, @n8n/n8n-nodes-langchain.agent, n8n-nodes-base.googleanalyticstool, @n8n/n8n-nodes-langchain.lmchatgooglegemini, @n8n/n8n-nodes-langchain.memorybufferwindow, n8n-nodes-base.slack, n8n-nodes-base.stickynote

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Adil Khan.

Original n8n.io source

1.1 Workflow description

Title
Query GA4 data with Google Gemini AI in a Slack channel
Workflow name
Query GA4 data with Google Gemini AI in a Slack channel

This workflow integrates Google Analytics 4 (GA4) with Slack, enabling users to query their website data using natural language inside a dedicated Slack channel. An AI Agent interprets user queries, fetches relevant reports from GA4, and responds in Slack as a reply.

How it works When a user sends a message in a specified Slack channel, the workflow is triggered. The message is filtered to remove @bot mentions, and then passed to an AI Agent. The AI Agent, powered by a Google Gemini Chat Model and utilizing conversational memory (to have back-and-forth with user on follow up questions, limit of 10), determines if the user's query requires data from Google Analytics 4. If so, it leverages a pre-configured GA4 tool to fetch the necessary report (e.g., page views, users, conversions for a specific date range). Finally, the AI Agent's response, containing the requested data, is sent back to the original Slack channel as a reply.

Setup Steps Slack Trigger: Configure the Slack API credential and specify the channel n8n should monitor for new messages.

Credentials: Create and configure the following credentials in n8n:

Slack API: For sending and receiving messages.

Google Analytics 4: For accessing GA4 reports. Requires a Google Cloud Project with the Analytics Data API enabled and a Service Account Key (JSON).

Google Gemini Chat Model: For the AI Agent's intelligence. Requires an API key from Google AI Studio.

AI Agent System Prompt: Craft a robust system prompt for the AI agent. This prompt should define the agent's role, constraints (e.g., "do not estimate or lie on data, if GA4 is unavailable, inform so"), and guidance on mapping natural language metrics/dimensions to GA4 equivalents (e.g., "when the user mentions 'leads', they mean 'conversions' in GA4").

Slack Reply: Ensure the final Slack "Send a message" node is configured to reply to the original channel, providing the data in a clear, concise format.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Slack Trigger

Type / Role
n8n-nodes-base.slackTrigger - slackTrigger
Config choices
Version 1

Block 2 - Edit Fields

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 3 - AI Agent

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 3.1

Block 4 - Get a report in Google Analytics

Type / Role
n8n-nodes-base.googleAnalyticsTool - googleAnalyticsTool
Config choices
Version 2

Block 5 - Google Gemini Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatGoogleGemini - lmChatGoogleGemini
Config choices
Version 1

Block 6 - Simple Memory

Type / Role
@n8n/n8n-nodes-langchain.memoryBufferWindow - memoryBufferWindow
Config choices
Version 1.3

Block 7 - Send a message

Type / Role
n8n-nodes-base.slack - slack
Config choices
Version 2.4

Block 8 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

3. Summary Table

Workflow Query GA4 data with Google Gemini AI in a Slack channel
Complexity intermediate
Nodes 8
Categories Market Research, AI Chatbot
Author Adil Khan
Published 27 Jan 2026

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/13038/13038.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Query GA4 data with Google Gemini AI in a Slack channel do?

This workflow integrates Google Analytics 4 (GA4) with Slack, enabling users to query their website data using natural language inside a dedicated Slack chan...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Market Research, AI Chatbot use case.