AI Workflow Credential Auditor Agent with n8n & OpenAI
Integrates with:
Overview
Overview
This AI Agent provides a powerful way to audit and understand credential usage across your n8n instances. It first scans your n8n workflows using the n8n API, extracts details about which credentials are used, and stores this information in a temporary, in-memory SQLite database. Then, using an OpenAI-powered Langchain agent, you can conversationally query this database to find specific workflows based on the credentials they utilize. For example, you can ask "Which workflows are using my Slack and Airtable credentials?" and the agent will translate your question into a SQL query, retrieve the results, and even provide direct links to the relevant n8n workflows.
Key Features & Benefits
- Automated Credential Discovery: Connects to your n8n instance via its API to list workflows and identify used credentials.
- AI-Powered Conversational Querying: Leverages OpenAI and Langchain to understand natural language questions about credential usage and translate them into database queries. Its abilities include 'workflow auditing', 'credential usage analysis', and 'natural language querying'.
- Targeted Workflow Identification: Quickly find all workflows using specific credentials (e.g., "find workflows using 'Stripe_Prod_Key'").
- Dynamic Database Population: Creates an SQLite database on-the-fly with workflow and credential information for querying. (Note: This database is temporary and resides in memory; it's cleared when n8n restarts or the populating execution ends.)
- Direct Workflow Links: The AI agent can generate clickable links to the identified n8n workflows within your instance.
- Enhanced Instance Management: Ideal for CTOs, Heads of Automation, and n8n administrators to maintain oversight on credential distribution and usage.
- Security & Compliance Aid: Simplifies the process of auditing which automations have access to which services.
Use Cases
- Quickly identify all B2C e-commerce workflows using a specific payment gateway credential for audit purposes.
- For B2B SaaS CTOs: Pinpoint which automation workflows access sensitive customer data via specific API keys.
- Streamline debugging by asking the agent which workflows use a recently changed or problematic API credential.
- Perform impact analysis before revoking or updating a credential by finding all dependent n8n workflows.
- Assist new team members in understanding which workflows interact with specific internal or external services.
Prerequisites
- An n8n instance (Cloud or self-hosted) where this workflow will run.
- An n8n API Key with permissions to read workflows. This key determines the scope of workflows the agent can analyze.
- An OpenAI API Key with access to a suitable model (e.g., gpt-3.5-turbo, gpt-4).
- Note: The workflow credential database is created in memory by the Code node and will be cleared if your n8n instance restarts or the workflow execution that created it ends. For persistent storage, modification of the Code node (Save to Database) is required.
Setup Instructions
- Download the n8n workflow JSON file.
- Import the workflow into your n8n instance.
- Step 1: Populate Credential Database a. Locate the 'n8n' node (it's the one connected to 'When clicking "Test workflow"'). Configure it by selecting or creating your n8n API credentials. This API key's scope will determine which workflows are discoverable. b. Manually run the workflow by clicking "Test workflow" on the 'When clicking "Test workflow"' node. This will execute the first part, fetching workflow data and populating the temporary SQLite database.
- Step 2: Configure and Interact with the AI Agent a. In the 'OpenAI Chat Model' node, select or create your OpenAI API credentials. b. The 'Workflow Credentials Helper Agent' and 'Query Workflow Credentials Database' tool are pre-configured. You can review the system prompt in the 'Workflow Credentials Helper Agent' node for customization if needed. c. To interact with the agent, you can either: i. Activate the entire workflow (toggle on the top right of the n8n editor) and then open the Chat Trigger's production webhook URL in your browser. ii. Or, for testing, open the Chat Trigger's test webhook URL (available in its 'Webhook URLs' section) in your browser after ensuring the credential database has been populated (Step 3b). d. Ask questions like: "Which workflows use Slack credentials?" or "Find workflows with 'customer' in their name that use OpenAI."
- Remember, the database population (Step 3b) needs to be run to make data available for the AI agent to query. If n8n restarts, or the execution that populated the database finishes and is cleaned up, you'll need to re-run this step.
Want your own unique AI agent?
Talk to us - we know how to build custom AI agents for your specific needs.
Schedule a Consultation