Discobot for training

(Timothy Vail) #1


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?


(Jeff Atwood) #2

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

(Timothy Vail) #3

Would it be possible to know how to make it possible :wink: ?

(Jeff Wong) #4

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.

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.

(Timothy Vail) #5

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? :face_with_raised_eyebrow:

Thank you for the suggestion, I really appreciate it! :sunglasses:

(Jeff Wong) #6

“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.

(Timothy Vail) #7

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?

(Jeff Wong) #8

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.

(Timothy Vail) #9

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

(Jeff Wong) #10

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 if you’re still curious, but I’d urge you to stay on Hubot’s documentation.

Setting up a smart chatbot on discourse :robot:
(Timothy Vail) #11

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

(Jeff Wong) #12

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

(Timothy Vail) #15

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?

(Jeff Wong) #16

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:

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.

(Timothy Vail) #17

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?

(Jeff Wong) #18

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

(Timothy Vail) #19

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

(Jeff Wong) #20

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.

(Timothy Vail) #21

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 :slight_smile: thank you!

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

(Jeff Wong) #22

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

Heres some resources for you to get started-