你好,
经过数周的调试,我终于成功设置了一个类似于 discobot 的 AI 机器人,但它具备学习能力且响应更加灵敏。以下是我的设置步骤,供有兴趣自行搭建的参考。虽然步骤较多,但一旦配置完成,效果令人惊叹。
-
为 Discourse 安装 hubot 插件:https://meta.discourse.org/t/hubot-adapter-for-discourse/63419。要在您的 Discourse 上安装 hubot,需要将 hubot 相关变量(如 HUBOT_DISCOURSE_USERNAME)写入 (yourhubotfolder)/bin/hubot 文件中。只需使用 nano 或其他编辑器打开该文件,添加如下内容:export HUBOT_DISCOURSE_USERNAME=mybot。更多详细信息请访问:Discobot for training - #10 by featheredtoast
-
在 https://dialogflow.com/ 注册并创建一个新的机器人。
-
从以下地址安装 hubot / apiai(即 Dialogflow)适配器:GitHub - ojacques/hubot-apiai: Add smartness and conversational UX to Hubot with API.AI as back-end · GitHub
3a. 在 bin/hubot 文件中,确保已设置以下变量:
export HUBOT_DISCOURSE_USERNAME=(机器人的用户名,请勿使用 discobot)
export HUBOT_DISCOURSE_KEY=(您的机器人用户的 API 密钥,而非站点 API 密钥)
export HUBOT_DISCOURSE_SERVER=(Discourse 服务器地址)
export API_AI_CLIENT_ACCESS_TOKEN=(Dialogflow 机器人服务器的 API 密钥,可在设置中找到)
export GOOGLE_APPLICATION_CREDENTIALS=(yourjson).json
export DIALOGFLOW_PROJECT_ID=(项目名称)
您需要下载一个 Google 应用凭据 JSON 文件,可按照以下指南操作:https://cloud.google.com/genomics/downloading-credentials-for-api-access
-
现在通过输入 bin/hubot -a discourse-adapter 启动您的 hubot。如果您希望它在终端关闭后仍继续运行,请输入 nohup bin/hubot -a discourse-adapter &
-
通过私聊机器人进行测试。如果您在 Dialogflow 中设置了闲聊功能,可以直接说“你好”、“你好吗”等进行闲聊。其他对话功能需要您自行配置。YouTube 上有几个不错的入门教程,例如:https://youtu.be/HqfN9qjNj9A
以下是演示:
如果您有任何问题,欢迎随时提问。
此外,特别感谢 @codinghorror 及其团队开发 Discourse,以及 @awole20 开发 hubot 插件,没有你们我无法完成这一切!
38 个赞
This is just plain awesome! I am not too experienced with this myself, but do you know if this would work to deploy on Heroku or not? Thanks for the tutorial!
1 个赞
Hubot is indeed able to be installed on Heroku - check out the Hubot docs for more info: Deploying to Heroku | HUBOT
5 个赞
That’s cool. I’ll look further into this.
1 个赞
@awole20 @Timothy_Vail I know I sound absolutely hilarious by saying this, but is there any way to make a bot that you guys know of without being an admin (a.k.a having an api key)?
1 个赞
You need to be the admin of not only discourse but of the server it sits on. No way around that one.
3 个赞
That´s a bummer. Thanks for the information though.
1 个赞
I am slowly working my way through this. What threw me at the first stage was access errors when running yo hubot --adapter=discourse-adapter per the installation instructions for the plugin. It looks like you have to change the permission for the folders. Fix is documented here.
1 个赞
So, as I discussed above, I hit an error installing NPM. Error was using root when installing, a common gotcha that leads to a lot of EACCES and permission errors. This is a well-documented error. I believe a lot of people are on Digital Ocean. Follow their documentation for correctly setting up NPM on your droplet.
谢谢你的分享,Tim。我很好奇你为聊天机器人设置了哪些类型的对话。你的论坛用户在实际中是如何与它互动的?
4 个赞
你好,Nacho,
其实我已经有一段时间没有使用聊天机器人了,但我计划在一个即将开展的项目中再次使用它。它主要用于教师的培训 session,老师们会通过聊天机器人完成课程,并通过对话学习教学方法。如果您有任何问题,请随时告诉我。
5 个赞
哇,太棒了,我得好好消化几天。
我的 Discourse 站点需要一些 AI 功能。
3 个赞
在我深入到我的 Discourse 上实施之前(而且由于我只掌握一部分技能,但很擅长遵循指示
)……这个帖子里的说明是否仍然有效?或者……有没有更当前或更推荐的集成 AI 机器人的方法?
3 个赞