Ai bot rongcloud dify integration guide
Here is the full English translation of your document titled “AI Bot Development: Integration of RongCloud IM with Dify – A Practical Guide”:
AI Bot Development: RongCloud IM and Dify Integration Guide
Author: wangqijia|RongCloud Developer Team Date: June 2025
1. Overview
RongCloud IM PaaS provides comprehensive AI bot management capabilities, supporting rich event callbacks triggered by specific bots. This enables developers to flexibly handle various business scenarios, such as:
- Initiating one-on-one conversations with bots
- Using @mention to trigger contextual responses
In addition, the platform comes with built-in integration capabilities for AI platforms, allowing bot messages to be automatically forwarded to connected LLM platforms (e.g., Dify). This eliminates the need for an intermediate service layer, greatly improving the stability of message flow, reducing integration costs, and accelerating development delivery.
This guide will walk you through integrating AI bots into the RongCloud IM platform and connecting them with Dify LLM services.
2. High-Level Architecture
Workflow:
- App Server
- Manages bots, processes webhook callbacks, and receives bot messages.
- User Client
- Sends user messages and receives bot responses.
- IM Server
-
Message Forwarding: Forwards messages to Dify based on callback types (e.g.,
dify_chat
,dify_completion
) and supports both streaming and non-streaming modes. -
Response Handling and Session Management:
-
Streaming: Pushes incremental content from Dify in real time.
-
Non-streaming: Sends the complete message after receiving the full response.
-
Session Context: Stores
conversation_id
from the first interaction (valid for 24 hours). Subsequent messages use this ID to maintain multi-turn context.
- Dify
- Receives the message, performs inference, and returns either streaming or complete text responses.
3. Integration and Deployment Guide
This section helps you deploy and configure the integration quickly, enabling you to experience intelligent bot interactions on RongCloud IM.
3.1 Prerequisites
Before integrating your bot, please ensure the following:
- You have created an application on the RongCloud Developer Console and obtained a valid
App Key
andApp Secret
. - Dify is deployed (either self-hosted or via a cloud service).
3.2 Supported Callback Types
Callback types determine how bots interact with different platforms or systems. Currently supported types include:
Type | Description |
---|---|
webhook | Custom callback via webhook, suitable for flexible integration |
dify_chat | Connects to Dify’s “Chat Assistant” mode for building multi-turn bots |
dify_completion | Connects to Dify’s “Text Completion” mode for generative applications |
dify_chatflow | Connects to Dify’s “Chatflow” mode for flow-based conversational design |
3.3 Integration Steps
- Create a Dify App: Create an app in Dify and obtain the API key.
- Create a Real User: Create a real user account to interact with the bot.
- Configure the Bot and Callback Address: Register your bot and set up the message callback.
- Verify Integration: Send a private message from the real user to the bot and confirm the response from Dify.
- Verify Multi-Turn Conversation: Continue sending messages from the same user to the bot and check if context is preserved.
⚠️ Note: RongCloud API calls require authentication. Use the provided script to generate credentials.
Step 1: Create a Dify App
Message assistants connect using the dify_chatflow
mode, which supports memory-based multi-turn workflows.
You can check the full DSL config example: dify-chatflow-dsl.yml
Step 2: Create a Real User
Step 3: Configure Bot and Callback Address
Depending on your scenario, choose between:
- Streaming mode: Best for long or incremental responses, offering a smoother user experience.
- Non-streaming mode: Best when responses are shown only after completion.
Step 4: Verify Integration
Send a message from the real user created in step 2:
Demo screenshots from Sealtalk APP:
Step 5: Verify Multi-Turn Conversations
Send multiple messages from the same user to the same bot and check if the context is preserved.
The Dify log shows 4 messages, confirming that multi-turn conversation context is successfully maintained within the same session.
4. Use Cases
4.1 Message Assistant: Enable smart Q&A, task execution, content generation
- Knowledge Q&A powered by knowledge base or LLM
- Content generation requests (e.g., “Write an apology email”)
- Translation requests (e.g., “Translate this to English”)
- Instruction requests that trigger system actions (e.g., “Create a ticket”)
- FAQ automation based on user intent parsing
4.2 Companion Bot: Create personalized, emotionally intelligent chatbots
- Natural casual conversations to fulfill daily social interaction needs
- Role simulation (e.g., friend, therapist, virtual idol) to enhance engagement
- Emotion-aware responses and empathetic interaction
- Combine with custom character settings (e.g., “AI Partner”, “Career Coach”) for immersive experiences
5. Best Practices
5.1 Use Metadata to Personalize Bot Context
When creating bots, you can pass custom metadata for the creator. This metadata will be included in message callbacks and forwarded to Dify. It can be used for:
- Prompt variable substitution
- Contextual customization
- Flow orchestration
5.2 Configure Separate Bots and Dify Apps per Scenario
It is recommended to create separate bots and Dify apps for each business use case (e.g., Q&A, translation, tools, companionship). Assign specific prompts to each bot for better targeting and improved user experience.
6. Utility Scripts
6.1 Generate RongCloud HTTP Signature
Conclusion
Thank you for exploring this guide on integrating RongCloud IM PaaS with Dify LLM services. This powerful combination simplifies the AI bot development process by reducing technical complexity, while providing a robust callback mechanism and native multi-turn support.
Whether you’re building a knowledge bot, a content generation tool, or a personalized companion chatbot, RongCloud and Dify together offer a stable and efficient solution.
As AI technology continues to evolve, we will keep enhancing platform compatibility and provide more tools and documentation. We welcome your feedback to help shape the future of intelligent dialogue systems.
Wishing you success on your development journey and in your projects!