Skip to main content

Entities

Entities let a plugin recognize tokens in message text (CVEs, ticket IDs, coordinates, and similar) and show a card when a reader opens a mention. Core owns parse-on-read; your plugin registers types and matchers, optionally returns cards, and can give a type a static leading mention badge.

Feature flag: Entities (and related server configuration). When entities are disabled, registration API calls return app.entities.disabled.app_error (model.EntitiesDisabledError).

For method signatures, see the server plugin SDK reference (RegisterEntityType, RegisterEntityMatcher, RegisterEntityProvider, EntityLookup).

Register on activate​

In OnActivate (and again when configuration changes what you offer):

  1. RegisterEntityType — local Name becomes <plugin_id>:<name> everywhere else. Optional static Badge on the type is the mention chrome for every value of that type.
  2. RegisterEntityMatcher — RE2 Pattern plus Type (your type name or a built-in id such as mm:time). Set SkipBots / Scope / URL as needed.
  3. RegisterEntityProvider — list the types you describe. HasCard: true enables the EntityLookup hook. Cache is none (default), shared, or user.
_ = p.API.RegisterEntityType(&model.EntityType{
Name: "ticket", DisplayName: "Ticket",
Badge: &model.EntityBadge{Text: "T", Color: model.EntityBadgeColorNone},
})
_ = p.API.RegisterEntityMatcher(&model.EntityMatcher{
Name: "ticket", Type: "ticket",
Pattern: `TKT-[0-9]+`, Boundary: "token", SkipBots: true,
URL: "https://tickets.example.com/{value}",
})
_ = p.API.RegisterEntityProvider(&model.EntityProvider{
Name: "tickets", Types: []string{"ticket"},
HasCard: true, Cache: model.EntityCacheShared,
})

EntityLookup​

Implement EntityLookup to return a model.EntityCard for a value you provide. Return (nil, nil) when the type is not yours so other providers can answer. Always call model.NormalizeEntityCard before returning.

Prefer a Mattermost Blocks body (card.Blocks, including fields blocks) over legacy Summary / Rows alone. Normalization migrates legacy body fields into blocks when Blocks is empty.

Static mention badges​

A type's Badge is shown on every mention of that type. Set exactly one of Text or Icon.

FieldRules
Text1–4 runes; mutually exclusive with Icon
IconCompass glyph allowlist: shield-outline, shield-alert-outline, alert-outline, lock-outline
ColorOptional severity fill, using the CVSS qualitative colors: none (green), low, medium, high, critical. Empty uses the neutral theme fill.

Per-value details, such as a severity or score, belong on the entity card returned by EntityLookup, not on the mention.

Minimum server version for EntityLookup: 12.2.