Promo Code Finder using AI Agents, SerpAPI, and Caching - n8n Workflow

This powerful n8n workflow automatically finds active promo codes using an AI agent (Gemini 2.5 Pro) and SerpAPI, caches results in a Data Table, and notifies users via Telegram or Gmail.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Individuals or businesses looking for powerful n8n templates that combine real-time web search with AI validation.
E-commerce marketers needing an automated tool to track competitor discounts or offer customer service via bot.
Developers wanting to study a complex n8n workflow integrating LangChain agents, multiple triggers, and internal caching mechanisms.
Users seeking to leverage the n8n Data Table functionality for efficient data storage and retrieval.

Overview

Finding valid and active discount codes manually is time-consuming. This robust n8n workflow automates the entire process. It uses a specialized AI agent, powered by the Gemini 2.5 Pro language model and the SerpAPI web search tool, to actively hunt for current vouchers. A core feature of this n8n automation is the efficiency gained through caching. Before searching, the n8n workflow checks an internal Data Table. If a valid code for the requested platform is found, it is delivered instantly, saving API costs and search latency. This versatile n8n workflow is activated by multiple n8n trigger points, making it easy to integrate into existing communication channels.

How it Works

The process begins when an n8n trigger is activated, which can be a Telegram message, a submitted web form, or a direct API call (Webhook).


  1. Input Normalization: Regardless of the n8n trigger source, the input query (the platform name) and the recipient identifier are standardized by a Set n8n node.

  2. Cache Lookup: The n8n workflow then queries the internal Data Table using the Get row(s) n8n node to check for cached, valid promo codes for the requested platform.

  3. Conditional Routing: The If n8n node checks the results.

If Found (True): The cached promo code details are immediately sent to the user via the Telegram n8n node and the Gmail n8n node.
If Not Found (False): The n8n workflow proceeds to the AI generation step.

  1. AI Agent Search: The Promo Seeker Agent n8n node executes a complex search strategy. It uses the Gemini 2.5Pro model and the SerpAPI n8n node to find recent codes (posted within the last 30 days) and validates their relevance.

  2. Data Structuring: The Structured Output Parser ensures the AI's natural language response is converted into a reliable JSON format, ready for database insertion.

  3. Caching Results: Finally, the Upsert row(s) n8n node saves the newly found promo code into the Data Table, ensuring this n8n workflow is optimized for future requests.

Installation Guide


  1. Import: Copy the provided n8n workflow JSON and paste it into your n8n instance using the 'Import from JSON' option.

  2. Credentials Setup: This n8n template requires several credentials. Set up connections for the following services:

SerpAPI: Obtain an API key from their dashboard and configure the SerpAPI n8n node credentials.
OpenRouter API: Used to access the Gemini 2.5 Pro model. Create an API key on OpenRouter and configure the OpenRouter n8n node credentials.
Telegram API: Create a bot via @BotFather and configure the Telegram n8n node credentials for both the trigger and the send message nodes.
Gmail OAuth2: Connect your Google account and grant necessary permissions to enable the Send a message n8n node.

  1. Data Table Creation: Manually create an n8n Data Table named 'Kode Promo Valid' (or similar) with the required columns: platform (string), promoCode (string), value (string), termsConditions (string), and validUntil (dateTime).

  2. Activate: Save the n8n workflow and set the active toggle to ON. The n8n trigger nodes (Telegram, Webhook, Form) are now live.

Node Details

Telegram Trigger, On form submission, Webhook: These are the multiple n8n trigger points that initiate this automation. They collect the platform request from different user channels.
Set (Platform) n8n node: Prepares the data, extracting the platform query and the recipient details from the various n8n trigger inputs, ensuring consistent data flow throughout the n8n workflow.
Get row(s) n8n node (Data Table): Performs the crucial caching check. It queries the Data Table for existing, valid promo codes matching the requested platform.
If (Code Exist?) n8n node: Routes the flow. If data exists from the Data Table, it skips the AI search; otherwise, it initiates the expensive external calls.
Promo Seeker Agent n8n node: The centralized AI logic. This LangChain n8n node uses a structured system message to instruct the Gemini 2.5 Pro model (via OpenRouter) to prioritize current codes using the integrated search tool.
Gemini 2.5Pro (OpenRouter) n8n node: Provides the large language model necessary for the agent to analyze search results and synthesize a structured response.
SerpAPI n8n node: Functions as the external web search tool for the AI agent, providing real-time data on active promo codes, essential for this n8n workflow.
Structured Output Parser n8n node: Enforces a predefined JSON schema on the AI's output, ensuring that the structured data (code, value, expiration) can be reliably inserted into the database.
Upsert row(s) n8n node (Data Table): Saves the newly generated, validated promo code data into the Data Table, effectively maintaining the cache and improving future performance of the n8n workflow.
Telegram and Gmail n8n nodes: Final action nodes that format and deliver the promo code details to the user via their specified communication channel, concluding the n8n workflow.

Related n8n Workflows

Free

Nodes: 16 Nodes
Updated: December 26 2025
View all
Created by

Featured*