# Hubot Adapter for Discourse

**URL:** https://meta.discourse.org/t/hubot-adapter-for-discourse/63419
**Category:** Extras
**Created:** [May 26, 2017, 5:03am UTC](https://meta.discourse.org/t/hubot-adapter-for-discourse/63419 "2017-05-26T05:03:55Z")
**Posts on this page:** 1
**Showing post:** 6

<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: [October 12, 2017, 7:38pm UTC](https://meta.discourse.org/t/hubot-adapter-for-discourse/63419/6 "2017-10-12T19:38:50Z")

</div>

> [@Sujan](#):
>
> Can you show how you for example would configure it to do the dice rolling thing you mentioned above?

Hubot can be configured with both pre-written plug-in scrips, as well as ad-hoc scripts. You can get started with hubot pretty quickly over commandline for local barebones testing of responses. This adapter is only here to allow it to “speak” and respond over discourse.

I ended up splitting up [my bot](https://github.com/featheredtoast/wotcher-docker) from [my custom configuration](https://github.com/featheredtoast/wotcher), so that I could run tests against my custom scripts.

The dice roller can be seen [here](https://github.com/featheredtoast/wotcher/blob/master/src/dice-roller.coffee) and I have an additional (and much simpler) [“if you here anything about ‘the deals’ respond in kind” script](https://github.com/featheredtoast/wotcher/blob/master/src/wotcher.coffee) for fun.

> [@Sujan](#):
>
> Is the adapter also able to receive/read all new topics being created? (or would I have to modify it to do this?)

You can set it up that way - The adapter responds via discourse’s native notifications. Basically, if there’s a discourse notification of a message, the bot will see it. In the bot’s Discourse profile, you can edit and add to the watched categories to allow it to automatically see new topics/replies/etc without a direct @.

EG: for your use case, you would probably want to add your interested categories to “watching first post” and set the “when I post in a topic set that topic to” normal. That way, the bot gets notified on new topics, but does not continue to monitor/reply afterwards.

> [@Sujan](#):
>
> Is there a diagram/flowchart/list online somewhere which methods of your adapter are called in which order when?

Not currently - It follows the same patterns from other hubot adapters - aside from setting up what hubot “hears” in discourse, you really shouldn’t have to mind much about the internals. Mostly you’d be interested in the API, and the difference between function hooks like `robot.hear` vs `robot.respond`. [See the docs for examples!](https://hubot.github.com/docs/scripting/)

---

_[View the full topic](https://meta.discourse.org/t/hubot-adapter-for-discourse/63419)._
