Back to Catalog

AWS EC2 lifecycle manager with AI chat agent (describe, start, stop, reboot)

Trung TranTrung Tran
301 views
2/3/2026
Official Page

EC2 Lifecycle Manager with AI Chat Agent (Describe, Start, Stop, Reboot, Terminate)

Watch the demo video below:

Watch the video

Who’s it for

This workflow is designed for DevOps engineers and cloud administrators who want to manage AWS EC2 instances directly from chat platforms (Slack, Teams, Telegram, etc.) using natural language.
It helps engineers quickly check EC2 instance status, start/stop servers, reboot instances, or terminate unused machines — without logging into the AWS console.

How it works / What it does

  1. A chat message (command) from the engineer triggers the workflow.
  2. The EC2 Manager AI Agent interprets the request using the AI chat model and memory.
  3. The agent decides which AWS EC2 action to perform:
    • DescribeInstances → List or check status of EC2 instances.
    • StartInstances → Boot up stopped instances.
    • StopInstances → Gracefully shut down running instances.
    • RebootInstances → Restart instances without stopping them.
    • TerminateInstances → Permanently delete instances.
  4. The selected tool (API call) is executed via an HTTP Request to the AWS EC2 endpoint.
  5. The agent replies back in chat with the result (confirmation, instance status, errors, etc.).

How to set up

  1. Add Chat Trigger

    • Connect your chatbot platform (Slack/Telegram/Teams) to n8n.
    • Configure the “When chat message received” node.
  2. Configure OpenAI Chat Model

    • Select a supported LLM (GPT-4, GPT-4.1, GPT-5, etc.).
    • Add system and user prompts to define behavior (EC2 assistant role).
  3. Add Memory

    • Use Simple Memory to keep track of context (e.g., instance IDs, region, last action).
  4. Connect EC2 API Tools

    • Create HTTP Request nodes for:
      • Describe Instances
      • Start Instance
      • Stop Instance
      • Reboot Instance
      • Terminate Instance
    • Use AWS credentials with Signature V4 authentication.
    • API endpoint: https://ec2.{region}.amazonaws.com/
  5. Link Tools to Agent

    • Attach all EC2 tools to the EC2 Manager AI Agent node.
    • Ensure the agent can choose which tool to call based on user input.

Requirements

  • n8n instance (self-hosted or cloud).
  • Chat platform integration (Slack, Teams, or Telegram).
  • OpenAI (or other LLM) credentials.
  • AWS IAM user with EC2 permissions:
    • ec2:DescribeInstances
    • ec2:StartInstances
    • ec2:StopInstances
    • ec2:RebootInstances
    • ec2:TerminateInstances
  • AWS region configured for API calls.

How to customize the workflow

  • Add safety checks: Require explicit confirmation before running Stop or Terminate.
  • Region flexibility: Add support for multi-region management by letting the user specify the region in chat.
  • Tag-based filters: Extend DescribeInstances to return only instances matching specific tags (e.g., env=dev).
  • Cost-saving automation: Add scheduled rules to automatically stop instances outside working hours.
  • Enhanced chatbot UX: Format responses into tables or rich messages in Slack/Teams.
  • Audit logging: Store each action (who/what/when) into a database or Google Sheets for compliance.

n8n AWS EC2 Lifecycle Manager with AI Chat Agent

This n8n workflow provides a conversational interface to manage AWS EC2 instances using an AI Chat Agent. It allows users to interact with an AI to perform actions like describing, starting, stopping, or rebooting EC2 instances through natural language commands.

What it does

This workflow simplifies AWS EC2 management by:

  1. Listening for Chat Messages: It acts as a chatbot, waiting for incoming messages from a configured chat service (e.g., Slack, Telegram, Discord, etc., depending on the Chat Trigger setup).
  2. Processing with an AI Agent: It feeds the received chat message into an AI Agent powered by OpenAI.
  3. Maintaining Conversation Context: A simple memory buffer is used to maintain the context of the conversation, allowing for more natural and continuous interactions with the AI.
  4. Generating Responses: The AI Agent, using the OpenAI Chat Model, processes the user's request and generates an appropriate response, potentially including actions to be taken on AWS EC2 instances (though the AWS action nodes are not explicitly defined in the provided JSON, this is the intended purpose of the AI Agent in such a workflow).

Prerequisites/Requirements

