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):
RegisterEntityType— localNamebecomes<plugin_id>:<name>everywhere else. Optional staticBadgeon the type is the mention chrome for every value of that type.RegisterEntityMatcher— RE2PatternplusType(your type name or a built-in id such asmm:time). SetSkipBots/Scope/URLas needed.RegisterEntityProvider— list the types you describe.HasCard: trueenables theEntityLookuphook.Cacheisnone(default),shared, oruser.
_ = 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.
| Field | Rules |
|---|---|
Text | 1–4 runes; mutually exclusive with Icon |
Icon | Compass glyph allowlist: shield-outline, shield-alert-outline, alert-outline, lock-outline |
Color | Optional 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.