Skip to main content

AI Messages

PrismGamificationIntelligence uses Apple Intelligence (FoundationModels) to generate personalized, context-aware messages — celebrations, motivation, streak alerts, and recommendations. All processing happens on-device.

Setup

Default (Apple Intelligence)
Custom Configuration
Custom Provider

Availability Check

Check Availability
Returns true when the underlying language model is ready on the device.

Message Kinds

Seven message categories for different gamification moments:

Generating Messages

Single Message

Generate

Batch Generation

Batch

With Automatic Fallback

Auto-Fallback

Static Fallback Only

Fallback

PrismGamificationContext

Provide context for richer, more relevant AI messages:

PrismGamificationMessage

Prompt Builder

PrismGamificationPromptBuilder builds context-aware prompts for each message kind. The system instructions configure the AI as a gamification coach:
  • 1–2 sentences max
  • Enthusiastic but not excessive
  • Max 1 emoji
  • References specific achievements
  • Under 100 characters when possible
Custom Prompts

Fallback System

PrismGamificationFallbacks provides static messages for every kind — no AI required:
Fallbacks
Fallbacks use context data to build meaningful messages without AI processing.
Use messageWithFallback in production — it tries AI first and falls back gracefully. Reserve generateMessage for when you want to handle errors yourself.

Integration Pattern

Event-Driven Messages