AWorld Lab
English
  • English
  • Italiano
About
API ReferenceAWorld.orgAWorld Trust
About
API ReferenceAWorld.orgAWorld Trust
AWorld.org
English
  • English
  • Italiano
English
  • English
  • Italiano
  1. Domain Deep-Dives
  • Gamification Fundamentals
    • Engagement for Businesses and Organizations
    • API-first for Gamification
    • Activities, Learning, and Content
    • Missions, Rewards, and Progression
    • Leaderboards and Social Mechanics
  • Engagement Scenarios
    • Employee Engagement and Training
    • Customer Loyalty Program
    • Education Platform
    • Community and App Engagement
  • Domain Deep-Dives
    • Mission Domain
    • Learning Content Domain
    • Reward and Currency Domain
    • Badge Domain
    • Leaderboard Domain
    • Streak Domain
    • Cross-Cutting Patterns
  • Infrastructure & Security
    • Cloud Infrastructure and Architecture
    • Security and Cybersecurity
    • Compliance and Certifications
    • Disaster Recovery and Business Continuity
    • Performance and Scalability
    • Access Methods and Integration
    • Technical Glossary
  1. Domain Deep-Dives

Mission Domain

The mission system turns user actions into structured goals. It answers questions like "Has this user completed 10 quizzes this week?" or "Has the marketing team collectively finished 50 activities this month?"
This section covers the full configuration model: entity hierarchies, matching logic, assignment modes, and lifecycle management. It is relevant for anyone configuring missions through the dashboard or integrating them via API. For a high-level overview of what missions do, see the Gamification Fundamentals. For shared patterns used across all domains (JsonLogic expressions, timeframes, entity matching), see Cross-Cutting Patterns.
The domain is built around four entities that form a clear hierarchy:
MissionConfiguration  (what counts and how to count it)
      │
      └──▶ MissionRule  (when, for whom, and how to assign)
                │
                └──▶ Mission  (per-user or per-group tracking instance)
                        │
                        └──▶ MissionLog  (immutable progress audit trail)

Mission Configuration#

A Mission Configuration defines what user actions count toward a mission and how progress is measured. It is the template that specifies matching logic, increment rules, and completion targets.

Fields#

FieldTypeDescription
missionConfigurationIdnanoidUnique identifier
namestringHuman-readable reference (e.g., "Answer 10 Quizzes Correctly")
missionTypeINDIVIDUAL | GROUPWhether missions track one user or a group
matchTypeINSTANCE | ENTITY | TAGHow to match incoming events
matchEntityActivity | Quiz | TagWhich entity type to watch
matchEntityIdstring?Specific entity or tag ID (required for INSTANCE and TAG)
matchConditionJsonLogicAdditional matching logic evaluated at runtime
incrementExpressionJsonLogicHow much progress each matching event adds
targetAmountExpressionJsonLogicThe completion threshold
originCATALOG | CUSTOMWhere this configuration was created
defaultLanglangDefault language code
langslang[]Supported languages (1–10)

Match Types#

INSTANCE: Matches a specific entity. Example: completing activity abc123. Requires matchEntityId.
ENTITY: Matches any entity of that type. Example: completing any quiz.
TAG: Matches any entity tagged with the given tag. Example: completing any activity tagged sustainability. Requires matchEntityId (the tag ID).

Expressions#

The three expression fields are what make mission configurations flexible:
matchCondition filters which events qualify. It receives { mission } as context and must return a truthy value for the event to count. Example: only count quizzes with outcome SUCCESS.
incrementExpression defines how much progress each qualifying event adds. It receives { user, event } and must return a number. A static value like 1 means "add 1 per event". A conditional expression can award different amounts based on context — for instance, awarding 2 for hard quizzes and 1 for easy ones.
targetAmountExpression defines when the mission is complete. It receives { user, mission } and must return a number. A static 10 means "complete after 10 increments". A dynamic expression can set different targets per user — for instance, a higher target for premium users.
Constraint: When a JsonLogic expression evaluates to null, empty string, or NaN, the system defaults to 1 for both increment and target calculations.

Mission Rule#

A Mission Rule defines when and for whom missions are assigned. Every rule references one or more Mission Configurations (via a pool or matching condition) and controls how those configurations are instantiated as actual missions for users.

Core Fields#

