Creating bot on discourse

Is there a way to create a bot on Discourse that would reply to my commands, in a similar way that I have built many of my Discord bots?

Basically, I know that there are various plugins that I can install, but in my mind, it would be far easier for me to maintain if I could just have a bot that could listen to the text in a comment rather than trying to install plugins that are prone to mess up with things and especially if the maintainer decides that they don’t want to maintain the plugin anymore.

1 Like

You are going to need a plugin.

Take a look at my Frotz plugin as an example/starting point

API only plugins like this tend to be more stable over time so don’t worry about instability. All code requires maintenance in any case. I’ve done minimal changes to Frotz-bot over time.

Take a look at my Discord bot plugin to see how you can write code against events like new posts:

Your needs might be met by:

If you want more control over the code’s destiny, maintain a fork/repo yourself.

6 Likes

If you really want it to be entirely separate, you could use a combination of webhooks to deliver events to your bot and the HTTP requests API to have your bot make changes in Discourse.

Discourse API Docs

As @merefield alludes to though, it is possible to create plugins that do not override core functionality, instead being notified for events and interacting with core APIs, which are easier to maintain and less likely to have unwanted side effects.

Going the webhook/API route also requires setting up a stack to run your bot and ensuring that it is always available while Discourse is available, both of which come for free with a plugin loaded into Discourse.

Writing a plugin would require learning Ruby and gaining some familiarity with Discourse classes but if you’re already capable of writing and maintaining a bot in something else, I’m sure you could learn what’s needed pretty quickly.

3 Likes

Ah yes, that too, good point Simon!

Thank you everyone for your suggestions — I will definitely take look at all of them. :smiley:

this can be done in the post/comment,

is it possible to have a bot in a group chat ?
I see there is incoming webhook that could deliver message to a groupchat,
but seems there is no way having a bot account that listens to the chat messages, then do something accordingly… ?

Yes, for example:

supports Group chat (as well as Topics, PMs …)

(This is a purely AI bot without commands (the interface is 100% natural language so this is not required) but the structure would be the same)

1 Like

thanks @merefield

with a plugin, it could add an event hander/listener for group chat message.
I have a rest endpoint server that handles the webhook events, that works nicely for adding a bot to the post/comment.
but unfortunately, there is no events fired for group chat message, it does not fly that way… :frowning: