Discobot for training

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

2 Likes

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

1 Like

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

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.

6 Likes

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:

1 Like

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

3 Likes

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?

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.

1 Like

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

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.

2 Likes

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

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

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?

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

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?

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

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

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.

1 Like

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?

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

Heres some resources for you to get started-

2 Likes