Basic setup
Add alifecycle prop to your conversation:
Concepts
Nudge
A nudge is an automated reminder sent when the user has been silent for a configured duration. Nudges are:- Configurable - you set when the first one fires (
after), how often to repeat (interval, defaults toafterif omitted), and when to stop (max, unlimited if omitted) - Auto-resetting - any user message resets the nudge timer
- Handler-controlled - the framework decides when to nudge, you decide what to say
- Workflow-aware - nudges are automatically suppressed while a workflow is running
Expiration
Expiration is when a conversation session ends due to prolonged inactivity. When it fires:- Your handler runs first (
type: "expire") so you can send a goodbye message or save a summary - Then the framework takes over: cancels workflows, tags the conversation, resets state, clears the transcript
Session
A session is a single period of activity within a conversation. One conversation can have many sessions over its lifetime. The framework manages asession object automatically:
| Field | Type | Description |
|---|---|---|
id | string | Unique identifier for this session. Changes on every expiration. |
number | number | Monotonically increasing counter. Session 1, 2, 3… |
status | 'active' or 'expired' | Whether this session is currently live. |
startedAt | string | ISO timestamp when this session began. |
lastActivityAt | string | ISO timestamp of the last user message. |
nudgeCount | number | How many nudges have fired in this session. Resets on new activity and on session renewal. |
conversation.session:
session object is read-only. It returns undefined for conversations without lifecycle configured.
What happens when a conversation expires
Duration strings
Lifecycle durations usems-compatible strings:
| String | Duration |
|---|---|
'30s' | 30 seconds |
'5m' | 5 minutes |
'1h' | 1 hour |
'24h' | 24 hours |
'2d' | 2 days |
Common patterns
Escalating nudges
UsenudgeCount to change the tone as nudges progress:
Welcome back after expiration
Detect when a user returns after a session expired:Nudge-only (no expiration)
Configure nudges without expiration. The conversation stays open indefinitely:Expiration-only (no nudges)
Silently expire after inactivity without reminders:Different timeouts per channel
Each conversation file has its own lifecycle. Use this for channel-appropriate timing:Things to know
- Timers are wall-clock based.
after: "5m"means 5 minutes of real time since the last user message, not “bot idle time.” - Only user messages reset timers. Bot messages, events, and workflow callbacks do not reset the nudge/expire timers.
- Expiration always wins. Even if nudges are suppressed during a workflow, the expire timer keeps ticking. Set
expire.afterlonger than your longest expected workflow. - Session data survives expiration.
session.numberpersists. Only user state and transcript are cleared. - No behavior change without opt-in. Conversations without
lifecyclework exactly as before. - Lifecycle events are invisible to the LLM. Nudge and expire events are not added to the transcript. Only your handler’s
send()calls appear in the conversation history.