AutomationFlowsAI & RAG › Indonesian Stock Market Research Agent with Sectors App, Gemini & Tavily

Indonesian Stock Market Research Agent with Sectors App, Gemini & Tavily

ByDzaky Jaya @hoorahyeah on n8n.io

use cases: research stock market in Indonesia. analyze the performance of companies belonging to certain subsectors or company comparing financial metrics between BBCA and BBRI providing technical analysis for certain ticker stock movement and many more*

Chat trigger trigger★★★★★ complexityAI-powered44 nodesChat TriggerChatTelegram TriggerTelegramAgentGoogle Gemini ChatMemory Postgres ChatGoogle Gemini Embeddings
AI & RAG Trigger: Chat trigger Nodes: 44 Complexity: ★★★★★ AI nodes: yes Added:

This workflow corresponds to n8n.io template #9551 — we link there as the canonical source.

This workflow follows the Agent → Chat Trigger recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "89535855-4a71-4e2d-ad84-8ab0ac01befb",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -1472,
        -112
      ],
      "parameters": {
        "public": true,
        "options": {
          "responseMode": "responseNodes",
          "allowFileUploads": true
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "33de3f5a-6c34-45b1-8fb8-e23917b97280",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        -1248,
        -208
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "1bdf7476-de5c-4ee6-a520-ff2738c27705",
              "operator": {
                "type": "object",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json.files[0] }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "9b4b354e-fe75-4715-aef6-50b3671b5a10",
      "name": "Call Sub-VectorStore",
      "type": "n8n-nodes-base.executeWorkflow",
      "position": [
        -1024,
        -208
      ],
      "parameters": {
        "options": {},
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "LGqCjjPrBqibM5YW"
        },
        "workflowInputs": {
          "value": {},
          "schema": [],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "30f878d0-1d6f-47fd-8769-c3759eb2d5b9",
      "name": "Respond to Chat",
      "type": "@n8n/n8n-nodes-langchain.chat",
      "position": [
        -1024,
        -16
      ],
      "parameters": {
        "message": "={{ $json.output }}",
        "options": {},
        "waitUserReply": false
      },
      "typeVersion": 1
    },
    {
      "id": "b7ef9dc4-849b-400a-b221-3a8ebe1e26e6",
      "name": "Sub-MainAgent",
      "type": "n8n-nodes-base.executeWorkflow",
      "position": [
        -1248,
        -16
      ],
      "parameters": {
        "options": {},
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "b5p7Eyko3sLaqPTf",
          "cachedResultName": "Sub-MainAgent"
        },
        "workflowInputs": {
          "value": {
            "chatInput": "={{ $json.chatInput }}",
            "sessionId": "={{ $json.sessionId }}"
          },
          "schema": [
            {
              "id": "chatInput",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "chatInput",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "sessionId",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "sessionId",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "chatInput"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "64c0eb7f-bbed-4b44-b61d-46fc7a58f8ba",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -1472,
        368
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "fe243728-f5ff-425b-84ee-08bde54f32ef",
      "name": "Send a text message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -1024,
        464
      ],
      "parameters": {
        "text": "={{ $json.output }}",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "486e26ae-6ef8-4338-89bb-1603086d7b57",
      "name": "If1",
      "type": "n8n-nodes-base.if",
      "position": [
        -1248,
        272
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "1bdf7476-de5c-4ee6-a520-ff2738c27705",
              "operator": {
                "type": "object",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json.files[0] }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "f7184f1a-63f6-44fd-a775-ac957eaea165",
      "name": "Call Sub-VectorStore1",
      "type": "n8n-nodes-base.executeWorkflow",
      "position": [
        -1024,
        272
      ],
      "parameters": {
        "options": {},
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "LGqCjjPrBqibM5YW"
        },
        "workflowInputs": {
          "value": {},
          "schema": [],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "44c5f4d6-e3a0-49a0-8c49-856526d5bea9",
      "name": "Sub-MainAgent1",
      "type": "n8n-nodes-base.executeWorkflow",
      "position": [
        -1248,
        464
      ],
      "parameters": {
        "options": {},
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "b5p7Eyko3sLaqPTf",
          "cachedResultName": "Sub-MainAgent"
        },
        "workflowInputs": {
          "value": {
            "chatInput": "={{ $json.message.text }}",
            "sessionId": "={{ $json.message.chat.id }}"
          },
          "schema": [
            {
              "id": "chatInput",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "chatInput",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "sessionId",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "sessionId",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "chatInput"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "a5a2a48f-ea07-4348-8254-ec27d0affdea",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -1472,
        848
      ],
      "parameters": {
        "path": "n8n_chat_agent",
        "options": {},
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "typeVersion": 2.1
    },
    {
      "id": "c341b311-5019-4667-8250-04fd31008afd",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        -1024,
        944
      ],
      "parameters": {
        "options": {},
        "respondWith": "json",
        "responseBody": "={{\n{\n  \"AIResponse\": $json.output\n}\n}}"
      },
      "typeVersion": 1.4
    },
    {
      "id": "fa1f7e6c-6060-4ba8-a707-31f238ef882e",
      "name": "If2",
      "type": "n8n-nodes-base.if",
      "position": [
        -1248,
        752
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "1bdf7476-de5c-4ee6-a520-ff2738c27705",
              "operator": {
                "type": "object",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json.files[0] }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "03a9128b-69fe-4ca8-b5f0-0b1af9aa986d",
      "name": "Call Sub-VectorStore2",
      "type": "n8n-nodes-base.executeWorkflow",
      "position": [
        -1024,
        752
      ],
      "parameters": {
        "options": {},
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "LGqCjjPrBqibM5YW"
        },
        "workflowInputs": {
          "value": {},
          "schema": [],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "356555b9-bdad-4f5b-934b-236dfbd6b841",
      "name": "Sub-MainAgent2",
      "type": "n8n-nodes-base.executeWorkflow",
      "position": [
        -1248,
        944
      ],
      "parameters": {
        "options": {},
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "b5p7Eyko3sLaqPTf",
          "cachedResultName": "Sub-MainAgent"
        },
        "workflowInputs": {
          "value": {
            "chatInput": "={{ $json.body.chatInput }}",
            "sessionId": "={{ $json.body.session_id }}"
          },
          "schema": [
            {
              "id": "chatInput",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "chatInput",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "sessionId",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "sessionId",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "chatInput"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "a3401939-fc69-4693-9cf6-64fbbd463285",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -112,
        -128
      ],
      "parameters": {
        "options": {
          "systemMessage": "=## Role\nYou are MainAdvisor, a senior Financial Advisor at Algoritma Data Science School. Your job:\n* Understand the user\u2019s intent.\n* Decide whether to answer directly or delegate to a specialized agent/tool.\n* Keep responses concise, structured, and actionable.\n\n## Tools\n1. Sub-SectorsApp \u2192 Agent specializing to perform API request to Sectors App API. Sectors App is an Indonensian Financial Data Platform providing access to financial data of almost all Indonesian company listed in IDX. use this Agent if user askin anything related to financial that need backed by data.\n2. Sub-WebSearch \u2192 News/real-time info, definitions you\u2019re unsure about, methodology references, or cross-validation of surprising results.\n3. Vector Store Knowledge \u2192 Anything about Algoritma (programs, syllabus, policy, SOP, contacts)."
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "127aef96-3af6-432a-a908-3c4b89223998",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -416,
        96
      ],
      "parameters": {
        "options": {
          "temperature": 0.4
        }
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "346d196d-20c0-42cd-9aba-afc748f5c055",
      "name": "Postgres Chat Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "position": [
        -272,
        96
      ],
      "parameters": {
        "sessionKey": "={{ $json.sessionId }} - {{ $workflow.id }}",
        "sessionIdType": "customKey"
      },
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "b6e77799-57c8-4a50-8f9f-f67226a01f77",
      "name": "Embeddings Google Gemini1",
      "type": "@n8n/n8n-nodes-langchain.embeddingsGoogleGemini",
      "position": [
        -48,
        304
      ],
      "parameters": {
        "modelName": "models/gemini-embedding-001"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "f870cd50-9989-450f-855b-632d3cb3a0d6",
      "name": "VectorStore-CompanyKnowledge",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "position": [
        -128,
        96
      ],
      "parameters": {
        "mode": "retrieve-as-tool",
        "topK": 10,
        "options": {},
        "tableName": {
          "__rl": true,
          "mode": "list",
          "value": "documents",
          "cachedResultName": "documents"
        },
        "toolDescription": "use this tool to retrieve data from vector store. contains all knowledge about company data"
      },
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "fafa4188-b589-426d-9be1-5bb0a230d29c",
      "name": "Sub-SectorsApp",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        160,
        96
      ],
      "parameters": {
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "vUOIGDlMVpho9tAd",
          "cachedResultName": "Sub-SectorsApp"
        },
        "description": "Agent specialized to call Sectors App API to retrieve real-time financial data",
        "workflowInputs": {
          "value": {},
          "schema": [],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "b2644015-910d-4373-a68f-5eb4e28ebe3e",
      "name": "Sub-WebSearch",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        304,
        96
      ],
      "parameters": {
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "itVZLOt01TdRZ0pE",
          "cachedResultName": "Sub-WebSearch"
        },
        "description": "AI Agent specialized in web search for retrieve real-time data and validate unsure opinion",
        "workflowInputs": {
          "value": {},
          "schema": [],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "06b89197-e32f-4b73-9636-f7aee04fc636",
      "name": "Start",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        -592,
        -128
      ],
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "chatInput",
              "type": "any"
            },
            {
              "name": "sessionId",
              "type": "any"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "c6b9aa77-1db8-44dc-98a9-8f6f051b9c19",
      "name": "GetCompanies",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        -304,
        800
      ],
      "parameters": {
        "url": "https://api.sectors.app/v1/companies",
        "options": {},
        "sendQuery": true,
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters0_Name', ``, 'string') }}",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters0_Value', ``, 'string') }}"
            },
            {
              "name": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters1_Name', ``, 'string') }}",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters1_Value', ``, 'string') }}"
            },
            {
              "name": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters2_Name', ``, 'string') }}",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters2_Value', ``, 'string') }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {}
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "b9ce0641-6f80-485c-86b2-6fcf57d4a3a5",
      "name": "GetSubsectors",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        -448,
        800
      ],
      "parameters": {
        "url": "https://api.sectors.app/v1/subsectors",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "toolDescription": "Get subsectors data from Sectors App API"
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "a467e607-8823-42e9-8c72-66239b62cd2d",
      "name": "Google Gemini Chat Model2",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -608,
        800
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "4ec6a8db-f0df-49f4-9866-3efb5d7ccaf9",
      "name": "Spec Agent - Sectors App",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -496,
        592
      ],
      "parameters": {
        "text": "={{ $json.query }}",
        "options": {
          "systemMessage": "=## Overview\nYou have access to the Sectors App API companies list endpoint through an HTTP request tool. This endpoint allows you to filter and analyze companies by subsector or sub-industry with sorting capabilities on various financial metrics.\n\n## About Sectors App\nSectors is an Indonesian Financial Data Platform providing real-time and accurate financial data to almost all Indonesian company listed in IDX.\n\n## Available Tools\nYou have access to two tools:\n1. **GetSubsector**: Returns list of all available subsectors from Sectors API\n2. **GetCompanies**: Makes the companies list API call\n\n## When to Use This Endpoint\nUse this endpoint when users ask about:\n- Companies in specific sectors or industries\n- Company rankings by financial metrics\n- Comparative analysis within industries\n- Investment opportunities in particular sectors\n- Market leaders in specific business areas\n\n## Workflow: Subsector Validation Process\n\n### ALWAYS Follow This 2-Step Process:\n\n#### Step 1: Validate Subsector Name\n**Before making any companies list API call, ALWAYS use the GetSubsector tool first to:**\n- Get the complete list of available subsectors\n- Verify the exact spelling and formatting required\n- Find the closest match to user's request if needed\n\n#### Step 2: Make Companies List API Call\nOnly after confirming the correct subsector name, proceed with the HTTP request.\n\n### Subsector Validation Examples:\n\n**User asks: \"Show me banking companies\"**\n1. \u2705 First: Use GetSubsector tool\n2. \u2705 Find: \"banks\" (not \"banking\")\n3. \u2705 Then: Make API call with `sub_sector=banks`\n\n**User asks: \"Technology companies\"**\n1. \u2705 First: Use GetSubsector tool  \n2. \u2705 Check available options (might be \"software\", \"hardware\", etc.)\n3. \u2705 Ask user for clarification or choose most relevant\n4. \u2705 Then: Make API call with correct parameter\n\n### Handling Subsector Mismatches:\n\n**If user's requested subsector doesn't exist:**\n- Show available subsectors from GetSubsector response\n- Suggest the closest alternatives\n- Ask user to choose or proceed with your best match\n- Explain why you're suggesting specific alternatives\n\n**Example response for mismatch:**\n```\nI checked the available subsectors and \"technology\" isn't a direct match. However, I found these related options:\n- \"software\" - for software companies\n- \"semiconductors\" - for chip manufacturers  \n- \"telecommunications\" - for telecom companies\n\nWhich would you prefer, or would you like me to analyze software companies as the closest match?\n```\n\n## HTTP Request Configuration\n\n### Base URL\n```\nGET https://api.sectors.app/v1/companies/\n```\n\n### Required Headers\n```\nAuthorization: <API_KEY>\n```\n\n### Query Parameters\n**Choose ONE filter (never use both):**\n- `sub_sector`: Use for broader sector filtering (e.g., \"banks\", \"financing-service\", \"insurance\", \"retailing\", \"tobacco\")\n- `sub_industry`: Use for more specific industry filtering (e.g., \"paper\", \"life-insurance\", \"personal-care-products\", \"software\", \"gold\")\n\n**Format requirements:** Always use kebab-case (lowercase, separated by hyphens)\n\n**Optional sorting parameters:**\n- `sort_by`: Choose from `symbol`, `company_name`, `market_cap`, `dividend_yield`, `total_dividend`, `revenue`, `earnings`, `pb`, `pe`, `ps`\n- `desc`: Set to `true` for descending order, `false` for ascending (default: `false`)\n\n### Example Request Structure\n```\nGET https://api.sectors.app/v1/companies/?sub_sector=banks&sort_by=market_cap&desc=true\n```\n\n## Response Analysis Guidelines\n\n### 1. Data Interpretation\nWhen you receive the response:\n- **DO NOT** return raw JSON data to users\n- Analyze the data for meaningful insights\n- Identify top performers, trends, and notable patterns\n- Compare metrics across companies where relevant\n\n### 2. Key Metrics to Focus On\n- **Market Cap**: Company size and market value\n- **P/E Ratio**: Valuation relative to earnings\n- **P/B Ratio**: Valuation relative to book value\n- **Dividend Yield**: Income potential for investors\n- **Revenue & Earnings**: Financial performance indicators\n\n### 3. Insight Categories to Provide\n\n**Market Leaders:**\n- Identify companies with highest market caps\n- Note dominant players in the sector/industry\n\n**Valuation Analysis:**\n- Compare P/E and P/B ratios to identify potentially undervalued/overvalued stocks\n- Highlight companies with attractive valuations\n\n**Income Opportunities:**\n- Point out high dividend-yielding companies\n- Analyze dividend sustainability based on other metrics\n\n**Growth Potential:**\n- Identify companies with strong revenue/earnings growth\n- Note emerging players vs established leaders\n\n### 4. Response Format\n\n**Always structure your response with:**\n\n1. **Executive Summary** (2-3 sentences)\n   - Key findings from the data\n   - Most important insights for investors\n\n2. **Top Companies** (3-5 companies if not specified by the user)\n   - Brief analysis of market leaders\n   - Why they stand out\n\n3. **Investment Insights**\n   - Valuation observations\n   - Risk/opportunity highlights\n   - Sector-specific considerations\n\n4. **Notable Mentions**\n   - Interesting outliers or emerging companies\n   - Unique characteristics worth noting\n\n### 5. Example Response Structure\n```\nBased on the banking sector analysis:\n\n**Executive Summary:**\nThe banking sector shows [key insight about valuations/performance]. Market leaders like [Company A] dominate with $X billion market cap, while [trend observation] across the sector.\n\n**Top Market Leaders:**\n1. [Company Name] - $X billion market cap, P/E of Y, notable for [specific strength]\n2. [Company Name] - Strong dividend yield of X%, indicating [analysis]\n3. [Company Name] - Trading at attractive P/B ratio of X, suggesting [insight]\n\n**Investment Insights:**\n- Valuation: [Analysis of sector valuations compared to historical norms]\n- Income: [Dividend yield analysis and sustainability]\n- Risk Factors: [Sector-specific considerations]\n\n**Notable Mentions:**\n[Highlight 1-2 interesting smaller companies or unusual metrics]\n```\n\n## Error Handling & Edge Cases\n\n### GetSubsector Tool Issues:\n**If GetSubsector tool fails:**\n- Inform user that subsector validation is temporarily unavailable\n- Proceed with commonly known subsectors (banks, insurance, retailing) if confident\n- Suggest user try again later for verification\n\n**If subsector not found in GetSubsector response:**\n- List 3-5 closest alternative subsectors\n- Explain the difference between alternatives\n- Let user choose or proceed with your recommended match\n\n### If API Returns Limited Data:\n- Provide a summary of available information\n- Explain limitations clearly\n- Suggest alternative approaches or related sectors to explore\n\n### If No Companies Match Criteria:\n- Double-check subsector name was validated correctly\n- Suggest similar or related sectors from GetSubsector results\n- Provide general market context\n\n### If Companies List Request Fails:\n- Verify subsector name matches exactly what GetSubsector returned\n- Check if the API key is properly configured\n- Inform user of technical issues and suggest retry\n\n## Best Practices\n\n1. **ALWAYS validate subsectors first** - Use GetSubsector tool before every companies list API call\n2. **Always contextualize data** - Don't just list numbers, explain what they mean\n3. **Compare relatively** - Show how companies rank against peers\n4. **Consider market conditions** - Factor in current market environment when relevant\n5. **Highlight actionable insights** - Focus on information useful for investment decisions\n6. **Keep responses concise but comprehensive** - Balance detail with readability\n7. **Handle ambiguity gracefully** - When multiple subsectors could match user's request, offer choices\n\n## Sample User Queries & Complete Workflow\n\n**\"Show me the top software companies\"**\n1. \u2705 Use GetSubsector tool to confirm \"software\" is available\n2. \u2705 Use `sub_industry=software`, sort by `market_cap`, desc=true\n3. \u2705 Analyze and provide insights\n\n**\"Which banks pay the best dividends?\"**\n1. \u2705 Use GetSubsector tool to verify \"banks\" subsector exists\n2. \u2705 Use `sub_sector=banks`, sort by `dividend_yield`, desc=true\n3. \u2705 Focus analysis on dividend sustainability and yields\n\n**\"Find undervalued insurance companies\"**\n1. \u2705 Use GetSubsector tool to confirm \"insurance\" is correct\n2. \u2705 Use `sub_sector=insurance`, sort by `pb` or `pe`, desc=false\n3. \u2705 Analyze for low ratios and value opportunities\n\n**\"Show me tech companies\" (ambiguous request)**\n1. \u2705 Use GetSubsector tool to see available options\n2. \u2705 Present options: \"software\", \"semiconductors\", etc.\n3. \u2705 Ask user to clarify or proceed with most relevant match\n4. \u2705 Make API call and analyze results\n\nRemember: Your goal is to transform raw financial data into actionable investment insights that help users make informed decisions.\n"
        },
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "e0972080-8b8b-408f-bbec-6e660fbad44e",
      "name": "Embeddings Google Gemini",
      "type": "@n8n/n8n-nodes-langchain.embeddingsGoogleGemini",
      "position": [
        608,
        816
      ],
      "parameters": {
        "modelName": "models/gemini-embedding-001"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "a8adebe2-c411-4edf-b048-1d410cdac8a3",
      "name": "Default Data Loader",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        784,
        816
      ],
      "parameters": {
        "options": {},
        "dataType": "binary"
      },
      "typeVersion": 1.1
    },
    {
      "id": "8f2e67d1-1be4-4057-a42e-06cb56448322",
      "name": "Supabase Vector Store",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "position": [
        592,
        592
      ],
      "parameters": {
        "mode": "insert",
        "options": {},
        "tableName": {
          "__rl": true,
          "mode": "list",
          "value": "documents",
          "cachedResultName": "documents"
        },
        "embeddingBatchSize": 32
      },
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "654852fd-ec52-469a-90e1-eb87978052e0",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        464,
        480
      ],
      "parameters": {
        "color": 3,
        "width": 480,
        "height": 480,
        "content": "## Vector Document Processing\nhandling input document to vector store"
      },
      "typeVersion": 1
    },
    {
      "id": "9abb81e7-491d-4c02-979e-c70bec3c9e05",
      "name": "Google Gemini Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -32,
        800
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "42dcda6d-ba04-4642-9cf2-c621b28b035f",
      "name": "Spec Agent - Web Search",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        48,
        592
      ],
      "parameters": {
        "text": "={{ $json.query }}",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "2ae27f8f-b7e2-4423-b9d9-9ff362f3ec1a",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1552,
        176
      ],
      "parameters": {
        "width": 800,
        "height": 448,
        "content": "## Input - Telegram Bot\nreceive and process input from native n8n ui chat"
      },
      "typeVersion": 1
    },
    {
      "id": "61c214d6-d95d-4356-8200-16c8b0cd3ad4",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1552,
        -304
      ],
      "parameters": {
        "width": 800,
        "height": 448,
        "content": "## Input - Native n8n Chat UI\nreceive and process input from native n8n ui chat"
      },
      "typeVersion": 1
    },
    {
      "id": "8841111a-b8ec-4c28-875d-82ccab53d918",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1552,
        656
      ],
      "parameters": {
        "width": 800,
        "height": 448,
        "content": "## Input - Web UI (Webhook)\nreceive and process input from native n8n ui chat"
      },
      "typeVersion": 1
    },
    {
      "id": "c8c1be34-f077-41ca-826a-df5f901ec384",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -672,
        -288
      ],
      "parameters": {
        "color": 5,
        "width": 1104,
        "height": 736,
        "content": "## Main Agent\nprocessing request and delegate task to specialized agent"
      },
      "typeVersion": 1
    },
    {
      "id": "faf416f8-bbfe-4bb0-a9d3-2db642b587ab",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -672,
        480
      ],
      "parameters": {
        "color": 4,
        "width": 560,
        "height": 672,
        "content": "## Specialized Agent - Sectors App\nhandling data request through Sectors App API"
      },
      "typeVersion": 1
    },
    {
      "id": "a516400f-65e9-47de-ac1b-c9d500358445",
      "name": "WebSeach - Tavily",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        288,
        816
      ],
      "parameters": {
        "url": "https://api.tavily.com/search",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "query",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters0_Value', `The search query to execute`, 'string') }}"
            },
            {
              "name": "topic",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters1_Value', `The category of the search. news is useful for retrieving real-time updates, particularly about politics, sports, and major current events covered by mainstream media sources. general is for broader, more general-purpose searches that may include a wide range of sources.\nAvailable options: \\`general\\`, \\`news\\`, \\`finance\\` `, 'string') }}"
            },
            {
              "name": "search_depth",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters2_Value', `The depth of the search. advanced search is tailored to retrieve the most relevant sources and content snippets for your query, while basic search provides generic content snippets from each source\nAvailable options: \\`basic\\`, \\`advances\\``, 'string') }}"
            },
            {
              "name": "start_date",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters3_Value', `Will return all results after the specified start date ( publish date ). Required to be written in the format YYYY-MM-DD`, 'string') }}"
            },
            {
              "name": "end_date",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters4_Value', `Will return all results before the specified end date ( publish date ). Required to be written in the format YYYY-MM-DD`, 'string') }}"
            }
          ]
        },
        "genericAuthType": "httpHeaderAuth",
        "toolDescription": "search through the web to find real-time information and verify uncertainty."
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "4c0f3ba7-fb62-4ef5-83ef-89911c708b3f",
      "name": "WebSearch - Google Grounding",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        128,
        864
      ],
      "parameters": {
        "url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"contents\": [\n    {\n      \"parts\": [\n        {\n          \"text\": \"{{ $fromAI(\"question\", \"pertanyaan yang ingin dicari\") }}\"\n        }\n      ]\n    }\n  ],\n  \"tools\": [\n    {\n      \"google_search\": {}\n    }\n  ]\n} ",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "toolDescription": "make web search using google grounding",
        "headerParameters": {
          "parameters": [
            {
              "name": "x-goog-api-key",
              "value": "$GOOGLE_API_KEY"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "fae4b90c-c183-4afb-b142-3d38f3c5fc28",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        480
      ],
      "parameters": {
        "color": 4,
        "width": 512,
        "height": 560,
        "content": "## Specialized Agent - Web Grounding\nsearch real time information to verify answer"
      },
      "typeVersion": 1
    },
    {
      "id": "34d12b9d-63c5-41c0-8765-4ec2959cd907",
      "name": "GetDailyTransData",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        -608,
        976
      ],
      "parameters": {
        "url": "=https://api.sectors.app/daily/{{ $fromAI(\"ticker\", \"ticker or stock code\") }}",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "toolDescription": "Return daily transaction data of a given ticker on a certain interval (up to 90 days)"
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "df4c1260-dd23-4a34-8cd1-696044289bb9",
      "name": "GetCompanyReport",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        -448,
        976
      ],
      "parameters": {
        "url": "=https://api.sectors.app/company/report/{{ $fromAI(\"ticker\", \"ticker or stock code\", \"string\", \"BBCA\") }}",
        "options": {},
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "sections",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters0_Value', `Sections of the company report that is to be retrieved (default to all).\nAvailable sections: overview, valuation, future, peers, financials, dividend, management, ownership\nUse comma to separate each section when retrieving data of more than one section.`, 'string') }}"
            }
          ]
        },
        "toolDescription": "Return report of a given ticker, organized into distinct sections"
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "17430343-dba0-4cfb-b9ee-9b2d1edcef1f",
      "name": "GetTopCompaniesRanked",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        -272,
        976
      ],
      "parameters": {
        "url": "https://api.sectors.app/companies/top",
        "options": {},
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "classifications",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters0_Value', `Comma-separated list of classifications to rank. Defaults to all: dividend_yield, total_dividend, revenue, earnings, market_cap, pb, pe, ps.`, 'string') }}"
            },
            {
              "name": "year",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters1_Value', `Year for which to compute rankings (e.g. 2024). Defaults to the current year.`, 'string') }}"
            },
            {
              "name": "n_stock",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters2_Value', `Number of tickers per classification (default 5).`, 'string') }}"
            },
            {
              "name": "sub_sector",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters3_Value', `Filter by subsector (kebab\u2011case). Get the available sub_sector from the GetSubsectors tool if unsure. \nexamples: banks, financing-service, insurance, retailing, tobacco`, 'string') }}"
            },
            {
              "name": "min_mcap_billion",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters4_Value', `Minimum market cap (in IDR billions) for companies to include (e.g. 1000 for IDR 1 trillion).`, 'string') }}"
            }
          ]
        },
        "toolDescription": "Return a list of top tickers in a given year based on selected classifications (dividend yield, total dividend, revenue, earnings, market cap, PB ratio, PE ratio, or PS ratio). Supports filtering, logical combination, and inclusion of null metrics."
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    }
  ],
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Call Sub-VectorStore",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If1": {
      "main": [
        [
          {
            "node": "Call Sub-VectorStore1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If2": {
      "main": [
        [
          {
            "node": "Call Sub-VectorStore2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "Sub-MainAgent2",
            "type": "main",
            "index": 0
          },
          {
            "node": "If2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GetCompanies": {
      "ai_tool": [
        [
          {
            "node": "Spec Agent - Sectors App",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "GetSubsectors": {
      "ai_tool": [
        [
          {
            "node": "Spec Agent - Sectors App",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Sub-MainAgent": {
      "main": [
        [
          {
            "node": "Respond to Chat",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sub-WebSearch": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Sub-MainAgent1": {
      "main": [
        [
          {
            "node": "Send a text message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sub-MainAgent2": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sub-SectorsApp": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "GetCompanyReport": {
      "ai_tool": [
        [
          {
            "node": "Spec Agent - Sectors App",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Sub-MainAgent1",
            "type": "main",
            "index": 0
          },
          {
            "node": "If1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GetDailyTransData": {
      "ai_tool": [
        [
          {
            "node": "Spec Agent - Sectors App",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "WebSeach - Tavily": {
      "ai_tool": [
        [
          {
            "node": "Spec Agent - Web Search",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Supabase Vector Store",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Postgres Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "GetTopCompaniesRanked": {
      "ai_tool": [
        [
          {
            "node": "Spec Agent - Sectors App",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings Google Gemini": {
      "ai_embedding": [
        [
          {
            "node": "Supabase Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings Google Gemini1": {
      "ai_embedding": [
        [
          {
            "node": "VectorStore-CompanyKnowledge",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Spec Agent - Web Search",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "Spec Agent - Sectors App",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          },
          {
            "node": "Sub-MainAgent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "VectorStore-CompanyKnowledge": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "WebSearch - Google Grounding": {
      "ai_tool": [
        [
          {
            "node": "Spec Agent - Web Search",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

use cases: research stock market in Indonesia. analyze the performance of companies belonging to certain subsectors or company comparing financial metrics between BBCA and BBRI providing technical analysis for certain ticker stock movement and many more*

Source: https://n8n.io/workflows/9551/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

This workflow acts as a 24/7 sales agent, engaging leads across WhatsApp, Instagram, Facebook, Telegram, and your website. It intelligently transcribes audio messages, answers questions using a knowle

Chat Trigger, Memory Postgres Chat, Tool Workflow +20
AI & RAG

• Create a Google Drive folder to watch. • Connect your Google Drive account in n8n and authorize access. • Point the Google Drive Trigger node to this folder (new/modified files trigger the flow).

Agent, Chat Trigger, Memory Buffer Window +14
AI & RAG

The workflow operates through a three-step process that handles incoming chat messages with intelligent tool orchestration: Message Trigger: The node triggers whenever a user message arrives and passe

Chat Trigger, Memory Postgres Chat, OpenAI Embeddings +16
AI & RAG

An extendable RAG template to build powerful, explainable AI assistants — with query understanding, semantic metadata, and support for free-tier tools like Gemini, Gemma and Supabase.

Document Default Data Loader, Text Splitter Recursive Character Text Splitter, Supabase +9
AI & RAG

A complete AI-powered study assistant system that lets you chat naturally with your documents stored in Google Drive:

Google Gemini Embeddings, Supabase Vector Store, Memory Postgres Chat +9