Page MenuHomePhabricator

Create a blacklist of terms that chatbots should ignore
Closed, ResolvedPublic


We have a chatbot hooked into our slack, which everyone loves and adores, however, there are many, many, many common abbreviations which he should not be responding to with helpful phabricator links, examples include:

  • S3 (amazon s3)
  • Q1, Q2 (quarter 1, quarter 2)
  • B1, B2, B3, B4 (we abbreviate our current generation of spaceship names starting with a B)


It would be nice if there were a globally configured list of terms that the chatbot would ignore.

Event Timeline

We have config for this (remarkup.ignored-object-names) but the chatbot currently (by design) only uses the API, and there's no way to get this over the API.

Broadly, I expect to replace the chatbot architecture with something more first-party that isn't as bad (T7829).

Actually, from T9899 it looks like we already require it anyway, so whatever.

Phabricator ships with a chatbot, roughly documented in Chat Bot Technical Documentation.

This bot was originally written (circa 2011) as a sort of toy/demo API client, and faced a very low barrier to contributions for a long time. It ended up as a sloppy, poorly-engineered mess. T7829 discusses some of the many issues with it, especially with the feed handler. Despite being a steaming pile of garbage, it's still kind of useful, so it hasn't been nuked.

In the intervening years we wrote a chat application in the upstream (Conpherence). Conpherence is in a sort of iffy place right now and needs a solid UI iteration to get to approximate parity with other web chat applications in the space (Slack, etc), roughly described as "v4" in T10364. After that, I suspect the next "v5" iteration will focus on bot/API features. This is likely some ways away, but the vision is for chat bots and Conpherence to be more tightly integrated in the future, with web UI control of bots, letting bots join Conpherence rooms, etc. This would entail a total rewrite of the chatbot.

Until that happens, it's pretty much limping along, since it doesn't really create maintenance problems and is still somewhat useful. So this change is not a particularly grand one in the larger scheme of things, but it's a simple fix which should familiarize you with the review workflow and some of the CLI tooling.

To fix this problem (S3, etc., generating object mentions), we're just going to make PhabricatorBotObjectNameHandler respect remarkup.ignored-object-names. In theory, the bot "shouldn't" read directly from the database, but in practice the newer daemon infrastructure requires that anyway (per T9899), and no one actually runs the chatbot as a pure client, and it's still useful as a toy/demo even if it isn't a pure client, and the future of bots will move them closer to the core anyway.

So it's fine to just read this config directly (by calling PhabricatorEnv::getEnvConfig('remarkup.ignored-object-names')) and respect it.

Specifically, do this:

  • Configure the chatbot to connect to something, like an IRC channel, or whatever it normally connects to in your environment. Follow the documentation above or make @yelirekim hand over whatever config file you're using.
  • Make sure the PhabricatorBotObjectNameHandler handler is enabled.
  • Create a task (T1).
  • Type T1 in chat.
  • The bot should say <bot> T1: whatever your task name is and then link to the task.

Now, the problem is that if you say V1 (meaning "Version 1") and have a Slowvote with ID 1, the bot will say:

<bot> V1: What is the best flavor of pizza, chocolate or vanilla?

In PhabricatorBotObjectNameHandler.php, add some code to read remarkup.ignored-object-names, then use it to ignore object names in chat. This configuration option normally prevents V1, etc, from being linked in normal comments in the web UI, but has essentially the same role/meaning and is reasonable to extend to the chatbot.

Edit the config (using Config in the Phabricator web UI) to blacklist T1 or whatever, restart the bot (you'll probably need to restart the bot after any config change), and try saying T1 again. The bot should be quiet this time, but should still expand T2, T1000, R2D2, etc.

You can look at the use of the config option in PhabricatorObjectRemarkupRule.php as a syntax reference for how to actually do the check. It's OK to just copy the code rather than trying to share it, since all of the bot stuff will be thrown off a cliff eventually and is awful anyway.

Also, don't look at any of the bot code and just pretend it doesn't exist.