UNPKG

6.73 kBMarkdownView Raw
1---
2permalink: /docs/
3---
4
5## Getting Started With Hubot
6
7You will need [node.js and npm](https://docs.npmjs.com/getting-started/installing-node). Once those are installed, we can install the hubot generator:
8
9 % npm install -g yo generator-hubot
10
11This will give us the `hubot` [yeoman](http://yeoman.io/) generator. Now we
12can make a new directory, and generate a new instance of hubot in it. For example, if
13we wanted to make a bot called myhubot:
14
15
16 % mkdir myhubot
17 % cd myhubot
18 % yo hubot
19
20At this point, you'll be asked a few questions about who is creating the bot,
21and which [adapter](adapters.md) you'll be using. Adapters are hubot's
22way of integrating with different chat providers.
23
24If you are using git, the generated directory includes a .gitignore, so you can
25initialize and add everything:
26
27 % git init
28 % git add .
29 % git commit -m "Initial commit"
30
31If you'd prefer to automate your hubot build without being interactively
32prompted for its configuration, you can add the following options
33to the `yo hubot` command to do so:
34
35| Option | Description |
36|:--------------------------------------------|:-------------------------------------------------------|
37| `--owner="Bot Wrangler <bw@example.com>"` | Bot owner, e.g. "Bot Wrangler <bw@example.com>" |
38| `--name="Hubot"` | Bot name, e.g. "Hubot" |
39| `--description="Delightfully aware robutt"` | Bot description, e.g. "Delightfully aware robutt" |
40| `--adapter=campfire` | Bot adapter, e.g. "campfire" |
41| `--defaults` | Declare all defaults are set and no prompting required |
42
43You now have your own functional hubot! There's a `bin/hubot`
44command for convenience, to handle installing npm dependencies, loading scripts,
45and then launching your hubot.
46
47Note: Hubot can use Redis to persist data, so before you can start hubot on your own computer, if you want to persist data, then you should have Redis running on your machine accessible via `localhost`. Then, ensure that `hubot-redis-brain` is listed in `external-scripts.json` as an `Array` of module names (e.g. `['hubot-redis-brain']`) or an `object` where the key is the name of the module (e.g. `{'hubot-redis-brain': 'some arbitrary value'}`) where the value of the property in the object is passed to the module function as the second argument. The first argument being the hubot Robot instance.
48
49 % bin/hubot
50 Hubot>
51
52This starts hubot using the [shell adapter](./adapters/shell.md), which is mostly useful for development. Make note of the name in the `hubot>` prompt; this is the name your hubot will respond to with commands. If the prompt reads `myhubot>` then your commands must start with `myhubot <command>`.
53
54For example, to list available commands:
55
56 % bin/hubot
57 myhubot> myhubot help
58 myhubot> Shell: myhubot adapter - Reply with the adapter
59 myhubot animate me <query> - The same thing as `image me`, except adds a few parameters to try to return an animated GIF instead.
60 myhubot echo <text> - Reply back with <text>
61 myhubot help - Displays all of the help commands that Hubot knows about.
62 myhubot help <query> - Displays all help commands that match <query>.
63 myhubot image me <query> - The Original. Queries Google Images for <query> and returns a random top result.
64 myhubot map me <query> - Returns a map view of the area returned by `query`.
65 myhubot mustache me <url|query> - Adds a mustache to the specified URL or query result.
66 myhubot ping - Reply with pong
67 myhubot pug bomb N - get N pugs
68 myhubot pug me - Receive a pug
69 myhubot the rules - Make sure hubot still knows the rules.
70 myhubot time - Reply with current time
71 myhubot translate me <phrase> - Searches for a translation for the <phrase> and then prints that bad boy out.
72 myhubot translate me from <source> into <target> <phrase> - Translates <phrase> from <source> into <target>. Both <source> and <target> are optional
73 ship it - Display a motivation squirrel
74
75You almost definitely will want to change your hubot's name to add character. bin/hubot takes a `--name`:
76
77 % bin/hubot --name sam
78 sam>
79
80Your hubot will now respond as `sam`. This is
81case-insensitive, and can be prefixed with `@` or suffixed with `:`. These are equivalent:
82
83 SAM help
84 sam help
85 @sam help
86 sam: help
87
88## Scripts
89
90Hubot's power comes through scripts. There are hundreds of scripts written and maintained by the community. Find them by searching the [NPM registry](https://www.npmjs.com/browse/keyword/hubot-scripts) for `hubot-scripts <your-search-term>`. For example:
91
92```
93$ npm search hubot-scripts github
94NAME DESCRIPTION
95hubot-deployer Giving Hubot the ability to deploy GitHub repos to PaaS providers hubot hubot-scripts hubot-gith
96hubot-gh-release-pr A hubot script to create GitHub's PR for release
97hubot-github Giving Hubot the ability to be a vital member of your github organization
98
99```
100
101To use a script from an NPM package:
102
1031. Run `npm install --save <package-name>` to add the package as a dependency and install it.
1042. Add the package to `external-scripts.json`.
1053. Run `npm home <package-name>` to open a browser window for the homepage of the script, where you can find more information about configuring and installing the script.
106
107You can also put your own scripts under the `scripts/` directory. All scripts (files ending with either `.js` or `.mjs`) placed there are automatically loaded and ready to use with your hubot. Read more about customizing hubot by [writing your own scripts](scripting.md).
108
109## Adapters
110
111Hubot uses the adapter pattern to support multiple chat-backends. Here is a [list of available adapters](adapters.md), along with details on how to configure them.
112
113## Deploying
114
115You can deploy hubot to Heroku, which is the officially supported method. Additionally you are able to deploy hubot to a UNIX-like system or Windows. Please note the support for deploying to Windows isn't officially supported.
116
117* [Deploying Hubot onto Azure](./deploying/azure.md)
118* [Deploying Hubot onto Bluemix](./deploying/bluemix.md)
119* [Deploying Hubot onto Heroku](./deploying/heroku.md)
120* [Deploying Hubot onto Unix](./deploying/unix.md)
121* [Deploying Hubot onto Windows](./deploying/windows.md)
122
123## Patterns
124
125Using custom scripts, you can quickly customize Hubot to be the most life embettering robot he or she can be. Read [docs/patterns.md](patterns.md) for some nifty tricks that may come in handy as you teach your hubot new skills.
\No newline at end of file