FieldTypeDescription
missionRuleIdnanoidUnique identifier
namestringHuman-readable name
missionTypeINDIVIDUAL | GROUPMust match the referenced configurations
statePENDING | ACTIVE | ENDEDLifecycle state
assignmentModeLAZY | EVENT | DISABLEDHow missions are assigned to users
usersMatchConditionJsonLogic?Which users this rule applies to (required for INDIVIDUAL)
missionsMatchConditionJsonLogicFilters which configurations to instantiate
missionConfigurationsPoolstring[]?Explicit list of configuration IDs to use (alternative to matching)

Assignment Modes#

The assignment mode determines how and when missions are created for users:
LAZY: Missions are created on-demand when a user browses available missions. If the user matches the rule's conditions, the mission is generated in real time. Ideal for discovery-driven experiences where users choose which missions to pursue.
EVENT: Missions are assigned automatically when a matching event occurs — for example, assigning a follow-up mission when the user completes a Learning Path. This is real-time and reactive.
DISABLED: No assignments are made. Used for deactivating a rule without deleting it.

Event Mode Fields#

When assignmentMode is EVENT, four additional fields become required:
FieldTypeDescription
eventMatchTypeINSTANCE | ENTITY | TAGHow to match the triggering event
eventMatchEntityActivity | Quiz | Tag | UserWhich entity type triggers assignment
eventMatchEntityIdstringSpecific entity or tag ID
eventMatchConditionJsonLogicAdditional filtering on the event
Constraint: All four eventMatch* fields are required when assignmentMode is EVENT and must be absent for other modes.

User and Mission Targeting#

usersMatchCondition determines which users are eligible for this rule. It receives { user, activeMissions } as context — where activeMissions is the list of missions already assigned to the user. This allows rules like "only assign if the user doesn't already have 3 active missions".
Constraint: usersMatchCondition is required for INDIVIDUAL rules and must be absent for GROUP rules (the entire group is eligible by definition).
missionsMatchCondition filters which Mission Configurations should be instantiated. It receives { user, activeMissions, mission } where mission is a candidate configuration. This allows rules like "only assign configurations tagged with the user's department".
missionConfigurationsPool is an alternative to missionsMatchCondition — an explicit list of configuration IDs. When present, only these configurations are considered.

Timeframe#

FieldTypeDescription
timeframeTypePERMANENT | RANGE | RECURRINGWhether the rule runs indefinitely, once, or repeats
timeframeStartsAtISO datetimeWhen the rule begins
timeframeEndsAtISO datetime?When the rule ends (required for RANGE and RECURRING)
timeframeTimezoneTypeFIXED | USERWhether to use a fixed timezone or each user's own
timeframeTimezonetimezone?The fixed timezone (required when FIXED)
recurrenceDAILY | WEEKLY | MONTHLY | CUSTOM?Reset cadence (required for RECURRING)
scheduleCroncron?Cron expression (required when recurrence is CUSTOM)
For a full explanation of timeframe, recurrence, and timezone handling, see the Cross-Cutting Patterns document.

Group Targeting#

FieldTypeDescription
groupTagIdstring?The tag that identifies the group (required for GROUP rules)
Constraint: GROUP rules require groupTagId. INDIVIDUAL rules must not have it.

Mission (Assignment)#

A Mission is a tracking instance — the concrete assignment of a Mission Configuration to a specific user or group under a specific rule. It holds the current progress and the frozen target.

Fields#

FieldTypeDescription
missionIdnanoidUnique identifier
missionConfigurationIdnanoidThe configuration this mission is based on
missionRuleIdnanoid?The rule that triggered this assignment
missionTypeINDIVIDUAL | GROUPInherited from configuration
userIdnanoid?The user this mission belongs to (INDIVIDUAL only)
groupTagIdstring?The group this mission belongs to (GROUP only)
statePENDING | ACTIVE | ENDEDLifecycle state
isCompletedboolean?Whether the target has been reached
completedAtISO datetime?When the mission was completed
currentAmountnumberAccumulated progress
targetAmountnumberFrozen completion threshold
periodIdstringDeduplication key for recurring missions
The mission also carries copies of matching and expression fields from the configuration (matchType, matchEntity, matchEntityId, matchCondition, incrementExpression, targetAmountExpression) so that progress tracking does not depend on the configuration remaining unchanged.

Mission Types#

INDIVIDUAL missions are assigned to a single user. Each user gets their own mission instance with independent progress tracking. When currentAmount >= targetAmount, the mission is marked as completed and stops accepting further increments.
GROUP missions are assigned to a group identified by a tag. All users in the group contribute to the same currentAmount. Unlike individual missions, group missions continue counting after reaching the target — they track cumulative group progress without capping.
Constraint: INDIVIDUAL missions require userId and forbid groupTagId. GROUP missions require groupTagId and forbid userId.