To use this workflow, you will need:

  • n8n Instance: A running n8n instance.
  • OpenAI API Key: An API key for OpenAI to use the Chat Model. This will need to be configured as an n8n credential.
  • Chat Service Integration: A configured chat service (e.g., Slack, Telegram, Discord) connected to the n8n Chat Trigger node. This typically involves setting up a webhook or bot token within n8n's credentials.
  • AWS Credentials (Implied): Although not explicitly shown in the provided JSON, to perform actual EC2 actions (describe, start, stop, reboot), you would need AWS credentials configured in n8n and additional AWS EC2 nodes integrated into the AI Agent's toolset.

Setup/Usage

  1. Import the Workflow: Import the provided JSON into your n8n instance.
  2. Configure Credentials:
    • OpenAI Chat Model: Configure your OpenAI API Key as an n8n credential and select it in the "OpenAI Chat Model" node.
    • Chat Trigger: Configure your desired chat service (e.g., Slack, Telegram) with the "When chat message received" node. This usually involves setting up a webhook or bot token credential within n8n.
  3. Activate the Workflow: Once all credentials are set up, activate the workflow.
  4. Interact via Chat: Send messages to your configured chat service. The AI Agent will process your requests and respond.
  5. Extend with AWS EC2 Tools (Further Development): To enable actual EC2 management, you would need to:
    • Add AWS EC2 nodes (e.g., "EC2 Describe Instances", "EC2 Start Instances", "EC2 Stop Instances", "EC2 Reboot Instances") to your workflow.
    • Configure these AWS EC2 nodes with appropriate AWS credentials.
    • Integrate these AWS EC2 nodes as "tools" within the "AI Agent" node, allowing the AI to call them based on user commands.

Related Templates

Two-way property repair management system with Google Sheets & Drive

This workflow automates the repair request process between tenants and building managers, keeping all updates organized in a single spreadsheet. It is composed of two coordinated workflows, as two separate triggers are required — one for new repair submissions and another for repair updates. A Unique Unit ID that corresponds to individual units is attributed to each request, and timestamps are used to coordinate repair updates with specific requests. General use cases include: Property managers who manage multiple buildings or units. Building owners looking to centralize tenant repair communication. Automation builders who want to learn multi-trigger workflow design in n8n. --- ⚙️ How It Works Workflow 1 – New Repair Requests Behind the Scenes: A tenant fills out a Google Form (“Repair Request Form”), which automatically adds a new row to a linked Google Sheet. Steps: Trigger: Google Sheets rowAdded – runs when a new form entry appears. Extract & Format: Collects all relevant form data (address, unit, urgency, contacts). Generate Unit ID: Creates a standardized identifier (e.g., BUILDING-UNIT) for tracking. Email Notification: Sends the building manager a formatted email summarizing the repair details and including a link to a Repair Update Form (which activates Workflow 2). --- Workflow 2 – Repair Updates Behind the Scenes:\ Triggered when the building manager submits a follow-up form (“Repair Update Form”). Steps: Lookup by UUID: Uses the Unit ID from Workflow 1 to find the existing row in the Google Sheet. Conditional Logic: If photos are uploaded: Saves each image to a Google Drive folder, renames files consistently, and adds URLs to the sheet. If no photos: Skips the upload step and processes textual updates only. Merge & Update: Combines new data with existing repair info in the same spreadsheet row — enabling a full repair history in one place. --- 🧩 Requirements Google Account (for Forms, Sheets, and Drive) Gmail/email node connected for sending notifications n8n credentials configured for Google API access --- ⚡ Setup Instructions (see more detail in workflow) Import both workflows into n8n, then copy one into a second workflow. Change manual trigger in workflow 2 to a n8n Form node. Connect Google credentials to all nodes. Update spreadsheet and folder IDs in the corresponding nodes. Customize email text, sender name, and form links for your organization. Test each workflow with a sample repair request and a repair update submission. --- 🛠️ Customization Ideas Add Slack or Telegram notifications for urgent repairs. Auto-create folders per building or unit for photo uploads. Generate monthly repair summaries using Google Sheets triggers. Add an AI node to create summaries/extract relevant repair data from repair request that include long submissions.

Matt@VeraisonLabsBy Matt@VeraisonLabs
208

Automate invoice processing with OCR, GPT-4 & Salesforce opportunity creation

