# Discobot for training

**URL:** https://meta.discourse.org/t/discobot-for-training/81316
**Category:** Development
**Tags:** discobot
**Created:** [23 februari 2018 om 15:35 UTC](https://meta.discourse.org/t/discobot-for-training/81316 "2018-02-23T15:35:44Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Timothy\_Vail](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/timothy_vail/32/90872_2.png) [@Timothy\_Vail](https://meta.discourse.org/u/Timothy_Vail)
#### Post date: [23 februari 2018 om 15:35 UTC](https://meta.discourse.org/t/discobot-for-training/81316/1 "2018-02-23T15:35:45Z")

</div>

Hello,

I would like to customize the discobot to give training to employees, which is basically providing them with pre-set posts with info.

How can I run discobot as a trainer for whatever topic I’d like?

Thanks,  
Tim

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [24 februari 2018 om 00:59 UTC](https://meta.discourse.org/t/discobot-for-training/81316/2 "2018-02-24T00:59:37Z")

</div>

You can customize any discobot response, but it’s not possible to create a whole new narrative at this time.

---

<div class="post-metadata">

### Author: ![Timothy\_Vail](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/timothy_vail/32/90872_2.png) [@Timothy\_Vail](https://meta.discourse.org/u/Timothy_Vail)
#### Post date: [24 februari 2018 om 17:02 UTC](https://meta.discourse.org/t/discobot-for-training/81316/3 "2018-02-24T17:02:12Z")

</div>

> [@codinghorror](#):
>
> You can customize any discobot response, but it’s not possible to create a whole new narrative at this time.

Would it be possible to know how to make it possible 😉 ?

---

<div class="post-metadata">

### Author: ![featheredtoast](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/featheredtoast/32/116994_2.png) [@featheredtoast](https://meta.discourse.org/u/featheredtoast)
#### Post date: [24 februari 2018 om 17:31 UTC](https://meta.discourse.org/t/discobot-for-training/81316/4 "2018-02-24T17:31:30Z")

</div>

If you’re willing to run a Hubot chat bot, I wrote an adapter that can talk to Discourse that might fit your use case.

> [@Hubot Adapter for Discourse](https://meta.discourse.org/t/hubot-adapter-for-discourse/63419):
>
> I built a [Hubot](https://hubot.github.com/) adapter for Discourse. [https://github.com/featheredtoast/hubot-discourse-adapter](https://github.com/featheredtoast/hubot-discourse-adapter) This should work moderately well for communities that desire bot integrations. There are a few gotchas (see the readme) but for the most part it has been pretty incredible to tinker with so far. Something my community desired was a dice roller, which I knew existed as a hubot plugin. While there have been other attempts at [integrating dice rollers into discourse](https://meta.discourse.org/t/simple-dice-roller-plugin/9958/15), if I was going to run a bot agains…

You will still have to create your own Hubot plugins to hear and respond to messages however you like, but technically yes it is doable.

---

<div class="post-metadata">

### Author: ![Timothy\_Vail](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/timothy_vail/32/90872_2.png) [@Timothy\_Vail](https://meta.discourse.org/u/Timothy_Vail)
#### Post date: [24 februari 2018 om 18:31 UTC](https://meta.discourse.org/t/discobot-for-training/81316/5 "2018-02-24T18:31:43Z")

</div>

> [@awole20](#):
>
> You will still have to create your own Hubot plugins to hear and respond to messages however you like, but technically yes it is doable.

Wow that would be neat, I looked at some of the Hubot documentation, and it would be a good fit I think.

What do you mean by plugins? I hope you don’t mean I have to build a discourse plugin on top of programming the bot? 🤨

Thank you for the suggestion, I really appreciate it! 🕶

---

<div class="post-metadata">

### Author: ![featheredtoast](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/featheredtoast/32/116994_2.png) [@featheredtoast](https://meta.discourse.org/u/featheredtoast)
#### Post date: [24 februari 2018 om 18:35 UTC](https://meta.discourse.org/t/discobot-for-training/81316/6 "2018-02-24T18:35:07Z")

</div>

“Writing a Hubot Plugin” here means “Programming the Bot” - You shouldn’t need to do anything in Discourse aside from setting up the account and generating the API key for the bot.

---

<div class="post-metadata">

### Author: ![Timothy\_Vail](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/timothy_vail/32/90872_2.png) [@Timothy\_Vail](https://meta.discourse.org/u/Timothy_Vail)
#### Post date: [24 februari 2018 om 21:13 UTC](https://meta.discourse.org/t/discobot-for-training/81316/7 "2018-02-24T21:13:58Z")

</div>

So the way to do it is set it up on heroku and get an api key which you past into the discourse settings, correct?

---

<div class="post-metadata">

### Author: ![featheredtoast](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/featheredtoast/32/116994_2.png) [@featheredtoast](https://meta.discourse.org/u/featheredtoast)
#### Post date: [24 februari 2018 om 21:16 UTC](https://meta.discourse.org/t/discobot-for-training/81316/8 "2018-02-24T21:16:13Z")

</div>

You can host Hubot wherever - mine is running on the same server as Discourse.

You need to create a user in Discourse, and generate an API key for it to paste into the Hubot settings. This grants hubot permission to post under that Discouse account.

---

<div class="post-metadata">

### Author: ![Timothy\_Vail](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/timothy_vail/32/90872_2.png) [@Timothy\_Vail](https://meta.discourse.org/u/Timothy_Vail)
#### Post date: [24 februari 2018 om 21:32 UTC](https://meta.discourse.org/t/discobot-for-training/81316/9 "2018-02-24T21:32:34Z")

</div>

Exciting! 😃 Is there a public demo somewhere? Or sample hubot code?

---

<div class="post-metadata">

### Author: ![featheredtoast](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/featheredtoast/32/116994_2.png) [@featheredtoast](https://meta.discourse.org/u/featheredtoast)
#### Post date: [24 februari 2018 om 23:52 UTC](https://meta.discourse.org/t/discobot-for-training/81316/10 "2018-02-24T23:52:36Z")

</div>

It might be less confusing to just point you towards the Hubot docs for building/installing. You can follow it pretty closely, but use the Discourse adapter instead:

`yo hubot --adapter=discourse-adapter`

I don’t have a public demo, and I’ve dockerized and separated all of my scripts. [I’ve already linked them in the Hubot topic](https://meta.discourse.org/t/hubot-adapter-for-discourse/63419/6) if you’re still curious, but I’d urge you to stay on Hubot’s documentation.

---

<div class="post-metadata">

### Author: ![Timothy\_Vail](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/timothy_vail/32/90872_2.png) [@Timothy\_Vail](https://meta.discourse.org/u/Timothy_Vail)
#### Post date: [25 februari 2018 om 04:27 UTC](https://meta.discourse.org/t/discobot-for-training/81316/11 "2018-02-25T04:27:00Z")

</div>

Great, thank you awole20! So, can I use the discobot account to do a hubot?

---

<div class="post-metadata">

### Author: ![featheredtoast](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/featheredtoast/32/116994_2.png) [@featheredtoast](https://meta.discourse.org/u/featheredtoast)
#### Post date: [25 februari 2018 om 07:52 UTC](https://meta.discourse.org/t/discobot-for-training/81316/12 "2018-02-25T07:52:13Z")

</div>

Don’t see why not - all you need is a Discourse username and an associated API key. Give it a shot!

---

<div class="post-metadata">

### Author: ![Timothy\_Vail](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/timothy_vail/32/90872_2.png) [@Timothy\_Vail](https://meta.discourse.org/u/Timothy_Vail)
#### Post date: [26 februari 2018 om 19:45 UTC](https://meta.discourse.org/t/discobot-for-training/81316/15 "2018-02-26T19:45:19Z")

</div>

Hi @awole20, where do we enter the variables

- `HUBOT_DISCOURSE_USERNAME` the username the bot will connect as.
- `HUBOT_DISCOURSE_KEY` the API key for the user. This needs to be a user API key, not a site-wide API key.
- `HUBOT_DISCOURSE_SERVER` the discourse server eg `https://discourse.example.com/` ?

Is it in the actual bot after you enter `bin/hubot`?

---

<div class="post-metadata">

### Author: ![featheredtoast](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/featheredtoast/32/116994_2.png) [@featheredtoast](https://meta.discourse.org/u/featheredtoast)
#### Post date: [26 februari 2018 om 19:55 UTC](https://meta.discourse.org/t/discobot-for-training/81316/16 "2018-02-26T19:55:41Z")

</div>

Those are set from environment variables, which can be set in a number of ways. The simplest of which is editing your bin/hubot and adding:

```plaintext
export HUBOT_DISCOURSE_USERNAME=myuser
export HUBOT_DISCOURSE_KEY=secret
export HUBOT_DISCOURSE_SERVER=https://discourse.example.com/

```

before the `exec` line.

Bear in mind that the discourse key is a password, and so this file (or any env file) should be treated as secret and kept safe.

---

<div class="post-metadata">

### Author: ![Timothy\_Vail](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/timothy_vail/32/90872_2.png) [@Timothy\_Vail](https://meta.discourse.org/u/Timothy_Vail)
#### Post date: [26 februari 2018 om 20:38 UTC](https://meta.discourse.org/t/discobot-for-training/81316/17 "2018-02-26T20:38:21Z")

</div>

Certainly, now it is always running after I enter the bin/hubot cmd? I have it installed on the same server as Discourse?

I have that all in the file, and loaded it up with the API etc from the discobot. I even uncommented some of the scripts file to use, but when I replied @discobot open the pod bay doors, or “badgers” it just gave me the default discobot reply. Is it maybe overriding the messages of hubot?

---

<div class="post-metadata">

### Author: ![featheredtoast](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/featheredtoast/32/116994_2.png) [@featheredtoast](https://meta.discourse.org/u/featheredtoast)
#### Post date: [26 februari 2018 om 20:55 UTC](https://meta.discourse.org/t/discobot-for-training/81316/18 "2018-02-26T20:55:56Z")

</div>

Ah, yes that could definitely be a problem - Try creating a separate account for your learningbot that is separate from Discobot.

---

<div class="post-metadata">

### Author: ![Timothy\_Vail](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/timothy_vail/32/90872_2.png) [@Timothy\_Vail](https://meta.discourse.org/u/Timothy_Vail)
#### Post date: [27 februari 2018 om 03:32 UTC](https://meta.discourse.org/t/discobot-for-training/81316/19 "2018-02-27T03:32:27Z")

</div>

> [@awole20](#):
>
> yo hubot --adapter=discourse-adapter

Okay, I made a separate user, and loaded the api into the hubot in bin/hubot -a discourse-adapter and now it works.

Now how do I keep it on when I’m not in the SSH terminal? I’m on a Ubuntu server, on AWS EC2.

Thank you!

I actually get this error when I bin/hubot

npm WARN hubot-help@0.2.2 requires a peer of coffee-script@^1.12.6 but none is installed. You must install peer dependencies yourself.

up to date in 1.25s

---

<div class="post-metadata">

### Author: ![featheredtoast](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/featheredtoast/32/116994_2.png) [@featheredtoast](https://meta.discourse.org/u/featheredtoast)
#### Post date: [27 februari 2018 om 04:33 UTC](https://meta.discourse.org/t/discobot-for-training/81316/20 "2018-02-27T04:33:57Z")

</div>

I think that warning is fine; not sure you need to worry about that specifically.

You’re starting to wade deep in linux tooling land, and you might have to do some reading up on init scripts if you want your scripts more robust to be able to start on boot/restart.

`nohup bin/hubot -a discourse-adapter &` should work in a pinch though.

---

<div class="post-metadata">

### Author: ![Timothy\_Vail](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/timothy_vail/32/90872_2.png) [@Timothy\_Vail](https://meta.discourse.org/u/Timothy_Vail)
#### Post date: [27 februari 2018 om 04:36 UTC](https://meta.discourse.org/t/discobot-for-training/81316/21 "2018-02-27T04:36:35Z")

</div>

> [@awole20](#):
>
> nohup bin/hubot -a discourse-adapter & should work in a pinch though.

I entered that into the console, what will that do? I think it now works even though I’m not in the console any longer 🙂 thank you!

How do I restart it with new scripts loaded in? Do I have to stop it first?

---

<div class="post-metadata">

### Author: ![featheredtoast](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/featheredtoast/32/116994_2.png) [@featheredtoast](https://meta.discourse.org/u/featheredtoast)
#### Post date: [27 februari 2018 om 04:58 UTC](https://meta.discourse.org/t/discobot-for-training/81316/22 "2018-02-27T04:58:28Z")

</div>

For killing the job, `pkill hubot` is quick and dirty.

Heres some resources for you to get started-

> **[nohup](https://en.wikipedia.org/wiki/Nohup)**
>
> nohup is a POSIX command which means "no hang up". Its purpose is to execute a command such that it ignores the HUP (hangup) signal and therefore does not stop when the user logs out.
> Output that would normally go to the terminal goes to a file called .mw-parser-output .monospaced{font-family:monospace,monospace}nohup.out, if it has not already been redirected.
> The first of the commands below starts the program abcd in the background in such a way that the subsequent logout does not stop it.
> N...

> <https://askubuntu.com/questions/57477/bring-nohup-job-to-foreground>

[Next page](https://meta.discourse.org/t/discobot-for-training/81316.md?page=2)