Period Identification#

The periodId field serves as a deduplication key that prevents the same rule from assigning duplicate missions in the same time period:
TimeframeperiodId FormatExample
PERMANENT"PERMANENT"PERMANENT
RANGERule's start time in UTC2025-01-01T00:00:00
RECURRING / DAILYYYYY-MM-DD2025-09-15
RECURRING / WEEKLYYYYY-Www2025-W38
RECURRING / MONTHLYYYYY-MM2025-09
RECURRING / CUSTOMCron last-fire time in UTC2025-09-15T06:00:00
A MissionRuleEvaluation record is created each time a rule is evaluated for a user/group in a given period, preventing duplicate assignments.

Status Lifecycle#

    rule assigns mission
           │
    ┌──────▼──────┐
    │   PENDING    │ ◀── mission starts in the future
    └──────┬──────┘
           │  startsAt reached
           ▼
    ┌─────────────┐     currentAmount >= targetAmount
    │   ACTIVE    │ ──────────────────────────────────▶ isCompleted = true
    └──────┬──────┘     (INDIVIDUAL only; GROUP keeps counting)
           │  endsAt reached
           ▼
    ┌─────────────┐
    │   ENDED     │ ◀── timeframe expired
    └─────────────┘
PENDING: The mission exists but its timeframe hasn't started. targetAmount is not yet calculated.
ACTIVE: The mission is accepting progress. On transition to ACTIVE, the targetAmount is calculated from targetAmountExpression and frozen — subsequent changes to the expression or user context do not affect it.
ENDED: The timeframe has expired. Terminal state.

Mission Log#

A Mission Log is an immutable record created every time a mission's progress is updated. It provides a complete audit trail of which user contributed what amount and when.

Fields#

FieldTypeDescription
missionLogIdnanoidUnique identifier
missionIdnanoidThe mission that was updated
missionConfigurationIdnanoidThe configuration reference
missionTypeINDIVIDUAL | GROUPMission type
userIdnanoidThe user who triggered the progress
groupTagIdnanoid?For group missions
amountnumberThe increment applied (default: 1)
additionalDatarecord?Extra context from the source event
For group missions, the userId records which user in the group contributed, while the increment applies to the shared currentAmount.

How Missions Are Assigned#

When a user action occurs (completing an activity, passing a quiz, etc.), the system follows different paths depending on the assignment mode:

EVENT Mode Flow#

1.
The source system (Activity, Quiz, etc.) publishes an event.
2.
The mission engine queries for all ACTIVE rules with assignmentMode: EVENT that match the event's entity type and ID.
3.
For each matching rule:
The eventMatchCondition is evaluated against the event data.
The usersMatchCondition is evaluated against the user (for INDIVIDUAL) or skipped (for GROUP).
The missionsMatchCondition (or missionConfigurationsPool) determines which configurations to instantiate.
A MissionRuleEvaluation check prevents duplicate assignments in the same period.
4.
New Mission assignments are created in batch.

LAZY Mode Flow#

1.
A user browses available missions (e.g., opens the missions screen).
2.
The system queries for all ACTIVE rules with assignmentMode: LAZY.
3.
For each rule, the same evaluation chain runs: user eligibility → configuration matching → deduplication check.
4.
Eligible missions are created on-the-fly and returned to the user.

Source Event Remapping#

Source events are remapped to match entity types before evaluation:
Source EventMaps To
ActivityLogActivity
QuizLogQuiz
OthersPass through

How Progress Is Tracked#

When a user performs an action that might count toward a mission:
1.
The system queries for all ACTIVE, non-completed missions that match the event (by matchType, matchEntity, matchEntityId).
2.
For each matching mission, the matchCondition is evaluated against the event context.
3.
If the condition passes, the incrementExpression is evaluated to determine how much to add.
4.
The mission's currentAmount is atomically incremented.
5.
An immutable MissionLog entry is created.
6.
For INDIVIDUAL missions: if currentAmount >= targetAmount, the mission is marked as completed (isCompleted: true, completedAt set).
7.
For GROUP missions: the counter continues regardless of whether the target was reached.

Idempotency#

The counter update is idempotent — if the same event is processed twice (due to retries or at-least-once delivery), the mission's currentAmount is only incremented once. This is enforced via an idempotency key based on the event ID.
Mission completion uses a conditional database update that only sets isCompleted: true if it was previously false, preventing double-completion.

Example: Full Configuration#

Consider a company that wants to create a weekly quiz challenge: "Complete 5 quizzes with a passing score each week."

