# Topic auto tagging

**URL:** https://meta.discourse.org/t/topic-auto-tagging/54894
**Category:** Feature
**Created:** [December 28, 2016, 6:10pm UTC](https://meta.discourse.org/t/topic-auto-tagging/54894 "2016-12-28T18:10:19Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Janno\_Liivak](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/janno_liivak/32/352215_2.png) [@Janno\_Liivak](https://meta.discourse.org/u/Janno_Liivak)
#### Post date: [December 28, 2016, 6:10pm UTC](https://meta.discourse.org/t/topic-auto-tagging/54894/1 "2016-12-28T18:10:19Z")

</div>

I need one certain category’s (and it’s sub-category’s) to have auto-tagging feature. For example… I set up Tags, which can be used for topics in category (for example: iphone, macbookpro). If topic title has text “iPhone” and “MacBook Pro” in it, the tags “iphone” and “macbookpro” would be automatically selected for this topic.

What is the best strategy to get such feature implemented?

Should I go with a plugin? Is it possible to do with a plugin?

Or should I add feature to topic (and add “Topic auto-tagging” to it’s settings) and create a pull request to have it in main branch?

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [December 28, 2016, 6:17pm UTC](https://meta.discourse.org/t/topic-auto-tagging/54894/2 "2016-12-28T18:17:43Z")

</div>

Create a plugin based on [Sam’s Unhandled Tagger](https://github.com/discourse/discourse-unhandled-tagger/blob/master/plugin.rb).

Alter `plugin.rb` to scan for title and apply existing tags instead of always applying unhlandled.

---

<div class="post-metadata">

### Author: ![claas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/claas/32/71725_2.png) [@claas](https://meta.discourse.org/u/claas)
#### Post date: [December 28, 2016, 6:51pm UTC](https://meta.discourse.org/t/topic-auto-tagging/54894/3 "2016-12-28T18:51:40Z")

</div>

> [@Janno\_Liivak](#):
>
> Or should I add feature to topic (and add “Topic auto-tagging” to it’s settings)

Instead of automatically tagging topics, I would like the idea of _suggesting_ tags just as similar topics are suggested, but I imagine this isn’t that cheap to have (because we would need to maintain some sort of model/corpus per tag).

---

<div class="post-metadata">

### Author: ![Janno\_Liivak](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/janno_liivak/32/352215_2.png) [@Janno\_Liivak](https://meta.discourse.org/u/Janno_Liivak)
#### Post date: [December 28, 2016, 8:42pm UTC](https://meta.discourse.org/t/topic-auto-tagging/54894/4 "2016-12-28T20:42:15Z")

</div>

What if tags would populate as you type and before posting you could add/remove tags? Would that be OK?

---

<div class="post-metadata">

### Author: ![scombs](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/scombs/32/48616_2.png) [@scombs](https://meta.discourse.org/u/scombs)
#### Post date: [January 21, 2017, 8:21pm UTC](https://meta.discourse.org/t/topic-auto-tagging/54894/5 "2017-01-21T20:21:37Z")

</div>

Would like to see option on the Category\>Edit\>Tags screen for:

> Default tags for this category

below the current options:

 ![](https://global.discourse-cdn.com/meta/original/3X/8/c/8ce4f9ca0f63720f1047ffb93cc3fbd0c7e6433b.png)

This would also help for topics posted via mobile since adding tags is not supported.

My use case is adding an “events” tag so that topics from different event subcategories across the site can get aggregated to one calendar.

---

<div class="post-metadata">

### Author: ![ChrisBeach](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chrisbeach/32/214628_2.png) [@ChrisBeach](https://meta.discourse.org/u/ChrisBeach)
#### Post date: [January 21, 2017, 9:24pm UTC](https://meta.discourse.org/t/topic-auto-tagging/54894/6 "2017-01-21T21:24:21Z")

</div>

> [@claas](#):
>
> Instead of automatically tagging topics, I would like the idea of suggesting tags just as similar topics are suggested, but I imagine this isn’t that cheap to have (because we would need to maintain some sort of model/corpus per tag).

A bayesian algorithm would work well here.

To seed it, feed in all the current tagged posts, and let it learn which words in the content of a post correspond (probabilistically) to which tags.

---

<div class="post-metadata">

### Author: ![Muiran](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/muiran/32/73797_2.png) [@Muiran](https://meta.discourse.org/u/Muiran)
#### Post date: [July 28, 2017, 11:39am UTC](https://meta.discourse.org/t/topic-auto-tagging/54894/8 "2017-07-28T11:39:58Z")

</div>

Merged in from a duplicate topic.

> **[Automatic Post Tagger](https://wordpress.org/plugins/automatic-post-tagger/)**
>
> Adds relevant taxonomy terms to posts using a keyword list provided by the user.

Great WP plugin and seems it would be a great Discourse plugin as well if built to the same logic as this one.

Comments?

---

<div class="post-metadata">

### Author: ![HAWK](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hawk/32/86627_2.png) [@HAWK](https://meta.discourse.org/u/HAWK)
#### Post date: [July 21, 2017, 2:17am UTC](https://meta.discourse.org/t/topic-auto-tagging/54894/9 "2017-07-21T02:17:50Z")

</div>

> [@Plugin Concept: Automated Post Tagger](https://meta.discourse.org/t/plugin-concept-automated-post-tagger/66543/1):
>
> Automatic Post Tagger

Yuss! I was hoping for something like this recently when I built a ‘homepage’ that relies on tagging to group content.

---

<div class="post-metadata">

### Author: ![krauss](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/krauss/32/221613_2.png) [@krauss](https://meta.discourse.org/u/krauss)
#### Post date: [July 28, 2017, 11:43am UTC](https://meta.discourse.org/t/topic-auto-tagging/54894/10 "2017-07-28T11:43:49Z")

</div>

See [how Wikibots are working at Wikipedia](https://en.wikipedia.org/wiki/Wikipedia:Bots), it is a good **reference model** … Other important criteria to policy and implementation:

- to be an **assisted agent** : never (or very rare) an automatic classification with no human confirming it. Must work “by (assisted) lot” not in a continous (by demand) way.

- to be **specialized** : never generic, need a scope and limited (configurable/controlable) range.

- to be **symmetric** over validation: an human can be also use the same tag, the robot ([software agent](https://en.wikipedia.org/wiki/Software_agent)) is not the only autorithy to tagging its scope. So two cenarios: 1. robot tagging and human validating/confirming (or warning to vote). 2. human tagging, and robot valiating (or warning to other human confirm).

Whith this basic polices the robot is viable in any community!

Other suggestion: when the scope is specific, or when the “easy to tag” generates “tag pollution”, the best is to use _different color to the tags of the bot-scope_. EXAMPLE: tagging _languages_ in a multilingual community as [https://discuss.okfn.org](https://discuss.okfn.org).

---

<div class="post-metadata">

### Author: ![tophee](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tophee/32/73406_2.png) [@tophee](https://meta.discourse.org/u/tophee)
#### Post date: [July 1, 2018, 7:57pm UTC](https://meta.discourse.org/t/topic-auto-tagging/54894/11 "2018-07-01T19:57:05Z")

</div>

Now that we have watched words that trigger certain actions, wouldn’t it be easy to simply add “tag” as a possible action to perform upon a matched word/regex?

---

<div class="post-metadata">

### Author: ![neil](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neil/32/102150_2.png) [@neil](https://meta.discourse.org/u/neil)
#### Post date: [July 3, 2018, 7:52pm UTC](https://meta.discourse.org/t/topic-auto-tagging/54894/14 "2018-07-03T19:52:29Z")

</div>

It’s a feature that is closer to being implemented now, yes. “Simply adding tag” isn’t quite the whole story. Each watched word needs to also specify which tag to add, for example.

---

<div class="post-metadata">

### Author: ![tophee](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tophee/32/73406_2.png) [@tophee](https://meta.discourse.org/u/tophee)
#### Post date: [July 3, 2018, 8:04pm UTC](https://meta.discourse.org/t/topic-auto-tagging/54894/15 "2018-07-03T20:04:37Z")

</div>

That would be absolutely awesome! Especially if it’s not just words but also regular expressions. Auto-tagging based on regular expressions would bring tags in discourse to a whole new level!

> [@neil](#):
>
> Each watched word needs to also specify which tag to add, for example.

Yes, and I also realize that the existing actions apply to posts while tags can only be applied to topics. So the question is: will tagging actions only be based on the first post? Or can any reply also trigger the tag? Or will it be a setting, whether it applies to both?..

---

<div class="post-metadata">

### Author: ![sinister89](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sinister89/32/99847_2.png) [@sinister89](https://meta.discourse.org/u/sinister89)
#### Post date: [August 7, 2018, 7:43pm UTC](https://meta.discourse.org/t/topic-auto-tagging/54894/16 "2018-08-07T19:43:22Z")

</div>

Did anyone endup building this as a plugin?

---

<div class="post-metadata">

### Author: ![HAWK](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hawk/32/86627_2.png) [@HAWK](https://meta.discourse.org/u/HAWK)
#### Post date: [August 8, 2018, 4:33am UTC](https://meta.discourse.org/t/topic-auto-tagging/54894/17 "2018-08-08T04:33:20Z")

</div>

@vinothkannans is currently working on something along these lines for PMs. I’m not sure how much extra work there would be to make it fit this brief – can you comment Vinoth?

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [August 8, 2018, 5:38am UTC](https://meta.discourse.org/t/topic-auto-tagging/54894/18 "2018-08-08T05:38:28Z")

</div>

You can create a plugin with the below simple code. But the difficulty level is fully depends upon your auto tagging logic/requirement.

```plaintext
DiscourseEvent.on(:topic_created) do |topic|
  guardian = Guardian.new(Discourse.system_user)
  DiscourseTagging.tag_topic_by_names(topic, guardian, ["bug"], append: true) if topic.title.match(/bug/)
end

```

---

<div class="post-metadata">

### Author: ![Andy02](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/andy02/32/119498_2.png) [@Andy02](https://meta.discourse.org/u/Andy02)
#### Post date: [October 27, 2019, 7:25pm UTC](https://meta.discourse.org/t/topic-auto-tagging/54894/19 "2019-10-27T19:25:52Z")

</div>

@syl solved this with definable auto-tagging in his Docus plugin. I suspect someone could pull that function out to create auto-tagging if he didn’t mind.

from my perspective the most obvious solution would be for a post to be auto-tagged with the tag(s) that the user is currently on (tag-page, or post). This makes it obvious visually to the user how the feature works if they need to change it, and in most cases it will probably be correct as they will be replying to something with the tags they are replying to.

---

<div class="post-metadata">

### Author: ![Mark\_Schmucker](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mark_schmucker/32/124810_2.png) [@Mark\_Schmucker](https://meta.discourse.org/u/Mark_Schmucker)
#### Post date: [June 17, 2020, 12:54am UTC](https://meta.discourse.org/t/topic-auto-tagging/54894/20 "2020-06-17T00:54:42Z")

</div>

Correct me if I’m wrong, but it looks like @pfaffman implemented this plugin at [GitHub - pfaffman/discourse-topic-default-tag: Allow topics to include default tags · GitHub](https://github.com/pfaffman/discourse-topic-default-tag)?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [June 17, 2020, 2:48am UTC](https://meta.discourse.org/t/topic-auto-tagging/54894/21 "2020-06-17T02:48:21Z")

</div>

I did. It just assigns a tag to every topic created in a category, but it’s a good start on something that could apply tags depending on topic content, I suppose.

---

<div class="post-metadata">

### Author: ![markersocial](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/markersocial/32/170136_2.png) [@markersocial](https://meta.discourse.org/u/markersocial)
#### Post date: [June 25, 2020, 6:07am UTC](https://meta.discourse.org/t/topic-auto-tagging/54894/22 "2020-06-25T06:07:23Z")

</div>

+1 this would be a really useful feature or plugin, auto tagging based on watched words (each with an assigned tag) that exist in the topic (title/body).

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [June 25, 2020, 1:58pm UTC](https://meta.discourse.org/t/topic-auto-tagging/54894/23 "2020-06-25T13:58:29Z")

</div>

That’s certainly possible in a plugin. You could use my plugin above as a starting place or ask in #Marketplace

[Next page](https://meta.discourse.org/t/topic-auto-tagging/54894.md?page=2)
