n8n-nodes-dify-chat-model
v1.0.1
Published
N8N custom node for Dify Chat Model API with cache support - Compatible with AI Agent
Maintainers
Readme
N8N Dify Chat Model Node
N8N custom node for integrating Dify Chat Model API with cache support. This node is compatible with N8N's AI Agent and allows you to use Dify's caching capabilities to reduce token costs significantly.
🎯 Features
- ✅ Compatible with N8N AI Agent - Works seamlessly with AI Agent Chat Model output
- ✅ Cache Support - Leverages Dify's cache to reduce token costs
- ✅ Conversation Persistence - Supports continuing existing conversations
- ✅ Flexible Configuration - Configurable response modes (blocking/streaming)
- ✅ Input Variables - Support for custom input variables
- ✅ Secure Credentials - Secure credential management
📦 Installation
Via N8N Community Nodes (Recommended)
- Open your N8N instance
- Go to Settings → Community Nodes
- Search for
n8n-nodes-dify-chat-model - Click Install
- Restart N8N if prompted
Via npm
npm install n8n-nodes-dify-chat-modelThen restart your N8N instance.
🚀 Usage
1. Configure Credentials
- Add the Dify Chat Model node to your workflow
- Click on Credential to connect with
- Click Create New Credential
- Select Dify API
- Fill in:
- API Key: Your Dify API key
- Base URL:
https://api.dify.ai(or your self-hosted URL)
- Click Save
2. Configure the Node
- App ID: Your Dify Application ID (required)
- User ID: User identifier (optional, default: "n8n-user")
- Conversation ID: To continue existing conversations (optional)
- Response Mode: "Blocking" (recommended for AI Agent)
- Input Variables: Additional variables as JSON object (optional)
- Query: Automatically picks up from AI Agent output
3. Connect to AI Agent
Connect this node to the Chat Model output of your AI Agent node.
💡 Why Use This Node?
- 💰 Cost Savings: Dify's cache significantly reduces token usage compared to direct LLM calls
- 🔌 Compatibility: Works seamlessly with N8N's AI Agent
- 🌐 Flexibility: Supports both cloud and self-hosted Dify instances
- ⚡ Performance: Faster responses with cached results
📋 Requirements
- N8N version 1.0.0 or higher
- Dify API access (cloud or self-hosted)
- Dify Application ID
🔧 Development
# Install dependencies
npm install
# Build the project
npm run build
# Watch mode for development
npm run dev
# Lint
npm run lint
# Format code
npm run format📖 Documentation
🐛 Issues & Support
For issues and questions:
📝 License
MIT
🙏 Credits
Built for the N8N community to enable cost-effective AI agent workflows with Dify's caching capabilities.
