{"id":26483825,"url":"https://github.com/chatopera/chatbot-samples","last_synced_at":"2025-03-20T04:58:13.247Z","repository":{"id":38355036,"uuid":"139812191","full_name":"chatopera/chatbot-samples","owner":"chatopera","description":"🤖  聊天机器人示例，定制聊天机器人，聊天机器人语料导入导出","archived":false,"fork":false,"pushed_at":"2024-06-28T02:27:51.000Z","size":6922,"stargazers_count":123,"open_issues_count":1,"forks_count":41,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-06-28T06:37:35.785Z","etag":null,"topics":["chatbot","natural-language-generation","natural-language-processing","natural-language-understanding","personal-assistant"],"latest_commit_sha":null,"homepage":"https://github.com/chatopera/docs/issues?q=label%3ASamples","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chatopera.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-05T07:35:03.000Z","updated_at":"2024-06-28T02:27:55.000Z","dependencies_parsed_at":"2024-06-18T07:39:06.436Z","dependency_job_id":"71d7fa05-8857-45a6-83df-da2052bd77c2","html_url":"https://github.com/chatopera/chatbot-samples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chatopera%2Fchatbot-samples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chatopera%2Fchatbot-samples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chatopera%2Fchatbot-samples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chatopera%2Fchatbot-samples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chatopera","download_url":"https://codeload.github.com/chatopera/chatbot-samples/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244554067,"owners_count":20471173,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chatbot","natural-language-generation","natural-language-processing","natural-language-understanding","personal-assistant"],"created_at":"2025-03-20T04:58:12.769Z","updated_at":"2025-03-20T04:58:13.237Z","avatar_url":"https://github.com/chatopera.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=right\u003e\n\n[Chatopera 云服务](https://bot.chatopera.com/)　|　[入门教程](https://docs.chatopera.com/products/chatbot-platform/tutorials/index.html)　|　[文档中心](https://docs.chatopera.com/index.html)\n\n\u003c/div\u003e\n\n# Chatopera 示例程序\n\n[GitHub](https://github.com/chatopera/chatbot-samples/) | [Gitee](https://gitee.com/chatopera/chatbot-samples)\n\n本源码库提供多个示例程序项目，基于这些项目，您可以：\n\n- 快速掌握 Chatopera 对话机器人开发，实现智能问答，智能客服等应用；\n- 以对话模板为脚手架，学习最佳实践，开发多轮对话；\n- 快速掌握 Chatopera 机器人的系统集成。\n\n## 开始阅读前\n\n* 请完成入门教程，[查看文档](https://docs.chatopera.com/products/chatbot-platform/tutorials/index.html)\n* 本文面向开发者撰写，有命令行工具或编程语言经验：Bash（或 PowerShell）, Git, JavaScript\n\n## 工单\n\n有关 [chatopera/chatbot-samples](https://github.com/chatopera/chatbot-samples) 的工单，提交到 -\n\n[https://github.com/chatopera/docs/issues?q=label%3ASamples](https://github.com/chatopera/docs/issues?q=label%3ASamples)\n\n## 安装 CLI\n\n[CLI 命令行工具](https://docs.chatopera.com/products/chatbot-platform/references/cli.html)是自动化的脚本命令，使用 CLI 命令行工具可快速的导入或导出机器人语料。使用 CLI 工具，需要先安装依赖：\n\n* Git - [Windows 安装指南](https://gitforwindows.org/) | [macOS](https://git-scm.com/download/mac) | [Linux](https://git-scm.com/downloads)\n* Node.js - [安装指南](https://nodejs.org/zh-cn)\n\nCLI 同时依赖操作系统的命令行终端，如 PowerShell, CMD Prompt, Bash Shell, etc.\n\n打开命令行中断，比如 PowerShell，执行 `npm --version`，确认可以看到类似的输出。\n\n![Alt text](assets/images/screenshot_20240627135527.png)\n\n证明 nodejs 已经安装成功。然后，执行：\n\n```\nnpm install -g @chatopera/sdk\n```\n\n进行安装 CLI，上述命令执行后，在命令行执行 ``，确认可以看到类似这样的输出。\n\n![Alt text](assets/images/screenshot_20240627135732.png)\n\n## 克隆代码\n\n```\ngit clone https://github.com/chatopera/chatbot-samples.git\ncd chatbot-samples\npwd # 得到代码路径 ROOT_PATH\nls projects # projects 目录内存放多个示例项目\n```\n\n`{{ROOT_PATH}}` 是项目 [https://github.com/chatopera/chatbot-samples](https://github.com/chatopera/chatbot-samples) 存放的路径, 比如 `/c/Users/Administrator/chatbot-samples`。\n\n## 使用 CLI 导入示例程序\n\n首先，[安装 CLI 和克隆代码](https://github.com/chatopera/chatbot-samples?tab=readme-ov-file#%E5%AE%89%E8%A3%85-cli)，然后执行下面的步骤。\n\n### 导入语料\n将某个示例程序，导入到一个已有的聊天机器人。假设已经在 [https://bot.chatopera.com/dashboard](https://bot.chatopera.com/dashboard) 创建了一个聊天机器人，并获得了 ClientID 和 Secret 信息。 \n\n接着**按照顺序，执行下面的命令**：\n\n```\n#cd {{ROOT_PATH}}/projects/{{PROJECT_NAME}} # 使用哪个示例项目，就进入哪个文件夹\ncd {{ROOT_PATH}}/projects/GitHub工单机器人 # 比如，进入【GitHub工单机器人】 \nbot env # 自动生成 .env 文件，然后更新 .env 文件中的 BOT_CLIENT_ID 和 BOT_CLIENT_SECRET\nbot dicts --action import -f bot.dicts.json # 导出词典\nbot faq --action import -f bot.faqs.json    # 导出知识库\nbot intents --action import -f bot.intents.json # 导出意图识别\nbot conversation --action import -f bot.conversations.c66 # 导出多轮对话\n```\n\n这样，就可以访问机器人了，比如从 H5 聊天控件，和机器人对话。\n\n### 导出语料\n将目前 `.env` 文件中的机器人的语料导出为本地的语料文件。\n\n```\ncd {{ROOT_PATH}}/projects/GitHub工单机器人 # 使用哪个示例项目，就进入哪个文件夹\nbot dicts --action export -f bot.dicts.json # 假设已经创建了 .env 文件，并设定 BOT_CLIENT_ID 和 BOT_CLIENT_SECRET\nbot faq --action export -f bot.faqs.json\nbot intents --action export -f bot.intents.json\nbot conversation --action export -f bot.conversations.c66\n```\n\n这样，就完成了机器人对话技能的备份。\n\n**导入和导出中，文件格式是一样的。**\n\n## 更多说明\n\n### 示例程序目录\n\n查看[示例程序目录](./projects)。\n\n[![Alt text](assets/images/screenshot_20240620093658.png)](./projects)\n\n每个**示例程序**按照如下的结构组织。\n\n```\n根目录\n├── README.md                  # 该项目的使用说明，必读\n├── bot.dicts.json             # 词典导入文件，包括引用词典、词汇表词典和正则表达式词典\n├── bot.faqs.json              # 知识库导入文件，包括标准问、扩展问、分类等\n├── bot.intents.json           # 意图识别导入文件，包含意图、说法、槽位等\n├── bot.conversations.c66      # 多轮对话导入文件，包含脚本、函数等\n├── conversations              # 多轮对话文件解压后的内容，.c66 文件是 zip 压缩包\n├── flow.mdj                   # UML 对话流程文件，描述对话流程，可能有\n└── flow.xlsx                  # Excel 话术文件，描述对话流程，可能有\n```\n\n### 语料导入导出的更多介绍\n\n了解导入导出语料，[查看文档](https://docs.chatopera.com/products/chatbot-platform/howto-guides/integration/cli-export-import.html)\n\n### 设置命令快捷方式\n\n在 shell profile 中设置如下命令, 比如 `~/.zshrc` or `~/.bashrc`。\n\n```\nexport CHATBOT_SAMPLES={{ROOT_PATH}}\n# export bot files into current work dir\nalias botexport=\"$CHATBOT_SAMPLES/bin/export.sh\"\n# import bot files under current work dir\nalias botimport=\"$CHATBOT_SAMPLES/bin/import.sh\"\n# package conversations folder as bot.conversations.c66\nalias botconpac=\"$CHATBOT_SAMPLES/bin/conversation.package.sh\"\n```\n\n现在，使用命令 `botimport` 和 `botexport` 完成导入 BOT 和导出 BOT 的操作，比如：\n\n```\ncd projects/GitHub工单机器人\nbotimport # 导入语料到聊天机器人\nbotexport # 导出聊天机器人到语料\n```\n\n# LICENSE\n\n[Apache 2.0](./LICENSE)\n\n[![chatoper banner][co-banner-image]][co-url]\n\n[co-banner-image]: ./assets/8.png\n[co-url]: https://www.chatopera.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchatopera%2Fchatbot-samples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchatopera%2Fchatbot-samples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchatopera%2Fchatbot-samples/lists"}