Skip to main content
Lifecycle management adds idle nudges and session expiration to your conversations. You configure timers, and the framework handles scheduling, state resets, and session tracking.

Basic setup

Add a lifecycle 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 to after if 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:
  1. Your handler runs first (type: "expire") so you can send a goodbye message or save a summary
  2. 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 a session object automatically: You can access the current session via conversation.session:
The session object is read-only. It returns undefined for conversations without lifecycle configured.

What happens when a conversation expires

Duration strings

Lifecycle durations use ms-compatible strings: Durations are validated at construction time. Invalid or non-positive values throw an error immediately.

Common patterns

Escalating nudges

Use nudgeCount 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.after longer than your longest expected workflow.
  • Session data survives expiration. session.number persists. Only user state and transcript are cleared.
  • No behavior change without opt-in. Conversations without lifecycle work 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.
Last modified on April 27, 2026