n8n Integration
Use PromptRails as a node in your n8n workflows — execute agents, run prompts, manage chat sessions, and more.
n8n Integration
The official n8n community node for PromptRails lets you integrate AI agents, prompts, chat sessions, and data sources into your n8n workflows. Execute agents on schedule, respond to webhooks with AI, monitor costs, and build complex automation pipelines.
Installation
In your n8n instance:
- Go to Settings > Community Nodes
- Select Install a community node
- Enter
@promptrails/n8n-nodes-promptrails - Click Install
Configuration
Create a PromptRails API credential in n8n with the following fields:
| Field | Description |
|---|---|
| Host URL | https://api.promptrails.ai (default) |
| API Key | Your PromptRails API key (starts with pr_key_) |
To create an API key, go to Settings > API Keys in the PromptRails dashboard. See API Keys & Scopes for required scopes.
Resources & Operations
| Resource | Operations | Required Scopes |
|---|---|---|
| Agent | Execute, Preview, Get, List | agents:read, agents:execute |
| Prompt | Run, Get, List | prompts:read, prompts:execute |
| Chat | Create Session, Send Message, Get Session, List Sessions, List Messages | chat:write, sessions:read |
| Execution | Get, List | executions:read |
| Data Source | Query, Get, List | data_sources:read, data_sources:execute |
| Trace | Get, List | traces:read |
| Cost | Workspace Summary, Agent Summary | executions:read |
Example Workflows
Execute an Agent on Schedule
Trigger an agent every hour and send the result to Slack:
- Schedule Trigger — Run every hour
- PromptRails — Resource: Agent, Operation: Execute, provide the Agent ID and variables
- Slack — Post the agent output to a channel
AI-Powered Webhook Responder
Respond to incoming HTTP requests with an AI agent:
- Webhook — Receive incoming requests
- PromptRails — Resource: Chat, Operation: Send Message
- Respond to Webhook — Return the agent's response
Multi-Turn Chat Bot
Build a stateful chatbot using chat sessions:
- Webhook — Receive user messages
- IF — Check if session ID exists in the request
- PromptRails — Resource: Chat, Operation: Create Session (if new)
- PromptRails — Resource: Chat, Operation: Send Message
- Respond to Webhook — Return the response
Daily Cost Monitoring
Monitor your AI spending and get alerts:
- Schedule Trigger — Run daily at 9 AM
- PromptRails — Resource: Cost, Operation: Workspace Summary
- IF — Check if total cost exceeds budget threshold
- Email / Slack — Send an alert notification
Data Source Query Pipeline
Query a data source and process the results:
- Schedule Trigger or Webhook — Trigger the workflow
- PromptRails — Resource: Data Source, Operation: Query
- PromptRails — Resource: Agent, Operation: Execute (analyze the query results)
- Google Sheets — Write the analysis to a spreadsheet
Tips
- Variables as JSON: Agent Execute and Prompt Run accept variables as a JSON object. Use n8n expressions to build dynamic variables from previous nodes:
{{ JSON.stringify({ query: $json.message }) }} - Pagination: List operations support
pageandlimitparameters for paginating through results - Error handling: Use n8n's built-in error handling to retry failed operations or route to fallback paths
- Chaining: Chain multiple PromptRails operations — e.g., create a chat session, then send messages in sequence
Related Topics
- API Keys & Scopes -- Managing API keys and permissions
- Webhook Triggers -- Trigger agents via HTTP webhooks
- REST API Reference -- Full API documentation
- Python SDK -- Python SDK alternative
- JavaScript SDK -- JavaScript SDK alternative