← 返回 Skills 市场
Q1:
Q2:
Q3:
Q4:
78
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install dify-chat
功能描述
使用 OpenClaw 调用本地 Dify API,以对话模式查询知识库。支持单个工作流的多轮对话和流式响应输出。当用户需要访问公司内部知识库、文档查询或问答系统时触发,如"帮我查一下知识库""查询下Dify知识库"等场景。
使用说明 (SKILL.md)
Dify Chat Skill - 本地知识库对话机器人
🤖 技能简介
本skill允许你在OpenClaw中通过命令行调用本地部署的Dify API,进行知识库问答和对话交互。适合用于自动化查询、智能客服场景。
⚙️ 前置配置
1. 环境变量配置
确保 ~/.openclaw/config/dify.env 存在并配置:
# Dify API 配置
DIFY_API_KEY=your_KEY
DIFY_API_BASE=your_DIFY_API_BASE
DIFY_USER=openclaw-user
环境变量说明:
| 变量 | 类型 | 必填 | 说明 |
|---|---|---|---|
DIFY_API_KEY |
string | ✅ | Dify API Key(应用密钥) |
DIFY_API_BASE |
string | ✅ | Dify API 基础 URL |
DIFY_USER |
string | ⚪ | 用户标识(可选,默认 openclaw-user) |
🛠️ 工具使用
dify-chat - Dify 对话机器人
调用方式: 在 OpenClaw CLI 中直接输入 dify-chat 命令
必需参数:
-q, --query \x3C问题>- 要查询的问题或消息(必填)
可选参数:
-c, --conv-id \x3C会话 ID>- 保持多轮对话的会话标识--show-config- 显示当前配置信息-h, --help- 显示帮助信息
📝 使用示例
基础问答
dify-chat -q "什么是公司报销政策?"
输出:
🤖 Dify Chat Bot:
📝 Your query: 什么是公司报销政策?
--------------------------------------------------
🔄 Calling Dify API...
公司报销政策规定:
1. 出差补贴每日上限 500 元,需提供发票
2. 所有报销需在月末前提交审批单
3. 超过 5000 元的支出需要部门主管批准
💬 Conversation ID: conv_abc123xyz
多轮对话
第一次查询(获取会话 ID):
dify-chat -q "公司的年假怎么算?"
# 输出中会显示 conversation_id
继续追问(使用上一次的会话 ID):
dify-chat -q -c conv_abc123xyz "那带薪病假呢?"
查看配置状态
dify-chat --show-config
输出:
📋 Current Configuration:
API Base: your_DIFY_API_BASE
User: openclaw-user
✅ Status: Connected
🎯 最佳实践
✅ 推荐用法
- 知识库问答场景: 无需额外参数,自动调用 Dify 工作流
- 连续对话: 保存
conversation_id用于多轮交流,保持上下文 - 错误处理: CLI 会显示详细错误信息和可能的原因
⚠️ 注意事项
- 避免频繁调用 API(注意速率限制)
- 不要传递敏感信息到 API logs
- 会话 ID 在单次对话中重复使用以获得最佳效果
🔄 工作流程
sequenceDiagram
participant User as 用户
participant CLI as dify-chat CLI
participant Dify as Dify API
Note over User,Dify: 单轮对话流程
User->>CLI: dify-chat -q "问题"
CLI->>Dify: POST /chat-messages
Note over Dify: 查询知识库/执行工作流
Dify-->>CLI: SSE 流式响应
CLI-->>User: 实时显示回答
Note over User,Dify: 多轮对话流程
par
CLI->>CLI: 保存 conversation_id
User->>CLI: dify-chat -q "追问" -c ID
end
🐛 常见问题与故障排查
Q1: Error: Missing required environment variables
原因: 环境变量未正确配置或文件不存在
解决:
# 检查配置文件
cat ~/.openclaw/config/dify.env
# 如果缺少 DIFY_API_KEY 或 DIFY_WORKFLOW_ID,请添加
nano ~/.openclaw/config/dify.env
Q2: Cannot connect to API
原因:
- API Base URL 无法访问
- 网络防火墙限制
- Dify 服务未启动
解决:
- 确认 Base URL 正确:`curl -I http://your_DIFY_API_BASE
- 检查网络连通性
- 验证 Dify 服务状态
Q3: 400 Client Error: BAD REQUEST
原因:
- API Key 无效
- 请求参数格式错误
- 工作流 ID 未配置(如果需要)
解决:
# 验证 API Key
source ~/.openclaw/config/dify.env
curl -X POST "$DIFY_API_BASE/chat-messages" \
-H "Authorization: Bearer $DIFY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"inputs": {}, "response_mode": "blocking", "conversation_id": "", "user": "openclaw-user"}'
Q4: Conversation ID not working
原因: 会话 ID 格式错误或已过期
解决:
- 使用最近一次返回的 conversation_id
- 确保格式为
conv_xxx - 尝试新的查询获取新会话 ID
🔗 参考文档
📅 Changelog
| Version | Date | Change |
|---|---|---|
| 1.0.0 | 2026-04-14 | Initial release - Dify workflow chat integration |
🎓 技能元数据
- 技能名称:
dify-chat - 适用场景:
- AI 知识库问答
- 自动化文档查询
- 智能客服集成
- 依赖项: Python requests library, Dify API 访问权限
- 维护者: OpenClaw Team
- 状态: ✅ Production Ready
📌 提示: 运行 dify-chat --help 查看完整帮助信息。如需反馈或改进建议,请通过 OpenClaw 社区渠道提交。
安全使用建议
This skill otherwise appears to do what it says, but before installing: 1) Be aware the SKILL.md and script require a config file at ~/.openclaw/config/dify.env containing DIFY_API_KEY and DIFY_API_BASE — the registry metadata failing to declare these is an incoherence. 2) Verify DIFY_API_BASE points to a trusted/local Dify instance (not a public or unknown endpoint) and only provide an API key with minimal required permissions. 3) Inspect ~/.openclaw/config/dify.env file permissions (restrict to the user) and avoid putting high-privilege credentials there. 4) Note the package includes an executable Python script; if you don’t trust the source (no homepage, source unknown), run it in an isolated environment or review the script fully (it appears straightforward). 5) Ask the publisher to correct the registry metadata to list required env vars/primary credential before deploying widely.
功能分析
Type: OpenClaw Skill
Name: dify-chat
Version: 1.0.0
The skill provides a legitimate interface for interacting with a Dify API to perform knowledge base queries. The Python script `scripts/dify_chat.py` reads configuration from a local environment file and uses the `requests` library to communicate with the user-specified Dify endpoint. There is no evidence of data exfiltration, malicious execution, or prompt injection; the code is transparent and aligns with its stated purpose.
能力标签
能力评估
Purpose & Capability
The skill's stated purpose (calling a local Dify API for KB Q&A) matches the included CLI script and instructions. However, the registry metadata lists no required environment variables or primary credential while SKILL.md and scripts/dify_chat.py explicitly require a config file (~/.openclaw/config/dify.env) containing DIFY_API_KEY and DIFY_API_BASE. The missing declaration in metadata is an incoherence and should be corrected.
Instruction Scope
SKILL.md instructs the agent/user to read ~/.openclaw/config/dify.env and call the Dify API (POST /chat-messages) with streaming responses — that is consistent with the skill's purpose. The instructions do not ask for unrelated system files or other service credentials. Minor inconsistencies: troubleshooting mentions DIFY_WORKFLOW_ID though the script does not use it; the README advises not to send sensitive data but the script will forward any query to the configured API endpoint, so endpoint scope matters.
Install Mechanism
This is an instruction-only skill with a bundled Python script and no automated install spec. It requires the 'requests' Python package (documented). No external downloads or installers are used, which is low-risk from an install perspective.
Credentials
The script legitimately needs DIFY_API_KEY and DIFY_API_BASE (and optionally DIFY_USER) — these are proportional to the task. The problem is that the skill metadata does not declare these required environment variables or a primary credential, creating a mismatch. Also, the skill reads plaintext credentials from ~/.openclaw/config/dify.env; users should ensure that file is stored and permissioned securely and that the API key has minimal scope.
Persistence & Privilege
The skill does not request persistent/global privileges (always is false) and does not modify other skills or system-wide configuration. It simply reads a user config file and performs network calls to the configured Dify endpoint.
如何使用
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install dify-chat - 安装完成后,直接呼叫该 Skill 的名称或使用
/dify-chat触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
dify-chat 1.0.0 - Initial release
- Provides a CLI tool to query a local Dify knowledge base via OpenClaw.
- Supports multi-turn conversations with conversation ID and streaming responses.
- Easily configurable via environment variables.
- Includes commands for basic queries, continued conversations, and viewing config.
- Offers troubleshooting steps and best practices for API interaction.
元数据
常见问题
Dify工作流调用 是什么?
使用 OpenClaw 调用本地 Dify API,以对话模式查询知识库。支持单个工作流的多轮对话和流式响应输出。当用户需要访问公司内部知识库、文档查询或问答系统时触发,如"帮我查一下知识库""查询下Dify知识库"等场景。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 78 次。
如何安装 Dify工作流调用?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install dify-chat」即可一键安装,无需额外配置。
Dify工作流调用 是免费的吗?
是的,Dify工作流调用 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
Dify工作流调用 支持哪些平台?
Dify工作流调用 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Dify工作流调用?
由 Better.(@yep123456)开发并维护,当前版本 v1.0.0。
推荐 Skills