← All N8N workflows
AI & researchAgentAggregateChat TriggerCodeExecute Workflow Trigger

Some questions to try

Configured with Agent, Aggregate, Chat Trigger, Execute Workflow Trigger, and additional nodes. Review the connections and setup before adapting this template.

Workflow preview
TriggerWhen chat messagereceivedChat TriggerAI & modelsAI AgentAgentAI & modelsOpenAI Chat ModelOpenAI Chat ModelIntegrationCalculatorTool CalculatorCodeCodeCodeTriggerWhen Executed byAnother WorkflowExecute Workflow TriggerSubworkflowRecords by dateTool WorkflowTransformAggregateAggregateWeb / APIGoogle Sheets requestHTTP RequestData storeGet transactions byproduct nameGoogle Sheets ToolData storeGet all transactionsGoogle Sheets ToolData storeBuffer MemoryMemory Buffer WindowRoutingFilter by statusFilterData storeGet transactions bystatusGoogle Sheets Tool

Node categories in this workflow

  • Trigger
  • AI & models
  • Integration
  • Code
  • Subworkflow
  • Transform
  • Web / API
  • Data store
  • Routing

Icons describe general node roles, inferred from node types. Inspect the parameters for the configured action.

Drag to pan; use + and − to zoom. Reconstructed from the exported node positions; nothing runs here. Dashed lines represent non-main connections. Full node names and notes appear below.

How it works

The exported workflow contains the following configured nodes. Their connections are shown above; inspect the JSON for the complete logic, expressions, and external actions.

Workflow node names, types, and operations
NodeCategoryTypeOperation
When chat message receivedTriggerChat TriggerSee node parameters
AI AgentAI & modelsAgentSee node parameters
OpenAI Chat ModelAI & modelsOpenAI Chat ModelSee node parameters
CalculatorIntegrationTool CalculatorSee node parameters
CodeCodeCodeSee node parameters
When Executed by Another WorkflowTriggerExecute Workflow TriggerSee node parameters
Records by dateSubworkflowTool WorkflowSee node parameters
AggregateTransformAggregateSee node parameters
Google Sheets requestWeb / APIHTTP RequestSee node parameters
Get transactions by product nameData storeGoogle Sheets ToolSee node parameters
Get all transactionsData storeGoogle Sheets ToolSee node parameters
Buffer MemoryData storeMemory Buffer WindowSee node parameters
Filter by statusRoutingFilterSee node parameters
Get transactions by statusData storeGoogle Sheets ToolSee node parameters

Setup

  1. Download the JSON and import it into an isolated n8n instance. Leave the workflow inactive.
  2. Connect your own credentials through n8n’s credential store. Replace REPLACE_WITH_* values with your resource identifiers.
  3. Inspect API destinations, Code nodes, database queries, file paths, and outbound actions.
  4. Run with synthetic data and harmless destinations. Enable triggers only after checking the actual outputs.

Requirements

An n8n instance with the listed node types and compatible versions. Service-connected workflows may require accounts, credentials, or paid APIs.

Credential types declared in the source

  • googleSheetsOAuth2Api
  • openAiApi

Workflow notes

Sticky Note

To send all the items back to the AI, we need to finish with everything aggregated into one single item.

Otherwise it will respond with one item at a time, and the AI will only get the first item that arrives.

Sticky Note1

This node sends a custom HTTP Request to the Google Sheets API.

Filtering by date range in the Google Sheets API is very complicated.

This node solves that problem.

But doing the same in a database is much simpler. A tool could do it without needing a sub-workflow.

Sticky Note2

The output from this complex request is also messy.

So we use some code generated by ChatGPT to transform the data into JSON objects.

Some questions to try

Some questions to try

There's a red button on this page that you can click to chat with the AI.

Try asking it these questions:

  • How many refunds in January and what was the amount refunded?

  • How many successful sales did we have in January 2025 and what was the final income of those?

  • What is the most frequent reason for refunds?

Copy this Sheets file to your Google Drive

Copy this Sheets file to your Google Drive

https://docs.google.com/spreadsheets/d/REPLACE_WITH_DOCUMENT_ID/edit?gid=0#gid=0

👈

👈

The Calculator is a tool that allows an agent to run mathematical calculations.

How to connect to Google Sheets?

How to connect to Google Sheets?

To connect your n8n to your Google Sheets you're gonna need Google OAuth credentials

See documentation here

👆

👆

You can use many models here, including the free Google Gemini options.

Make sure to test it thoroughly. Some models are better for data analysis.

👆

👆

This is a short term memory. It will remember the 5 previous interactions during the chat

Sticky Note9

The AI Tools Agent has access to all the tools at the same time. It uses the name and description to decide when to use each tool.

Notice I'm using $fromAI function in all of them.

See documentations here

👈 This is a special tool

👈 This is a special tool

It is used to call another workflow. This concept is called sub-workflow.

See documentation here.

Instead of running a completely separate workflow, we are calling the one below.

It's contained in the same workflow, but we are using the trigger to define it will run only when called by this tool.

Sub-workflow

Sub-workflow

The AI can call this sub-workflow anytime, by using the Records by date tool.

The sub-workflow automatically return the result of the last executed node to the AI.

Author

Author

Solomon

Freelance consultant from Brazil, specializing in automations and data analysis. I work with select clients, addressing their toughest projects.

Currently running the Scrapes community with Simon 💪

For business inquiries, email me at user@example.com Or message me on Telegram for a faster response.

Check out my other templates

👉 https://n8n.io/creators/solomon/

Need help?

Need help?

For getting help with this workflow, please create a topic on the community forums here: https://community.n8n.io/c/questions/

Some questions to try

Some questions to try

Purpose and structure

This folder contains the Some questions to try workflow. Its executable nodes use agent, aggregate, chatTrigger, code, executeWorkflowTrigger, filter, googleSheetsTool, httpRequest, lmChatOpenAi, memoryBufferWindow, toolCalculator, toolWorkflow. The table and connection map below are derived from the JSON, not an inferred guarantee of behavior.

Setup

Import inactive. Configure your own credentials and replace REPLACE_WITH_* values. Review external destinations and Code nodes before running.

Entry points

When chat message received, When Executed by Another Workflow

Verification

Sanitized source candidate; not runtime-tested. This overview is generated from node metadata. Read the folder README for the connection map, credential types, and license.

Attribution

https://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/workflows/Code/0767_Code_Filter_Send_Webhook.json MIT; preserve source notices.

Canvas section labels

These name areas of the original canvas; they do not include explanatory instructions.

  • Change the URL of the Sheets file in all the Sheets tools 👇
  • 👆 Change the URL of the Sheets file

More in AI & research