relay

State Machine

Each conversation instance follows a defined set of state transitions. States ensure predictable behavior and full observability.

States

StateDescription
CREATEDInstance created, agent has not yet sent first message
ACTIVEAgent is actively processing the conversation
WAITING_FOR_REPLYMessage sent to contact, awaiting their response
WAITING_FOR_AGENTContact replied, awaiting agent processing
HEARTBEAT_SCHEDULEDFollow-up timer is pending
PAUSEDInstance suspended by operator command
QUEUEDWaiting for another instance on the same contact to complete
NEEDS_HUMAN_INTERVENTIONAgent has flagged for human review
COMPLETEDConversation finished successfully
ABANDONEDContact did not respond after max follow-ups
FAILEDUnrecoverable error or manual cancellation

Transitions

Normal Flow

CREATED → ACTIVE → WAITING_FOR_REPLY → WAITING_FOR_AGENT → ACTIVE → ...

The conversation cycles between ACTIVE, WAITING_FOR_REPLY, and WAITING_FOR_AGENT until the agent calls end_conversation().

Heartbeat Flow

WAITING_FOR_REPLY → HEARTBEAT_SCHEDULED → WAITING_FOR_REPLY

When a contact does not respond within the configured interval, the heartbeat fires. If max follow-ups are exceeded:

HEARTBEAT_SCHEDULED → ABANDONED

Queuing

Only one active instance per contact. Additional instances enter QUEUED:

QUEUED → CREATED  (when prior instance reaches terminal state)

Pause / Resume

Any non-terminal state can be paused. The previous state is recorded for resumption:

ACTIVE → PAUSED → ACTIVE
WAITING_FOR_REPLY → PAUSED → WAITING_FOR_REPLY

Human Intervention

ACTIVE → NEEDS_HUMAN_INTERVENTION → ACTIVE  (via relay resume or relay send)

Cancellation

Any non-terminal state can be cancelled:

(any non-terminal) → FAILED  (reason: "cancelled")

Terminal States

These states are final. No further transitions are possible:

  • COMPLETED — conversation ended successfully
  • ABANDONED — contact unresponsive after max follow-ups
  • FAILED — error or manual cancellation

On this page