Overview
This node integrates with the Dify API to perform three main operations: sending chat messages, converting audio files to text, and uploading files. It is useful in scenarios where you want to interact programmatically with Dify's AI services, such as building conversational agents, transcribing audio content, or managing file uploads within an n8n workflow.
Practical examples include:
- Sending a user query to a chatbot and receiving a response.
- Transcribing recorded audio messages into text for further processing.
- Uploading various types of files (images, documents, videos) to the Dify platform for storage or analysis.
Properties
| Name | Meaning |
|---|---|
| Operation | The action to perform: "Send Chat Message", "Audio to Text", or "File Upload". |
| User ID | Unique identifier for the user making the request. |
| Query | The text content of the user's message (used only for "Send Chat Message" operation). |
| Conversation ID | Identifier to continue an existing conversation (optional, used only for "Send Chat Message"). |
| Response Mode | How the API should respond: "Streaming" or "Blocking" (only for "Send Chat Message"). |
| Files | Collection of files to send along with the chat message, specifying type and transfer method. |
| Binary Property | Name of the binary property containing the file data (used for "Audio to Text" and "File Upload"). |
Details on Files property options (for "Send Chat Message"):
- Type: Audio, Custom, Document, Image, Video
- Transfer Method: Remote URL or Local File
- Depending on transfer method, specify either a URL or an uploaded file ID.
Output
The node outputs an array of items, each containing a json field with the response from the Dify API corresponding to the selected operation:
- For Send Chat Message, the JSON contains the chat response including any generated messages or metadata.
- For Audio to Text, the JSON includes the transcription result of the provided audio file.
- For File Upload, the JSON returns details about the uploaded file such as its ID and status.
If binary data is involved (in audio-to-text or file upload), the node expects the input binary data to be present but does not output binary data itself; it outputs the API response in JSON format.
Dependencies
- Requires an active connection to the Dify API via an API key credential.
- The base URL for the API is configurable through credentials and normalized internally.
- Uses HTTP POST requests with JSON bodies or multipart form-data depending on the operation.
- Requires n8n helpers for handling HTTP requests and binary data extraction.
Troubleshooting
- Missing binary data error: If the node is set to process audio or file upload but the specified binary property is missing, it throws an error indicating the absent binary data property. Ensure that the input item contains the correct binary data under the specified property name.
- Invalid API credentials: If the API key is incorrect or missing, requests will fail authorization. Verify the API key credential configuration.
- Incorrect operation parameters: Providing parameters irrelevant to the chosen operation (e.g., query text for file upload) will have no effect; ensure parameters match the selected operation.
- Base URL issues: The node normalizes the base URL by enforcing HTTPS and trimming trailing slashes or version suffixes. Misconfigured URLs might cause request failures.
Links and References
- Dify API Documentation (general reference for API endpoints and usage)
- n8n Documentation - Creating Nodes (for understanding node development concepts)