{"id":1298,"date":"2015-06-01T18:13:22","date_gmt":"2015-06-01T10:13:22","guid":{"rendered":"http:\/\/www.strongd.net\/?p=1298"},"modified":"2015-07-30T17:34:21","modified_gmt":"2015-07-30T09:34:21","slug":"getting-started-with-hubot","status":"publish","type":"post","link":"https:\/\/www.strongd.net\/?p=1298","title":{"rendered":"Getting Started With Hubot"},"content":{"rendered":"<p>You will need <a href=\"http:\/\/nodejs.org\/\">node.js<\/a> and <a href=\"https:\/\/npmjs.org\/\">npm<\/a>. Joyent has<br \/>\nan <a href=\"http:\/\/joyent.com\/blog\/installing-node-and-npm\">excellent blog post on how to get those installed<\/a>, so we&#8217;ll omit those details here.<\/p>\n<p>Once node and npm are ready, we can install the hubot generator:<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-text\" data-lang=\"text\">%  npm install -g yo generator-hubot\r\n<\/code><\/pre>\n<\/div>\n<p>This will give us the <code>hubot<\/code> <a href=\"http:\/\/yeoman.io\/\">yeoman<\/a> generator. Now we<br \/>\ncan make a new directory, and generate a new instance of hubot in it. For example, if<br \/>\nwe wanted to make a bot called myhubot:<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-text\" data-lang=\"text\">% mkdir myhubot\r\n% cd myhubot\r\n% yo hubot\r\n<\/code><\/pre>\n<\/div>\n<p>At this point, you&#8217;ll be asked a few questions about who is creating the bot,<br \/>\nand which <a href=\"https:\/\/hubot.github.com\/docs\/adapters\/\">adapter<\/a> you&#8217;ll be using. Adapters are hubot&#8217;s way of<br \/>\nintegrating with different chat providers.<\/p>\n<p>If you are using git, the generated directory includes a .gitignore, so you can<br \/>\ninitialize and add everything:<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-text\" data-lang=\"text\">% git init\r\n% git add .\r\n% git commit -m \"Initial commit\"\r\n<\/code><\/pre>\n<\/div>\n<p>If you&#8217;d prefer to automate your hubot build without being interactively<br \/>\nprompted for its configuration, you can add the following options<br \/>\nto the <code>yo hubot<\/code> command to do so:<\/p>\n<table>\n<thead>\n<tr>\n<th>Option<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>--owner=\"Bot Wrangler &lt;bw@example.com&gt;\"<\/code><\/td>\n<td>Bot owner, e.g. &#8220;Bot Wrangler <a href=\"mailto:bw@example.com\">bw@example.com<\/a>&#8220;<\/td>\n<\/tr>\n<tr>\n<td><code>--name=\"Hubot\"<\/code><\/td>\n<td>Bot name, e.g. &#8220;Hubot&#8221;<\/td>\n<\/tr>\n<tr>\n<td><code>--description=\"Delightfully aware robutt\"<\/code><\/td>\n<td>Bot description, e.g. &#8220;Delightfully aware robutt&#8221;<\/td>\n<\/tr>\n<tr>\n<td><code>--adapter=campfire<\/code><\/td>\n<td>Bot adapter, e.g. &#8220;campfire&#8221;<\/td>\n<\/tr>\n<tr>\n<td><code>--defaults<\/code><\/td>\n<td>Declare all defaults are set and no prompting required<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>You now have your own functional hubot! There&#8217;s a <code>bin\/hubot<\/code><br \/>\ncommand for convenience, to handle installing npm dependencies, loading scripts,<br \/>\nand then launching your hubot.<\/p>\n<p>Hubot needs Redis to persist data, so before you can start hubot on your own computer, you should have Redis installed on your localhost. If just want to test Hubot without Redis, then you can remove <code>redis-brain.coffee<\/code> from <code>hubot-scripts.json<\/code>.<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-text\" data-lang=\"text\">% bin\/hubot\r\nHubot&gt;\r\n<\/code><\/pre>\n<\/div>\n<p>This starts hubot using the <a href=\"https:\/\/hubot.github.com\/docs\/adapters\/shell\/\">shell adapter<\/a>, which<br \/>\nis mostly useful for development. Make note of <code>Hubot&gt;<\/code>; this is the name your hubot will<br \/>\n<code>respond<\/code> to with commands. For example, to list available commands:<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-text\" data-lang=\"text\">% bin\/hubot\r\nHubot&gt; hubot: help\r\nhubot &lt;keyword&gt; tweet - Returns a link to a tweet about &lt;keyword&gt;\r\nhubot &lt;user&gt; is a badass guitarist - assign a role to a user\r\nhubot &lt;user&gt; is not a badass guitarist - remove a role from a user\r\nhubot animate me &lt;query&gt; - The same thing as `image me`, except adds a few parameters to try to return an animated GIF instead.\r\nhubot convert me &lt;expression&gt; to &lt;units&gt; - Convert expression to given units.\r\nhubot die - End hubot process\r\nhubot echo &lt;text&gt; - Reply back with &lt;text&gt;\r\nhubot fake event &lt;event&gt; - Triggers the &lt;event&gt; event for debugging reasons\r\nhubot help - Displays all of the help commands that Hubot knows about.\r\nhubot help &lt;query&gt; - Displays all help commands that match &lt;query&gt;.\r\nhubot image me &lt;query&gt; - The Original. Queries Google Images for &lt;query&gt; and returns a random top result.\r\nhubot map me &lt;query&gt; - Returns a map view of the area returned by `query`.\r\nhubot mustache me &lt;query&gt; - Searches Google Images for the specified query and mustaches it.\r\nhubot mustache me &lt;url&gt; - Adds a mustache to the specified URL.\r\nhubot ping - Reply with pong\r\nhubot show storage - Display the contents that are persisted in the brain\r\nhubot show users - Display all users that hubot knows about\r\nhubot the rules - Make sure hubot still knows the rules.\r\nhubot time - Reply with current time\r\nhubot translate me &lt;phrase&gt; - Searches for a translation for the &lt;phrase&gt; and then prints that bad boy out.\r\nhubot translate me from &lt;source&gt; into &lt;target&gt; &lt;phrase&gt; - Translates &lt;phrase&gt; from &lt;source&gt; into &lt;target&gt;. Both &lt;source&gt; and &lt;target&gt; are optional\r\nhubot who is &lt;user&gt; - see what roles a user has\r\nhubot youtube me &lt;query&gt; - Searches YouTube for the query and returns the video embed link.\r\nhubot pug bomb N - get N pugs\r\nhubot pug me - Receive a pug\r\nhubot ship it - Display a motivation squirrel\r\n<\/code><\/pre>\n<\/div>\n<p>You almost definitely will want to change your hubot&#8217;s name to add character. bin\/hubot takes a <code>--name<\/code>:<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-text\" data-lang=\"text\">% bin\/hubot --name myhubot\r\nmyhubot&gt;\r\n<\/code><\/pre>\n<\/div>\n<p>Your hubot will now respond as <code>myhubot<\/code>. This is<br \/>\ncase-insensitive, and can be prefixed with <code>@<\/code> or suffixed with <code>:<\/code>. These are equivalent:<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-text\" data-lang=\"text\">MYHUBOT help\r\nmyhubot help\r\n@myhubot help\r\nmyhubot: help\r\n<\/code><\/pre>\n<\/div>\n<h2>Scripting<\/h2>\n<p>Hubot&#8217;s power comes through scripting. Read <a href=\"https:\/\/hubot.github.com\/docs\/scripting\/\">more about scripting<\/a> for the deal on bending hubot to your will using code.<\/p>\n<p>There are many community-contributed scripts available through <a href=\"https:\/\/github.com\/github\/hubot-scripts\">hubot-scripts<\/a>. To use scripts from it:<\/p>\n<ul>\n<li>Make sure <code>hubot-scripts<\/code> is listed as a dependency in <code>package.json<\/code> (it should by default)<\/li>\n<li>Update <code>hubot-scripts.json<\/code> to include the script you want in the list. Make sure the file is still valid JSON!<\/li>\n<li>Review the script to see if there&#8217;s dependencies or configuration to add<\/li>\n<\/ul>\n<p>In addition, there are scripts released as npm packages. If you find one you want to use:<\/p>\n<ol>\n<li>Add the package to the list of <code>dependencies<\/code> into your <code>package.json<\/code><\/li>\n<li><code>npm install<\/code> to make sure its installed<\/li>\n<\/ol>\n<p>To enable third-party scripts that you&#8217;ve added you will need to add the package<br \/>\nname as a double quoted string to the <code>external-scripts.json<\/code> file in this repo.<\/p>\n<p><strong>Please note that external scripts may become the default for hubot scripts in future releases.<\/strong><\/p>\n<h2>Adapters<\/h2>\n<p>Hubot uses the adapter pattern to support multiple chat-backends. Here is a <a href=\"https:\/\/hubot.github.com\/docs\/adapters\/\">list of available adapters<\/a>, along with details on how to configure them.<\/p>\n<h2>Deploying<\/h2>\n<p>You can deploy hubot to Heroku, which is the officially supported method.<br \/>\nAdditionally you are able to deploy hubot to a UNIX-like system or Windows.<br \/>\nPlease note the support for deploying to Windows isn&#8217;t officially supported.<\/p>\n<ul>\n<li><a href=\"https:\/\/hubot.github.com\/docs\/deploying\/heroku\/\">Deploying Hubot onto Heroku<\/a><\/li>\n<li><a href=\"https:\/\/hubot.github.com\/docs\/deploying\/unix\/\">Deploying Hubot onto UNIX<\/a><\/li>\n<li><a href=\"https:\/\/hubot.github.com\/docs\/deploying\/windows\/\">Deploying Hubot onto Windows<\/a><\/li>\n<\/ul>\n<h2>Patterns<\/h2>\n<p>Using custom scripts, you can quickly customize Hubot to be the most life embettering robot he or she can be. Read<a href=\"https:\/\/hubot.github.com\/docs\/patterns\/\">docs\/patterns.md<\/a> for some nifty tricks that may come in handy as you teach your hubot new skills.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You will need node.js and npm. Joyent has an excellent blog post on how to get those installed, so we&#8217;ll omit those details here. Once node and npm are ready, we can install the hubot generator: % npm install -g yo generator-hubot This will give us the hubot yeoman generator. Now we can make a &hellip; <a href=\"https:\/\/www.strongd.net\/?p=1298\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Getting Started With Hubot<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[48],"class_list":["post-1298","post","type-post","status-publish","format-standard","hentry","category-20","tag-hadoop"],"_links":{"self":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/1298","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1298"}],"version-history":[{"count":1,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/1298\/revisions"}],"predecessor-version":[{"id":1299,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/1298\/revisions\/1299"}],"wp:attachment":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1298"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1298"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1298"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}