Step 1: Mission Configuration#

{
  "missionConfigurationId": "mc_quiz_weekly",
  "name": "Weekly Quiz Challenge",
  "missionType": "INDIVIDUAL",
  "matchType": "ENTITY",
  "matchEntity": "Quiz",
  "matchCondition": { "===": [{ "var": "event.outcome" }, "SUCCESS"] },
  "incrementExpression": 1,
  "targetAmountExpression": 5,
  "defaultLang": "en",
  "langs": ["en", "it"]
}
This says: count any quiz completion where the outcome is SUCCESS, add 1 per event, complete at 5.

Step 2: Mission Rule#

{
  "missionRuleId": "mr_quiz_weekly",
  "name": "Weekly Quiz Rule",
  "missionType": "INDIVIDUAL",
  "assignmentMode": "LAZY",
  "usersMatchCondition": true,
  "missionsMatchCondition": true,
  "missionConfigurationsPool": ["mc_quiz_weekly"],
  "timeframeType": "RECURRING",
  "timeframeStartsAt": "2025-01-06T00:00:00Z",
  "timeframeEndsAt": "2025-12-31T23:59:59Z",
  "timeframeTimezoneType": "USER",
  "recurrence": "WEEKLY",
  "defaultLang": "en",
  "langs": ["en"]
}
This says: every week, make this mission available to all users (LAZY — they see it when they browse missions). Use each user's local timezone for week boundaries.

Step 3: What Happens at Runtime#

1.
Monday: User opens the missions screen. The LAZY rule is evaluated. A new Mission is created:
periodId: "2025-W38", state: "ACTIVE", currentAmount: 0, targetAmount: 5
2.
Tuesday: User completes a quiz with outcome SUCCESS. The matchCondition passes. incrementExpression returns 1. Mission becomes currentAmount: 1.
3.
Wednesday: User completes a quiz but fails. The matchCondition evaluates to false (outcome is not SUCCESS). No increment.
4.
Friday: User completes 4 more passing quizzes. Mission reaches currentAmount: 5, isCompleted: true.
5.
Next Monday: A new period begins (2025-W39). The LAZY rule creates a fresh mission with currentAmount: 0.

Alternative: Event-Based Team Mission#

{
  "missionRuleId": "mr_team_event",
  "name": "Team Onboarding Challenge",
  "missionType": "GROUP",
  "groupTagId": "department:engineering",
  "assignmentMode": "EVENT",
  "eventMatchType": "ENTITY",
  "eventMatchEntity": "Activity",
  "eventMatchEntityId": "activity_onboarding",
  "eventMatchCondition": true,
  "missionsMatchCondition": true,
  "missionConfigurationsPool": ["mc_team_onboarding"],
  "timeframeType": "RANGE",
  "timeframeStartsAt": "2025-09-01T00:00:00Z",
  "timeframeEndsAt": "2025-09-30T23:59:59Z",
  "timeframeTimezoneType": "FIXED",
  "timeframeTimezone": "Europe/Rome"
}
This says: when any user completes the onboarding activity, assign a group mission to the engineering department. The mission tracks collective progress from September 1–30, Rome time.

Summary of Key Concepts#

ConceptPurpose
MissionConfigurationDefines what events count and how to measure progress (matching + expressions)
MissionRuleDefines when, for whom, and how missions are assigned (timeframe + targeting + mode)
MissionPer-user or per-group tracking instance with frozen target and live progress
MissionLogImmutable audit trail of every progress event
assignmentModeHow missions are created: LAZY (on-demand), EVENT (reactive), DISABLED (off)
missionTypeINDIVIDUAL (one user, stops at target) or GROUP (shared counter, keeps going)
matchTypeHow events are matched: INSTANCE (specific), ENTITY (any of type), TAG (by tag)
periodIdDeduplication key ensuring one mission per rule per time period
targetAmountFrozen when mission becomes ACTIVE — immune to later configuration changes
MissionRuleEvaluationTracks which rule+period combinations have been evaluated, preventing duplicates

Related Domains#

Reward and Currency Domain: mission completion events can trigger reward rules, automatically awarding virtual currency.
Leaderboard Domain: leaderboards can rank users by mission-related metrics.
Streak Domain: streaks can track activity completions that also feed into missions.
Cross-Cutting Patterns: JsonLogic expressions, entity matching, timeframe and scheduling, and state lifecycle patterns used throughout this domain.
Modified at 2026-02-24 16:05:00
Previous
Community and App Engagement
Next
Learning Content Domain
Built with