Timers

Timers allow you to schedule delayed actions and handle time-based events in your MindedJS agents.

Overview

The timer system provides three main functions:

  • resetTimer - Set or reset a timer for a specific session

  • cancelTimer - Cancel an existing timer

  • onTimer - Register handlers for timer events

Setting Timers

Use resetTimer to create or update a timer:

import { resetTimer } from '@minded-ai/mindedjs';

await resetTimer({
  sessionId: 'session-123',
  seconds: 30,
  timerName: 'inactivity-followup',
  payload: {
    message: 'Are you still there?',
    attemptNumber: 1
  }
});

Canceling Timers

Cancel a timer before it triggers:

Handling Timer Events

Register handlers that execute when timers trigger:

Last updated