# Is there any support for user-made bots?

**URL:** https://meta.discourse.org/t/is-there-any-support-for-user-made-bots/76224
**Category:** Development
**Created:** [12월 16, 2017, 7:26오후 UTC](https://meta.discourse.org/t/is-there-any-support-for-user-made-bots/76224 "2017-12-16T19:26:49Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![orangeandblack5](https://avatars.discourse-cdn.com/v4/letter/o/edb3f5/32.png) [@orangeandblack5](https://meta.discourse.org/u/orangeandblack5)
#### Post date: [12월 16, 2017, 7:26오후 UTC](https://meta.discourse.org/t/is-there-any-support-for-user-made-bots/76224/1 "2017-12-16T19:26:49Z")

</div>

I did some searching but was only able to find a Hubot adapter - is there any way to create a bot that could be used to accomplish relatively complex tasks such as running a forum game? I’ve seen some forums running on other platforms use bots to great effect in this manner, and was wondering if it is possible to set up a similar system on Discourse.

If this needs to be moved, please feel free to do so, but this seemed to be the most appropriate place to ask.

---

<div class="post-metadata">

### Author: ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)
#### Post date: [12월 17, 2017, 9:49오전 UTC](https://meta.discourse.org/t/is-there-any-support-for-user-made-bots/76224/2 "2017-12-17T09:49:27Z")

</div>

Sure, Discourse has a comprehensive API which should be sufficient for running a bot on the site.

---

<div class="post-metadata">

### Author: ![notriddle](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/notriddle/32/133055_2.png) [@notriddle](https://meta.discourse.org/u/notriddle)
#### Post date: [12월 17, 2017, 2:03오후 UTC](https://meta.discourse.org/t/is-there-any-support-for-user-made-bots/76224/3 "2017-12-17T14:03:04Z")

</div>

API tokens can only be handed out by administrators (or manually sussed out of browser cookies, but you’re not supposed to do that). If somebody wants to add a bot, they’re supposed to ask a staff member, who will give them the token.

---

<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: [12월 17, 2017, 10:17오후 UTC](https://meta.discourse.org/t/is-there-any-support-for-user-made-bots/76224/4 "2017-12-17T22:17:54Z")

</div>

Er what? Users can have their own API keys.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [12월 17, 2017, 10:34오후 UTC](https://meta.discourse.org/t/is-there-any-support-for-user-made-bots/76224/5 "2017-12-17T22:34:48Z")

</div>

> [@codinghorror](#):
>
> Users can have their own API keys.

User API is doable but it requires a rather complex protocol. Simplest thing is to have admins issue admin api keys that are tied to a specific user (bot user in this case)

---

<div class="post-metadata">

### Author: ![notriddle](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/notriddle/32/133055_2.png) [@notriddle](https://meta.discourse.org/u/notriddle)
#### Post date: [12월 17, 2017, 10:47오후 UTC](https://meta.discourse.org/t/is-there-any-support-for-user-made-bots/76224/6 "2017-12-17T22:47:20Z")

</div>

> [@codinghorror](#):
>
> Er what? Users can have their own API keys.

API keys can be linked to users, but they’re created in the Admin page. I (being a non-admin) can’t just click a button and get an API key for Meta like I can on (for example) GitHub.

---

<div class="post-metadata">

### Author: ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)
#### Post date: [12월 17, 2017, 10:53오후 UTC](https://meta.discourse.org/t/is-there-any-support-for-user-made-bots/76224/7 "2017-12-17T22:53:03Z")

</div>

> [@notriddle](#):
>
> If somebody wants to add a bot, they’re supposed to ask a staff member, who will give them the token.

If you’re running a forum game on a site without the knowledge and approval of site staff, you’re probably going to have a bad time.

---

<div class="post-metadata">

### Author: ![orangeandblack5](https://avatars.discourse-cdn.com/v4/letter/o/edb3f5/32.png) [@orangeandblack5](https://meta.discourse.org/u/orangeandblack5)
#### Post date: [12월 18, 2017, 3:35오전 UTC](https://meta.discourse.org/t/is-there-any-support-for-user-made-bots/76224/8 "2017-12-18T03:35:23Z")

</div>

Cool. As I’ve done some bots before but never on Discourse, any specific tips I could use to help the transition?

Thanks!

---

<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: [12월 18, 2017, 6:32오전 UTC](https://meta.discourse.org/t/is-there-any-support-for-user-made-bots/76224/9 "2017-12-18T06:32:41Z")

</div>

What kind of bots are you building out of curiosity?

If you’re not building on top of Hubot, I’d recommend taking the same approach as I did with the Hubot adapter, and listen with the message bus for notifications.

You can get a pretty good idea of how to use the [Discourse API](http://docs.discourse.org/) for getting messages, and responding by looking at the adapter source, too.

---

<div class="post-metadata">

### Author: ![orangeandblack5](https://avatars.discourse-cdn.com/v4/letter/o/edb3f5/32.png) [@orangeandblack5](https://meta.discourse.org/u/orangeandblack5)
#### Post date: [12월 18, 2017, 11:49오전 UTC](https://meta.discourse.org/t/is-there-any-support-for-user-made-bots/76224/10 "2017-12-18T11:49:37Z")

</div>

Thanks for the recommendation!

The basic idea is to build a bot to automatically run a small game of Mafia. Ideally, it would have several functions, such as counting votes, carrying out player actions, and automatically progressing through the game’s day and night cycles without requiring somebody to do so manually.

I won’t have time to work on this for a few months because school, so I’m just gathering information at this point. Should streamline the process later.
