开发Hubot聊天机器人

本文介绍了如何开发和使用开源聊天机器人Hubot,包括它的功能、应用案例和如何借助Hubot自动化任务。Hubot是基于Node.js和CoffeeScript的,支持运维自动化、外部服务交互等多种用途。文章详细阐述了安装过程、创建自定义机器人、运行机器人、编写脚本、安装脚本和自定义Adapter的步骤,并提供了相关资源链接。
摘要由CSDN通过智能技术生成
大家所熟知的智能聊天机器人,比如:微软小冰、Apple Siri、Google Now、IBM Watson等。微信自动回复、微信服务号里的客服Bot也都算是简单的实例。聊天机器人(Dialog System)主要实现方式有:基于人工模板(比如AIML)、基于搜索技术(比如ElasticSearch)、基于深度学习。从零实现这样的系统是很复杂的。

开源的ChatOps机器人:
1.[url=https://hubot.github.com/]Hubot[/url]:CoffeeScipt编写
2.[url=https://www.lita.io/]Lita[/url]:Ruby编写
3.[url=http://errbot.io/]Errbot[/url]:Python编写
[img]http://dl2.iteye.com/upload/attachment/0120/4886/05f0cb93-289d-3fd6-9b18-b664d7fc43c6.jpg[/img]
[url=https://www.pagerduty.com/blog/what-is-chatops/]So, What is ChatOps? And How do I Get Started?[/url]
[url=http://nordicapis.com/12-frameworks-to-build-chatops-bots/]12+ Frameworks to Build ChatOps Bots[/url]

[b]Hubot是由Github开发的开源聊天机器人,基于Node.js采用CoffeeScript编写。[/b]
Hubot [url=https://hubot.github.com/]https://hubot.github.com/[/url]
Hubot Scripts [url=https://github.com/hubot-scripts]https://github.com/hubot-scripts[/url]
Hubot Control [url=https://github.com/spajus/hubot-control]https://github.com/spajus/hubot-control[/url]

可以借助Hubot开发Chatbot来自动化的完成想要一切自动化任务,比如:
-运维自动化(编译部署代码、重启机器,监控服务器运行情况,自动修复Bug等)
-外部服务交互(管理Redmine、集成Jenkins、监视Zabbix等)
-定时获取天气预报
-随机订餐
-聊天机器人等等。
[img]http://dl2.iteye.com/upload/attachment/0120/4888/2193617c-9b79-3d28-91c2-1535de15f2c3.png[/img]

官方文档里有详细的使用说明,[url=https://hubot.github.com/docs/]https://hubot.github.com/docs/[/url],这里只做一个摘要。
Hubot Scripts里有大量的现成脚本可以用,也是自己编写脚本的最好sample。

[img]http://dl2.iteye.com/upload/attachment/0120/5867/d271c6db-3753-393b-ae7c-68408fcac6ce.png[/img]

[color=blue][b](一)安装[/b][/color]
运行Hubot需要以下软件支持:
[list]
[*]Node.js
[*]Redis 默认存贮数据
[*]CoffeeScript
[*]Yeoman
[*]generator-hubot 生成Hubot骨架工程
[/list]
[quote]C:\Users\rensanning>node -v
v0.12.8
C:\Users\rensanning>npm -v
2.14.9
C:\Users\rensanning>npm install -g yo generator-hubot
C:\Users\rensanning>npm list -g generator-hubot yo[/quote]

[color=blue][b](二)创建自己的bot[/b][/color]
[quote]C:\Users\rensanning>cd d:/
D:\>mkdir hubotsample
D:\>cd hubotsample
D:\hubotsample>yo hubot
? Owner RenSanNing <rensanning@gmail.com>
? Bot name okbot
? Description A sample hubot
? Bot adapter campfire[/quote]
默认提供了campfire和shell的adapter,其他的需要通过npm下载hubot-<AdapterName>。
也可以通过参数直接生成:
[quote]yo hubot --owner=rensanning@gmail.com --name=foobot --description="Foo Bot" --adapter=shell[/quote]

项目结构:
[list]
[*]bin/ 运行脚本
[*]node_modules 应用的包文件
[*]scripts 存放自定义脚本
[*]external-scripts.json 应用的外部脚本
[*]hubot-scripts.json *** 该文件已经无用,可以删除
[*]package.json 项目全局配置信息
[/list]

[color=blue][b](三)运行bot[/b][/color]

[quote]D:\hubotsample>bin\hubot -v
2.19.0
D:\hubotsample>bin\hubot -h
Usage hubot [o
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值