by Ai Lin ⌘
🎯 What It Does: This project lets you talk to Siri (via Apple Shortcuts) and record or query your daily spending. The shortcut sends your message to an n8n Webhook, which uses AI to decide whether it’s for writing or reading finance data, then replies with a human-friendly message — all powered by n8n + AI + Google Sheets. ⸻ 🌐 PART 1: n8n Setup 🧩 1. Create a Webhook Trigger in n8n • Add a node: Webhook • Set HTTP Method: POST • Set Path: siri-finance • Enable “Respond to Webhook” = ✅ 🧠 2. Add AI Agent Node (e.g. OpenAI, Ollama, Gemini) • Use system prompt like: You are a finance assistant. Decide if the user wants to record or read transactions. If it's recording, return a JSON object with date, type, name, amount, and expense/income. If it's reading, return date range and type (Expense/Income). Always reply with a human-friendly summary. • Input: {{ $json.text }} (from webhook) • Output: structured json.output 🧮 3. (Optional) Add Logic to write to DB / Supabase / Google Sheets • Append tool: Adds a new row • Read tool: Queries past data Now your n8n flow is ready! ⸻ 📱 PART 2: iOS Shortcut Setup ⚙️ 1. Create a new Shortcut • Name it: 記帳助理 (or Finance Bot) • Add Action: Ask for Input • Prompt: “請說出你的記帳內容” • Input Type: Text • Add Action: Get Contents of URL • Method: POST • URL: https://your-n8n-domain/webhook/siri-finance • Headers: Content-Type: application/json • Request Body: { "text": "Provided Input" } • Replace "Provided Input" with Magic Variable → Input Result 🔊 2. Show Result • Add Action: Show Result • Content: Get Contents of URL 🗣️ 3. Optional: Add “Speak Text” • If you want Siri to speak it back, add Speak Text after Show Result. ⸻ ✅ Example Usage • You: “Hey Siri, 開支$50 早餐” • Siri: “已記錄支出:項目 早餐,金額 $50,已寫入” Or • You: “查一下我過去7日用了幾多錢” • Siri: “你過去7日總支出為 $7684.64,包括:⋯⋯” ⸻ 📦 Files to Share You can package the following: • .shortcut file export • Sample n8n workflow .json • Optional Supabase schema / Google Sheet template ⸻ 💡 Tips for Newcomers • Keep your Webhook public but protect with token if needed. • Ensure you handle emoji and newline safely for iOS compatibility. • Add logging nodes in n8n to help debug Siri messages. ⸻ 🗣️ Optional Project Name “Siri 記帳助理” / “Finance VoiceBot” A simple voice-first way to manage your daily expenses.
by Vitali
Template Description This n8n workflow template allows you to create a masked email address using the Fastmail API, triggered by a webhook. This is especially useful for generating disposable email addresses for privacy-conscious users or for testing purposes. Workflow Details: Webhook Trigger: The workflow is initiated by sending a POST request to a specific webhook. You can include state and description in your request body to customize the masked email's state and description. Session Retrieval: The workflow makes an HTTP request to the Fastmail API to retrieve session information. It uses this data to authenticate further requests. Create Masked Email: Using the retrieved session data, the workflow sends a POST request to Fastmail's JMAP API to create a masked email. It uses the provided state and description from the webhook payload. Prepare Output: Once the masked email is successfully created, the workflow extracts the email address and attaches the description for further processing. Respond to Webhook: Finally, the workflow responds to the original POST request with the newly created masked email and its description. Requirements: Fastmail API Access**: You will need valid API credentials for Fastmail configured with HTTP Header Authentication. Authorization Setup**: Optionally set up authorization if your webhook is exposed to the internet to prevent misuse. Custom Webhook Request**: Use a tool like curl or create a shortcut on macOS/iOS to send the POST request to the webhook with the necessary JSON payload, like so: curl -X POST -H 'Content-Type: application/json' https://your-n8n-instance/webhook/87f9abd1-2c9b-4d1f-8c7f-2261f4698c3c -d '{"state": "pending", "description": "my mega fancy masked email"}' This template simplifies the process of integrating masked email functionality into your projects or workflows and can be extended for various use cases. Feel free to use the companion shortcut I've also created. Please update the authorization header in the shortcut if needed. https://www.icloud.com/shortcuts/ac249b50eab34c04acd9fb522f9f7068
by ist00dent
This n8n template allows you to instantly fetch a random dog image from the Dog CEO API by simply sending a webhook request. It's a fun and simple way to integrate random dog photos into your projects, whether for websites, applications, or playful automations. 🔧 How it works Trigger Webhook: This node acts as the entry point for the workflow. It listens for any incoming POST request. No specific data is required in the webhook body, as the workflow fetches a random image. Fetch Random Dog Image: This node makes an HTTP GET request to https://dog.ceo/api/breeds/image/random. The API responds with a JSON object containing the URL of a random dog image. Respond with Image URL: This node sends the URL of the random dog image back to the service that initiated the webhook. 👤 Who is it for? This workflow is ideal for: Developers: Quickly integrate random dog images into web applications, bots, or prototypes. Content Creators: Get fresh, random dog photos for social media, blogs, or presentations. Learning n8n: A straightforward example of using a webhook to trigger an API call and return data. Anyone who loves dogs! 📑 Data Structure When you trigger the webhook, you can send an empty POST request body. The workflow will return a JSON response similar to this (the message URL will vary): { "message": "https://images.dog.ceo/breeds/hound-walker/n02089867_2626.jpg", "status": "success" } ⚙️ Setup Instructions Import Workflow: In your n8n editor, click "Import from JSON" and paste the provided workflow JSON. Configure Webhook Path: Double-click the Trigger Webhook node. In the 'Path' field, set a unique and descriptive path (e.g., /get-dog-image). Activate Workflow: Save and activate the workflow. 📝 Tips Download the Image: Instead of just returning the URL, you can download the image and then process it. Insert another HTTP Request node after Fetch Random Dog Image to download the image binary. Set the HTTP Request node's 'Response Format' to 'Binary'. Use the expression ={{ $json.message }} for the URL. Save to Cloud Storage: After downloading the image (as described above), you can save it to various cloud storage services: Google Drive: Add a Google Drive node. Connect it to the output of the image download node. Configure it to upload the binary data to a specific folder. Amazon S3: Add an AWS S3 node. Configure it to upload the binary data, specifying your bucket and desired filename. Dropbox: Use the Dropbox node to upload the image file. Send as a Message: Share the dog image directly in a chat or email: Slack/Discord/Telegram: Use the respective integration node to send the image URL or the downloaded image as an attachment. Email: Attach the downloaded image to an email using an Email or Gmail node. Display on a Web Page: If you're embedding this into a web application, you can simply use the returned URL in an tag to display the image. Error Handling: You can add an Error Trigger node to catch any issues during the image fetching process (e.g., if the Dog CEO API is down) and send notifications.
by bangank36
This workflow converts an exported CSV from Squarespace profiles into a Shopify-compatible format for customer import. How It Works Clone this Google Sheets template, which includes two sheets: Squarespace Profiles (Input) Go to Squarespace Dashboard → Contacts Click the three-dot icon → Select Export all Contacts Shopify Customers (Output) This sheet formats the data to match Shopify's customer import CSV. Shopify Dashboard → Customers → Import customers by CSV The workflow can run on-demand or be triggered via webhook. Via webhook Set up webhook node to expect a POST request Trigger the webhook using this code (psuedo) - replace {webhook-url} with the actual URL const formData = new FormData(); formData.append('file', blob, 'profiles_export.csv'); // Add file to FormData fetch('{webhook-url}', { // Replace with your target URL method: 'POST', mode: 'no-cors', body: formData }); The data is processed into the Shopify Customers sheet. Manually trigger Import Squarespace profiles into the sheet. Run the workflow to convert and populate the Shopify Customers sheet. Once workflow is done, export the Shopify to csv and import to Shopify customers Requirements To use this template, you need: Google Sheets API credentials Google Sheets Setup Use this sample Google Sheets template to get started quickly. Who Is This For? For anyone looking to automate Squarespace contact exports into a Shopify-compatible format—no more manual conversion! Explore More Templates Check out my other n8n templates: 👉 n8n.io/creators/bangank36
by Roman Rozenberger
This workflow is perfect for technical writers, content creators, marketers, and developers who write in Markdown but need to collaborate or publish using Google Docs format. Ideal for teams that want to streamline their content creation and review process. What problem does this workflow solve? Manual conversion from Markdown to Google Docs is time-consuming and often loses formatting. This workflow eliminates the tedious copy-paste process, automatically preserves formatting, and creates organized, timestamped documents in your Google Drive. Perfect for content teams who write in Markdown but need Google Docs for collaboration and review. What this workflow does Converts Markdown to HTML** with proper formatting preservation (headers, lists, links, tables) Creates timestamped Google Docs** documents with automatic naming Adds Drive location metadata** for better organization and reference Maintains document structure** including emojis, tables, and text formatting Automates file creation** in specified Google Drive folders Setup Google Drive OAuth2 credentials configured in n8n Target Google Drive folder URL Input your content title and Markdown text in the "Set Input Data" node How to customize this workflow to your needs Modify HTML formatting options** in the Markdown conversion node Change file naming patterns** to match your organization system Adjust Drive folder structure** and metadata inclusion Update MIME type handling** for different output requirements Add additional processing steps** like notifications or integrations Perfect for technical documentation workflows, content publishing pipelines, blog preparation, and automated report generation. Setup Instructions - Markdown to Google Docs Converter Prerequisites n8n instance** (local or cloud) Google account** with Google Drive access Basic understanding** of n8n workflow configuration Step 1: Import the Workflow Open n8n and navigate to Workflows Click "Add workflow" → "Import from JSON" Upload the Export_Markdown_Content_do_Google_Docs_Document.json file Save the workflow with a descriptive name Step 2: Configure Google Drive Credentials Create Google Drive OAuth2 Credentials In n8n, go to Settings → Credentials Click "Add credential" → "Google Drive OAuth2 API" Follow the OAuth setup to authorize n8n access to Google Drive: Visit Google Cloud Console Create or select a project Enable Google Drive API Create OAuth2 credentials Add authorized redirect URI for your n8n instance Name the credential (e.g., "Google Drive - Markdown Converter") Configure Google Drive Nodes Update these nodes with your Google Drive credentials: Create Empty File Update Document with Correct HTML Formatting In each node: Select your Google Drive credential from the dropdown Test the connection to ensure it works properly Step 3: Prepare Your Google Drive Create Target Folder Go to Google Drive (drive.google.com) Create a new folder for your converted documents Copy the folder URL (will look like: https://drive.google.com/drive/folders/FOLDER_ID) Ensure the folder has proper permissions for your Google account Step 4: Configure Input Data Set Your Default Values Open the "Set Input Data" node Update the assignments with your preferences: Google Drive URL: Replace the example URL with your target folder URL Format: https://drive.google.com/drive/folders/YOUR_FOLDER_ID Content Title: Set a default title or leave placeholder text This will be used in the document filename Content in Markdown: Add your Markdown content or keep example for testing Supports standard Markdown syntax (headers, lists, links, tables) Step 5: Test the Workflow Initial Test Run Ensure all credentials are configured Click the "Test workflow" button on the Manual Trigger node Monitor the execution - check for any errors in node outputs Verify the result: Check your Google Drive folder Look for a new document with timestamp in the name Open the document to verify formatting Troubleshooting Common Issues Google Drive Permission Errors: Verify OAuth2 credentials are properly configured Check that the target folder exists and is accessible Ensure Google Drive API is enabled in Google Cloud Console Markdown Conversion Issues: Check that your Markdown syntax is valid Test with simple content first (headers, paragraphs, lists) Verify the "Change Markdown To HTML" node settings File Creation Problems: Confirm the Google Drive folder URL format is correct Check that the folder ID in the URL is valid Ensure your Google account has write permissions to the folder Step 6: Customize for Your Needs Modify HTML Formatting Options In the "Change Markdown To HTML" node: Enable/disable emoji support** (currently enabled) Adjust table formatting** (currently enabled) Modify header ID generation** (currently disabled) Configure space requirements** for headers Update File Naming Pattern In the "Create Empty File" node: Change the naming convention**: Currently uses _PUB {Content Title} {timestamp} Modify timestamp format**: Currently yyyy-MM-dd HH:mm:ss Add prefixes or suffixes** as needed for your organization Step 7: Production Usage Regular Workflow Execution Update the "Set Input Data" node with new content Execute the workflow manually or set up triggers Monitor execution logs for any issues Check Google Drive for generated documents Integration Options Webhook Integration: Add a Webhook trigger to accept external Markdown content Useful for automated content publishing workflows Email Integration: Add email notifications when documents are created Include links to generated Google Docs Advanced Configuration Error Handling Add error handling nodes after critical operations Implement retry logic for API failures Set up notifications for failed executions Performance Optimization Adjust the "Wait for Document Creation" timing if needed Consider file size limits for Google Docs Support and Troubleshooting Common Solutions Timeout errors**: Increase wait time in "Wait for Document Creation" Authentication failures**: Refresh Google OAuth2 credentials Formatting issues**: Test with simpler Markdown first Getting Help Check n8n community forums for Google Drive integration issues Review Google Drive API documentation for rate limits Test with minimal Markdown content to isolate problems Total setup time: ~15-20 minutes Difficulty level: Intermediate Requirements: Google account, n8n instance, basic OAuth2 setup knowledge
by Rui Borges
his workflow automates time tracking using location-based triggers. How it works Trigger: It starts when you enter or exit a specified location, triggering a shortcut on your iPhone. Webhook: The shortcut sends a request to a webhook in n8n. Check-In/Check-Out: The webhook receives the request and records the time and whether it was a "Check-In" or "Check-Out" event. Google Sheets: This data is then logged into a Google Sheet, creating a record of your work hours. Set up steps Google Drive: Connect your Google Drive account. Google Sheets: Connect your Google Sheets account. Webhook: Set up a webhook node in n8n. iPhone Shortcuts: Create two shortcuts on your iPhone, one for "Check-In" and one for "Check-Out." Configure Shortcuts: Configure each shortcut to send a request to the webhook with the appropriate "Direction" header. It's easy to setup, around 5 minutes.
by InfraNodus
Using the knowledge graphs instead of RAG vector stores This workflow creates an AI chatbot agent that has access to several knowledge bases at the same time (used as "experts"). These knowledge bases are provided using the InfraNodus GraphRAG using the knowledge graphs and providing high-quality responses without the need to set up complex RAG vector store workflows. The advantages of using GraphRAG instead of the standard vector stores for knowledge are: Easy and quick to set up (no complex data import workflows needed) A knowledge graph has a holistic view of your knowledge base Better retrieval of relations between the document chunks = higher quality responses How it works This template uses the n8n AI agent node as an orchestrating agent that decides which tool (knowledge graph) to use based on the user's prompt. Here's a description step by step: The user submits a question using the AI chatbot (n8n interface, in this case, which can be accessed via a URL or embedded to any website) The AI agent node checks a list of tools it has access to. Each tool has a description of the knowledge it has auto-generated by InfraNodus. The AI agent decides which tool should be used to generate a response. It may reformulate user's query to be more suitable for the expert. The query is then sent to the InfraNodus HTTP node endpoint, which will query the graph that corresponds to that expert. Each InfraNodus GraphRAG expert provides a rich response that takes the whole context into account and provides a response from each expert (graph) along with a list of relevant statements retrieved using a combination or RAG and GraphRAG. The n8n AI Agent node integrates the responses received from the experts to produce the final answer. The final answer is sent back to the user's chat (or a webhook endpoint) How to use You need an InfraNodus GraphRAG API account and key to use this workflow. Create an InfraNodus account Get the API key at https://infranodus.com/api-access and create a Bearer authorization key for the InfraNodus HTTP nodes. Create a separate knowledge graph for each expert (using PDF / content import options) in InfraNodus For each graph, go to the workflow, paste the name of the graph into the body name field. Keep other settings intact or learn more about them at the InfraNodus access points page. Once you add one or more graphs as experts to your flow, add the LLM key to the OpenAI node and launch the workflow Requirements An InfraNodus account and API key An OpenAI (or any other LLM) API key Customizing this workflow You can use this same workflow with a Telegram bot, so you can interact with it using Telegram. There are many more customizations available. Check out the complete guide at https://support.noduslabs.com/hc/en-us/articles/20174217658396-Using-InfraNodus-Knowledge-Graphs-as-Experts-for-AI-Chatbot-Agents-in-n8n Also check out the video tutorial with a demo:
by Anurag
Description This workflow automates the extraction of structured data from invoices or similar documents using Docsumo's API. Users can upload a PDF via an n8n form trigger, which is then sent to Docsumo for processing and structured parsing. The workflow fetches key document metadata and all line items, reconstructs each invoice row with combined header and item details, and finally exports all results as an Excel file. Ideal for automating invoice data entry, reporting, or integrating with accounting systems. How It Works A user uploads a PDF document using the integrated n8n form trigger. The workflow securely sends the document to Docsumo via REST API. After uploading, it checks and retrieves the parsed document results. Header information and table line items are extracted and mapped into structured records. The complete result is exported as an Excel (.xls) file. Setup Steps Docsumo Account: Register and obtain your API key from Docsumo. n8n Credentials Manager: Add your Docsumo API key as an HTTP header credential (never hardcode the key in the workflow). Workflow Configuration: In the HTTP Request nodes, set the authentication to your saved Docsumo credentials. Update the file type or document type in the request (e.g., "type": "invoice") as needed for your use case. Testing: Enable the workflow and use the built-in form to upload a sample invoice for extraction. Features Supports PDF uploads via n8n’s built-in form or via API/webhook extension. Sends files directly to Docsumo for document data extraction using secure credentials. Extracts invoice-level metadata (number, date, vendor, totals) and full line item tables. Consolidates all data in easy-to-use Excel format for download or integration. Modular node structure, easily extensible for further automation. Prerequisites Docsumo account with API access enabled. n8n instance with form, HTTP Request, Code, and Excel/Convert to File nodes. Working Docsumo API Key stored securely in n8n’s credential manager. Example Use Cases | Scenario | Benefit | |---------------------|-----------------------------------------| | Invoice Automation | Extract line items and metadata rapidly | | Receipts Processing | Parse and digitize business receipts | | Bulk Bill Imports | Batch process bills for analytics | Notes Credentials Security:** Do not store your API key directly in HTTP Request nodes; always use n8n credentials manager. Sticky Notes:** The workflow includes sticky notes for setup, input, API call, extraction, and output steps to assist template users. Custom Columns:** You can customize header or line item extraction by editing the Code node as needed.
by Lucas Peyrin
How it works This workflow demonstrates a fundamental pattern for securing a webhook by requiring an API key. It acts as a gatekeeper, checking for a valid key in the request header before allowing the request to proceed. Incoming Request: The Secured Webhook node receives an incoming POST request. It expects an API key to be sent in the x-api-key header. API Key Verification: The Check API Key node takes the key from the incoming request's header. It then makes an internal HTTP request to a second webhook (Get API Key) which acts as a mock database. This second webhook retrieves a list of registered API keys (from the Registered API Keys node) and filters it to find a match for the key that was provided. Conditional Response: If a match is found, the API Key Identified node routes the execution to the "success" path, returning a 200 OK response with the identified user's ID. If no match is found, it routes to the "unauthorized" path, returning a 401 Unauthorized error. This pattern separates the public-facing endpoint from the data source, which is a good security practice. Set up steps Setup time: ~2 minutes This workflow is designed to be a self-contained example. Set up Credentials: This workflow uses "Header Auth" for its internal communication. Go to Credentials and create a new Header Auth credential. You can use any name and value (e.g., Name: X-N8N-Auth, Value: my-secret-password). Select this credential in all four webhook/HTTP Request nodes. Add Your API Keys: Open the Registered API Keys node. This is your mock database. Edit the array to include the user_id and api_key pairs you want to authorize. Activate the workflow. Test it: Use the Test Secure Webhook node to send a request. Try it with a valid key from your list to see the success response. Change the x-api-key header to an invalid key to see the 401 Unauthorized error. For Production: Replace the mock database part of this workflow (the Get API Key webhook and Registered API Keys node) with a real database node like Supabase, Postgres, or Baserow to look up keys.
by Jimleuk
This n8n template offers a simple yet capable chatbot assistant who can answer course enquiries over SMS. Given the right access to data, AI Agents are capable of planning and performing relatively complex research tasks to get their answers. In this example, the agent must first understand the database schema, retrieve lists of values before generating it's own query to search over the database. Checkout the example database here - https://airtable.com/appO5xvP1aUBYKyJ7/shr8jSFDaghubDOrw How it works A Twilio trigger gives us the ability to receive SMS input into our workflow via webhook. The message is then directed to our AI agent who is instructed to assist the user and use the course database as reference. The database is an Airtable base. The agent autonomously figures out which tool it needs to use and generates it's own "filter_by_formula" query to search over the available courses. On successful search results, the Agent can then use this information to answer the user's query. The Agent's output is logged in a second sheet of the Airtable base. We can use this later for analysis and lead gen. Finally, the response is sent back to the user through SMS using Twilio. How to use Ensure your Twilio number is set to forward messages to this workflow's webhook URL. Configure and update the course database as required. If you're not interested in courses, you can swap this out for inventory, deliveries or any other data relevant to your business. Ask questions like: "Can you help me find suitable courses to fill my Wednesday mornings?" "Which courses are being instructed by profession Lee?" "I'm interested in creative arts. What courses are available which could be relevant to me?" Requirements Twilio for SMS receiving and sending OpenAI for LLM and Agent Airtable for Course Database Customising this workflow Add additional tools and expand the range of queries the agent is able to answer or assist with. Not using Airtable? This technique also works with SQL databases like PostgreSQL.
by Dhruv Dalsaniya
Description: This n8n workflow automates a Discord bot to fetch messages from a specified channel and send AI-generated responses in threads. It ensures smooth message processing and interaction, making it ideal for managing community discussions, customer support, or AI-based engagement. This workflow leverages Redis for memory persistence, ensuring that conversation history is maintained even if the workflow restarts, providing a seamless user experience. How It Works The bot listens for new messages in a specified Discord channel. It sends the messages to an AI model for response generation. The AI-generated reply is posted as a thread under the original message. The bot runs on an Ubuntu server and is managed using PM2 for uptime stability. The Discord bot (Python script) acts as the bridge, capturing messages from Discord and sending them to the n8n webhook. The n8n workflow then processes these messages, interacts with the AI model, and sends the AI's response back to Discord via the bot. Prerequisites to host Bot Sign up on Pella, which is a managed hosting service for Discord Bots. (Easy Setup) A Redis instance for memory persistence. Redis is an in-memory data structure store, used here to store and retrieve conversation history, ensuring that the AI can maintain context across multiple interactions. This is crucial for coherent and continuous conversations. Set Up Steps 1️⃣ Create a Discord Bot Go to the Discord Developer Portal. Click “New Application”, enter a name, and create it. Navigate to Bot > Reset Token, then copy the Bot Token. Enable Privileged Gateway Intents (Presence, Server Members, Message Content). Under OAuth2 > URL Generator, select bot scope and required permissions. Copy the generated URL, open it in a browser, select your server, and click Authorize. 2️⃣ Deploy the Bot on Pella Create a new folder discord-bot and navigate into it: Create and configure an .env file to store your bot token: Copy the code to .env: (You can copy the webhook URL from the n8n workflow) TOKEN=your-bot-token-here WEBHOOK_URL=https://your-domain.tld/webhook/getmessage Create file main.py copy the below code and save it: Copy this Bot script to main.py: import discord import requests import json import os from dotenv import load_dotenv Load environment variables from .env file load_dotenv() TOKEN = os.getenv("TOKEN") WEBHOOK_URL = os.getenv("WEBHOOK_URL") Bot Configuration LISTEN_CHANNELS = ["YOUR_CHANNEL_ID_1", "YOUR_CHANNEL_ID_2"] # Replace with your target channel IDs Intents setup intents = discord.Intents.default() intents.messages = True # Enable message event intents.guilds = True intents.message_content = True # Required to read messages client = discord.Client(intents=intents) @client.event async def on_ready(): print(f'Logged in as {client.user}') @client.event async def on_message(message): if message.author == client.user: return # Ignore bot's own messages if str(message.channel.id) in LISTEN_CHANNELS: try: fetched_message = await message.channel.fetch_message(message.id) # Ensure correct fetching payload = { "channel_id": str(fetched_message.channel.id), # Ensure it's string "chat_message": fetched_message.content, "timestamp": str(fetched_message.created_at), # Ensure proper formatting "message_id": str(fetched_message.id), # Ensure ID is a string "user_id": str(fetched_message.author.id) # Ensure user ID is also string } headers = {'Content-Type': 'application/json'} response = requests.post(WEBHOOK_URL, data=json.dumps(payload), headers=headers) if response.status_code == 200: print(f"Message sent successfully: {payload}") else: print(f"Failed to send message: {response.status_code}, Response: {response.text}") except Exception as e: print(f"Error fetching message: {e}") client.run(TOKEN) Create requirements.txt and copy: discord python-dotenv 3️⃣ Follow the video to set up the bot which will run 24/7 Tutorial - https://www.youtube.com/watch?v=rNnK3XlUtYU Note: Free Plan will expire after 24 hours, so please opt for the Paid Plan in Pella to keep your bot running. 4️⃣ n8n Workflow Configuration The n8n workflow consists of the following nodes: Get Discord Messages (Webhook):** This node acts as the entry point for messages from the Discord bot. It receives the channel_id, chat_message, timestamp, message_id, and user_id from Discord when a new message is posted in the configured channel. Its webhook path is /getmessage and it expects a POST request. Chat Agent (Langchain Agent):** This node processes the incoming Discord message (chat_message). It is configured as a conversational agent, integrating the language model and memory to generate an appropriate response. It also has a prompt to keep the reply concise, under 1800 characters. OpenAI -4o-mini (Langchain Language Model):** This node connects to the OpenAI API and uses the gpt-4o-mini-2024-07-18 model for generating AI responses. It is the core AI component of the workflow. Message History (Redis Chat Memory):** This node manages the conversation history using Redis. It stores and retrieves chat messages, ensuring the Chat Agent maintains context for each user based on their user_id. This is critical for coherent multi-turn conversations. Calculator (Langchain Tool):** This node provides a calculator tool that the AI agent can utilize if a mathematical calculation is required within the conversation. This expands the capabilities of the AI beyond just text generation. Response fromAI (Discord):** This node sends the AI-generated response back to the Discord channel. It uses the Discord Bot API credentials and replies in a thread under the original message (message_id) in the specified channel_id. Sticky Note1, Sticky Note2, Sticky Note3, Sticky Note4, Sticky Note5, Sticky Note:** These are informational nodes within the workflow providing instructions, code snippets for the Discord bot, and setup guidance for the user. These notes guide the user on setting up the .env file, requirements.txt, the Python bot code, and general recommendations for channel configuration and adding tools. 5️⃣ Setting up Redis Choose a Redis Hosting Provider: You can use a cloud provider like Redis Labs, Aiven, or set up your own Redis instance on a VPS. Obtain Redis Connection Details: Once your Redis instance is set up, you will need the host, port, and password (if applicable). Configure n8n Redis Nodes: In your n8n workflow, configure the "Message History" node with your Redis connection details. Ensure the Redis credential ✅ redis-for-n8n is properly set up with your Redis instance details (host, port, password). 6️⃣ Customizing the Template AI Model:** You can easily swap out the "OpenAI -4o-mini" node with any other AI service supported by n8n (e.g., Cohere, Hugging Face) to use a different language model. Ensure the new language model node is connected to the ai_languageModel input of the "Chat Agent" node. Agent Prompt:** Modify the text parameter in the "Chat Agent" node to change the AI's persona, provide specific instructions, or adjust the response length. Additional Tools:** The "Calculator" node is an example of an AI tool. You can add more Langchain tool nodes (e.g., search, data lookup) and connect them to the ai_tool input of the "Chat Agent" node to extend the AI's capabilities. Refer to the "Sticky Note5" in the workflow for a reminder. Channel Filtering:** Adjust the LISTEN_CHANNELS list in the main.py file of your Discord bot to include or exclude specific Discord channel IDs where the bot should listen for messages. Thread Management:** The "Response fromAI" node can be modified to change how threads are created or managed, or to send responses directly to the channel instead of a thread. The current setup links the response to the original message ID (message_reference). 7️⃣ Testing Instructions Start the Discord Bot: Ensure your main.py script is running on Pella. Activate the n8n Workflow: Make sure your n8n workflow is active and listening for webhooks. Send a Message in Discord: Go to one of the LISTEN_CHANNELS in your Discord server and send a message. Verify Response: The bot should capture the message, send it to n8n, receive an AI-generated response, and post it as a thread under your original message. Check Redis: Verify that the conversation history is being stored and updated correctly in your Redis instance. Look for keys related to user IDs. ✅ Now your bot is running in the background! 🚀
by Anurag
This workflow contains community nodes that are only compatible with the self-hosted version of n8n. Description This workflow automates document processing and structured table extraction using the Nanonets API. You can submit a PDF file via an n8n form trigger or webhook—the workflow then forwards the document to Nanonets, waits for asynchronous parsing to finish, retrieves the results (including header fields and line items/tables), and returns the output as an Excel file. Ideal for automating invoice, receipt, or order data extraction with downstream business use. How It Works A document is uploaded (via n8n form or webhook). The PDF is sent to the Nanonets Workflow API for parsing. The workflow waits until processing is complete. Parsed results are fetched. Both top-level fields and any table rows/line items are extracted and restructured. Data is exported to Excel format and delivered to the requester. Setup Steps Nanonets Account: Register for a Nanonets account and set up a workflow for your specific document type (e.g., invoice, receipt). Credentials in n8n: Add HTTP Basic Auth credentials in n8n for the Nanonets API (never store credentials directly in node parameters). Webhook/Form Configuration: Option 1: Configure and enable the included n8n Form Trigger node for document uploads. Option 2: Use the included Webhook node to accept external POSTs with a PDF file. Adjust Workflow: Update any HTTP nodes to use your credential profile. Insert your Nanonets Workflow ID in all relevant nodes. Test the Workflow: Enable the workflow and try with a sample document. Features Accepts documents via n8n Form Trigger or direct webhook POST. Securely sends files to Nanonets for document parsing (credentials stored in n8n credentials manager). Automatically waits for async processing, checking Nanonets until results are ready. Extracts both header data and all table/line items into a tabular format. Exports results as an Excel file download. Modular nodes allow easy customization or extension. Prerequisites Nanonets account** with workflow configured for your document type. n8n** instance with HTTP Request, Webhook/Form, Code, and Excel/Spreadsheet nodes enabled. Valid HTTP Basic Auth credentials** saved in n8n for API access. Example Use Cases | Scenario | Benefit | |-----------------------|--------------------------------------------------| | Invoice Processing | Automated extraction of line items and totals | | Receipt Digitization | Parse amounts and charges for expense reports | | Purchase Orders | Convert scanned POs into structured Excel sheets | Notes You must set up credentials in the n8n credentials manager—do not store API keys directly in nodes. All configuration and endpoints are clearly explained with inline sticky notes in the workflow editor. Easily adaptable for other document types or similar APIs—just modify endpoints and result mapping.