Skip to content

Commit

Permalink
Add bBot page to bot docs (RocketChat#916)
Browse files Browse the repository at this point in the history
* Add bBot page to bot docs

+ Fixed minor style issue where list had no spacing between following paragraph

* Fix link with missing protocol

* Update bots FAQ list of adapters
  • Loading branch information
timkinnane authored and MartinSchoeler committed Sep 18, 2018
1 parent b835760 commit 06f214e
Show file tree
Hide file tree
Showing 6 changed files with 201 additions and 8 deletions.
1 change: 1 addition & 0 deletions _data/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@
- Bots Architecture
- Creating Bot Users
- Configure Bot Environment
- Running a bBot Bot
- Running a Hubot Bot
- Running a Botkit Bot
- Running a Rasa Bot
Expand Down
5 changes: 4 additions & 1 deletion _sass/layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ body {
color: #1e70bf;
text-decoration: none;
}


ul {
margin-bottom: 12px;
}
ol {
list-style: decimal;
margin-left: 2em;
Expand Down
5 changes: 4 additions & 1 deletion bots/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ interactions.

We are building out support for multiple frameworks, including:

- [bBot](http://bbot.chat/) - complete
- [Hubot](https://hubot.github.com/) - complete
- [Botkit](https://botkit.ai/) - in development
- [Rasa](https://rasa.com/) - in development
Expand All @@ -29,14 +30,15 @@ These are the basic steps for using bots with Rocket.Chat.
2. The bot is run as [a separate process](bots-architecture/) using your chosen framework or platform
3. The bot environment must be pre-configured by [setting environment variables](configure-bot-environment/)
4. You provide scripts to define the bot's behaviour according to the requirements of your framework
- e.g. See [Running a Hubot bot](running-a-hubot-bot/)
- e.g. See [Running a bBot bot](running-a-bbot-bot/)

## Quick Links

- [Bots FAQ](bots-faq/)
- [Bots Architecture](bots-architecture/)
- [Creating Bot Users](creating-bot-users/)
- [Configuring the Bot Environment](configure-bot-environment/)
- [Running a bBot Bot](running-a-bbot-bot/)
- [Running a Hubot Bot](running-a-hubot-bot/)
- [Running a Botkit Bot](running-a-botkit-bot/)
- [Running a Rasa Bot](running-a-rasa-bot/)
Expand All @@ -48,5 +50,6 @@ Configuration and implementation details for components of the
[Bots Architecture](bots-architecture/) can be found in their project READMEs:

- [Rocket.Chat JS SDK](https://github.com/RocketChat/Rocket.Chat.js.SDK/)
- [bBot Rocket.Chat boilerplate](https://github.com/Amazebot/bbot-rocketchat-boilerplate)
- [Hubot Rocket.Chat boilerplate](https://github.com/RocketChat/hubot-rocketchat-boilerplate/)
- [Hubot Rocket.Chat adapter](https://github.com/RocketChat/hubot-rocketchat/tree/develop/)
13 changes: 7 additions & 6 deletions bots/bots-faq/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ obvious to other users and it can have specific permissions.
## What kinds of bots work with Rocket.Chat?

We are building out support for multiple bot frameworks and platforms, starting
with other open source projects. We currently have an adapter for Hubot, but are
working on supporting Botkit, Rasa and Botpress. We refer to these as
**external** bots, because their hosting and logic is separate to your
Rocket.Chat instance and defined by their provider. External bots are suited to
messaging-heavy interactions and/or where maintenance or processes are
independent of Rocket.Chat.
with other open source projects. We currently have adapters for bBot, Hubot,
Botkit and Botpress.

We refer to these as **external** bots, because their hosting and logic is
separate to your Rocket.Chat instance and defined by their provider. External
bots are suited to messaging-heavy interactions and/or where maintenance or
processes are independent of Rocket.Chat.

We are also working on a model for **internal** bots, that run as an app
attached to the instance and are tightly coupled with the architecture of
Expand Down
184 changes: 184 additions & 0 deletions bots/running-a-bbot-bot/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
[bbot]: http://bbot.chat
[bbot-gh]: https://github.com/Amazebot/bbot
[brocket]: https://github.com/Amazebot/bbot-rocketchat-boilerplate
[heroku-cli]: https://devcenter.heroku.com/articles/heroku-cli
[brocket-glitch]: https://glitch.com/edit/#!/remix/bbot-rocketchat-boilerplate

# Running a bBot Bot

[bBot][bbot] is a Rocket.Chat sponsored open source project created by our
frequent contributor, Tim Kinnane. Tim also created the Rocket.Chat JS SDK used
by all bot frameworks, so it's a fairly frictionless experience connecting
Rocket.Chat and bBot.

Developers should start with (or at least reference) our
[bBot Boilerplate][brocket] (aka **bRocket**), demonstrating general usage of
bBot with some features unique to Rocket.Chat such as rich message payloads.

As with all bot frameworks, you need to
[configure the environment](../configure-bot-environment)
for the Rocket.Chat SDK settings (implemented by bBot's bundled Rocket.Chat
adapter).

## Building Bot Behaviour

See bBot's own guides on [running the bot](http://bbot.chat/docs/core) and
[creating branches](http://bbot.chat/docs/path). Or watch this
[video guide](https://www.youtube.com/watch?v=vhRVFBiwJEA).

The [boilerplate instructions][brocket] also detail how to start the bot in
the terminal (`-m shell`), to test interactions before deployment.

## Deploying Your Bot

Bots run as their own external service, connecting to your Rocket.Chat instance.

There's a few options for bot deployment. Probably the most common is Docker,
as a container it can be deployed to most cloud hosting but we've included
instructions for Heroku below.

Glitch and Now are also detailed below, which are good options for rapid
prototyping with a free cloud hosting environment but aren't suitable for a bot
that will serve heavy traffic on an ongoing basis.

## Deploy Docker Container

The included `Dockerfile` is all that's required for configuring the build.

If your environment requires first building the Docker image (e.g. local test),
you can do that as follows, though many cloud environments will detect the
Docker setup and do this automatically. Many services will allow for defining
environment variables in their own dash UI too, so the `-e` lines below might
not be required either.

> NOTE: The Docker build copies `./index.js` and `./src` to the built image. No
> other scripts are included, so keep all your bot customisation within `src`.
Build a docker image:

```
docker build -t bbot:rocketchat .
```

Run the docker image, passing environment configs:

```
docker run -it --rm --name brocket \
-e ROCKETCHAT_URL=<YOUR_URL> \
-e ROCKETCHAT_USER=<BOT_USER> \
-e ROCKETCHAT_PASSWORD=<BOT_PASS> \
-e ROCKETCHAT_ROOM='' \
-e LISTEN_ON_ALL_PUBLIC=true \
-e RESPOND_TO_EDITED=true \
-e RESPOND_TO_DM=true \
-e RESPOND_TO_LIVECHAT=true \
bbot:rocketchat
```

## Deploy to Heroku

Heroku can detect the Node app type and automatically run the main script.

You should install the [Heroku CLI][heroku-cli] and login. Either create your
Heroku app following the linked instructions or add an existing app to your
bot's git as a remote host, per instructions below.

It just needs the environment configuration:

```
heroku config:set ROCKETCHAT_URL=<YOUR_URL>
heroku config:set ROCKETCHAT_USER=<BOT_USER>
heroku config:set ROCKETCHAT_PASSWORD=<BOT_PASS>
heroku config:set ROCKETCHAT_ROOM=''
heroku config:set LISTEN_ON_ALL_PUBLIC=true
heroku config:set RESPOND_TO_DM=true
heroku config:set RESPOND_TO_EDITED=true
heroku config:set RESPOND_TO_LIVECHAT=true
```

Then add your Heroku app as a git remote and push to release:

```
heroku git:remote -a <YOUR_APP>
git push heroku master
```

## Deploy Docker to Heroku

Log in to Container Registry

```
heroku container:login
```

Build the image and push to Container Registry:

```
heroku container:push web
```

Then release the image to your app:

```
heroku container:release web
```

Now open the app in your browser:

```
heroku open
```

## Deploy to Glitch

Remix the [Glitch boilerplate][brocket-glitch].

Edit **.env** as per example:

```
ROCKETCHAT_URL=<YOUR_URL>
ROCKETCHAT_USER=<BOT_USER>
ROCKETCHAT_PASSWORD=<BOT_PASS>
RESPOND_TO_DM=true
RESPOND_TO_EDITED=true
LISTEN_ON_ALL_PUBLIC=false
```

That's it, the app will restart and attempt connection when you change the
settings, just view the logs to resolve any connection issues.

Glitch apps will usually sleep after 5 minutes, but
[there are ways](https://support.glitch.com/t/not-letting-the-app-go-down/2000/13)
to get round that for periods of time.

## Deploy to Now

[Now from Zeit.co](https://zeit.co/now) provide free global serverless
deployments, with up to 1GB of bandwidth and storage.

First create an account, then install the Now CLI.

Deploy your app, passing environment configs:

```
now -e ROCKETCHAT_URL=<YOUR_URL> \
-e ROCKETCHAT_USER=<BOT_USER> \
-e ROCKETCHAT_PASSWORD=<BOT_PASS> \
-e ROCKETCHAT_ROOM='' \
-e LISTEN_ON_ALL_PUBLIC=true \
-e RESPOND_TO_EDITED=true \
-e RESPOND_TO_DM=true \
-e RESPOND_TO_LIVECHAT=true
```

Choose `package.json` or `Dockerfile` as the build source.

Follow the link (in clipboard) to your newly created app to view logs.

## Contribute to the Docs

If you've developed deployment methods other common cloud platforms, please
submit a PR with the instructions using the link below.

It would be especially helpful to know of community solutions for deploying
parallel services within the bot container, like a Mongo DB or Rasa NLU.
1 change: 1 addition & 0 deletions contributing/documentation/documentation-map/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ Here you can also find what articles are incomplete and missing.
- Bots Architecture
- Creating Bot Users
- Configure Bot Environment
- Running a bBot Bot
- Running a Hubot Bot
- Running a Botkit Bot
- Running a Rasa Bot
Expand Down

0 comments on commit 06f214e

Please sign in to comment.