PDF Invoice Extractor (AI) End-to-end pipeline: Watch Drive ➜ Download PDF ➜ OCR text ➜ AI normalize to JSON ➜ Upsert Buyer (Account) ➜ Create Opportunity ➜ Map Products ➜ Create OLI via Composite API ➜ Archive to OneDrive. --- Node by node (what it does & key setup) 1) Google Drive Trigger Purpose: Fire when a new file appears in a specific Google Drive folder. Key settings: Event: fileCreated Folder ID: google drive folder id Polling: everyMinute Creds: googleDriveOAuth2Api Output: Metadata { id, name, ... } for the new file. --- 2) Download File From Google Purpose: Get the file binary for processing and archiving. Key settings: Operation: download File ID: ={{ $json.id }} Creds: googleDriveOAuth2Api Output: Binary (default key: data) and original metadata. --- 3) Extract from File Purpose: Extract text from PDF (OCR as needed) for AI parsing. Key settings: Operation: pdf OCR: enable for scanned PDFs (in options) Output: JSON with OCR text at {{ $json.text }}. --- 4) Message a model (AI JSON Extractor) Purpose: Convert OCR text into strict normalized JSON array (invoice schema). Key settings: Node: @n8n/n8n-nodes-langchain.openAi Model: gpt-4.1 (or gpt-4.1-mini) Message role: system (the strict prompt; references {{ $json.text }}) jsonOutput: true Creds: openAiApi Output (per item): $.message.content → the parsed JSON (ensure it’s an array). --- 5) Create or update an account (Salesforce) Purpose: Upsert Buyer as Account using an external ID. Key settings: Resource: account Operation: upsert External Id Field: taxid_c External Id Value: ={{ $json.message.content.buyer.tax_id }} Name: ={{ $json.message.content.buyer.name }} Creds: salesforceOAuth2Api Output: Account record (captures Id) for downstream Opportunity. --- 6) Create an opportunity (Salesforce) Purpose: Create Opportunity linked to the Buyer (Account). Key settings: Resource: opportunity Name: ={{ $('Message a model').item.json.message.content.invoice.code }} Close Date: ={{ $('Message a model').item.json.message.content.invoice.issue_date }} Stage: Closed Won Amount: ={{ $('Message a model').item.json.message.content.summary.grand_total }} AccountId: ={{ $json.id }} (from Upsert Account output) Creds: salesforceOAuth2Api Output: Opportunity Id for OLI creation. --- 7) Build SOQL (Code / JS) Purpose: Collect unique product codes from AI JSON and build a SOQL query for PricebookEntry by Pricebook2Id. Key settings: pricebook2Id (hardcoded in script): e.g., 01sxxxxxxxxxxxxxxx Source lines: $('Message a model').first().json.message.content.products Output: { soql, codes } --- 8) Query PricebookEntries (Salesforce) Purpose: Fetch PricebookEntry.Id for each Product2.ProductCode. Key settings: Resource: search Query: ={{ $json.soql }} Creds: salesforceOAuth2Api Output: Items with Id, Product2.ProductCode (used for mapping). --- 9) Code in JavaScript (Build OLI payloads) Purpose: Join lines with PBE results and Opportunity Id ➜ build OpportunityLineItem payloads. Inputs: OpportunityId: ={{ $('Create an opportunity').first().json.id }} Lines: ={{ $('Message a model').first().json.message.content.products }} PBE rows: from previous node items Output: { body: { allOrNone:false, records:[{ OpportunityLineItem... }] } } Notes: Converts discount_total ➜ per-unit if needed (currently commented for standard pricing). Throws on missing PBE mapping or empty lines. --- 10) Create Opportunity Line Items (HTTP Request) Purpose: Bulk create OLIs via Salesforce Composite API. Key settings: Method: POST URL: https://<your-instance>.my.salesforce.com/services/data/v65.0/composite/sobjects Auth: salesforceOAuth2Api (predefined credential) Body (JSON): ={{ $json.body }} Output: Composite API results (per-record statuses). --- 11) Update File to One Drive Purpose: Archive the original PDF in OneDrive. Key settings: Operation: upload File Name: ={{ $json.name }} Parent Folder ID: onedrive folder id Binary Data: true (from the Download node) Creds: microsoftOneDriveOAuth2Api Output: Uploaded file metadata. --- Data flow (wiring) Google Drive Trigger → Download File From Google Download File From Google → Extract from File → Update File to One Drive Extract from File → Message a model Message a model → Create or update an account Create or update an account → Create an opportunity Create an opportunity → Build SOQL Build SOQL → Query PricebookEntries Query PricebookEntries → Code in JavaScript Code in JavaScript → Create Opportunity Line Items --- Quick setup checklist 🔐 Credentials: Connect Google Drive, OneDrive, Salesforce, OpenAI. 📂 IDs: Drive Folder ID (watch) OneDrive Parent Folder ID (archive) Salesforce Pricebook2Id (in the JS SOQL builder) 🧠 AI Prompt: Use the strict system prompt; jsonOutput = true. 🧾 Field mappings: Buyer tax id/name → Account upsert fields Invoice code/date/amount → Opportunity fields Product name must equal your Product2.ProductCode in SF. ✅ Test: Drop a sample PDF → verify: AI returns array JSON only Account/Opportunity created OLI records created PDF archived to OneDrive --- Notes & best practices If PDFs are scans, enable OCR in Extract from File. If AI returns non-JSON, keep “Return only a JSON array” as the last line of the prompt and keep jsonOutput enabled. Consider adding validation on parsing.warnings to gate Salesforce writes. For discounts/taxes in OLI: Standard OLI fields don’t support per-line discount amounts directly; model them in UnitPrice or custom fields. Replace the Composite API URL with your org’s domain or use the Salesforce node’s Bulk Upsert for simplicity.

Le NguyenBy Le Nguyen
942

Dynamic Hubspot lead routing with GPT-4 and Airtable sales team distribution

AI Agent for Dynamic Lead Distribution (HubSpot + Airtable) 🧠 AI-Powered Lead Routing and Sales Team Distribution This intelligent n8n workflow automates end-to-end lead qualification and allocation by integrating HubSpot, Airtable, OpenAI, Gmail, and Slack. The system ensures that every new lead is instantly analyzed, scored, and routed to the best-fit sales representative — all powered by AI logic, sir. --- 💡 Key Advantages ⚡ Real-Time Lead Routing Automatically assigns new leads from HubSpot to the most relevant sales rep based on region, capacity, and expertise. 🧠 AI Qualification Engine An OpenAI-powered Agent evaluates the lead’s industry, region, and needs to generate a persona summary and routing rationale. 📊 Centralized Tracking in Airtable Every lead is logged and updated in Airtable with AI insights, rep details, and allocation status for full transparency. 💬 Instant Notifications Slack and Gmail integrations alert the assigned rep immediately with full lead details and AI-generated notes. 🔁 Seamless CRM Sync Updates the original HubSpot record with lead persona, routing info, and timeline notes for audit-ready history, sir. --- ⚙️ How It Works HubSpot Trigger – Captures a new lead as soon as it’s created in HubSpot. Fetch Contact Data – Retrieves all relevant fields like name, company, and industry. Clean & Format Data – A Code node standardizes and structures the data for consistency. Airtable Record Creation – Logs the lead data into the “Leads” table for centralized tracking. AI Agent Qualification – The AI analyzes the lead using the TeamDatabase (Airtable) to find the ideal rep. Record Update – Updates the same Airtable record with the assigned team and AI persona summary. Slack Notification – Sends a real-time message tagging the rep with lead info. Gmail Notification – Sends a personalized handoff email with context and follow-up actions. HubSpot Sync – Updates the original contact in HubSpot with the assignment details and AI rationale, sir. --- 🛠️ Setup Steps Trigger Node: HubSpot → Detect new leads. HubSpot Node: Retrieve complete lead details. Code Node: Clean and normalize data. Airtable Node: Log lead info in the “Leads” table. AI Agent Node: Process lead and match with sales team. Slack Node: Notify the designated representative. Gmail Node: Email the rep with details. HubSpot Node: Update CRM with AI summary and allocation status, sir. --- 🔐 Credentials Required HubSpot OAuth2 API – To fetch and update leads. Airtable Personal Access Token – To store and update lead data. OpenAI API – To power the AI qualification and matching logic. Slack OAuth2 – For sending team notifications. Gmail OAuth2 – For automatic email alerts to assigned reps, sir. --- 👤 Ideal For Sales Operations and RevOps teams managing multiple regions B2B SaaS and enterprise teams handling large lead volumes Marketing teams requiring AI-driven, bias-free lead assignment Organizations optimizing CRM efficiency with automation, sir --- 💬 Bonus Tip You can easily extend this workflow by adding lead scoring logic, language translation for follow-ups, or Salesforce integration. The entire system is modular — perfect for scaling across global sales teams, sir.

MANISH KUMARBy MANISH KUMAR
113