Portal Community

Overview of the Lifecycle

Every EdgeInteract interaction follows the same five-stage lifecycle regardless of type. The stages are sequential and each stage must complete before the next begins. If a stage fails (e.g., timeout), the pipeline terminates with an error message on the callback topic.

R

Request

Server code constructs an InteractionRequest object and calls IInteractionPublisher.PublishAsync(userId, request). The request is assigned a UUID interactionId and timestamped. Pre-send hooks run at this stage.

D

Deliver

EdgeInteract publishes the serialized request to the EdgeStream topic interactions.{userId}. EdgeStream fans out the message to all active WebSocket sessions for that user. The timeout clock starts ticking.

U

Display

The client's InteractionContainer receives the message, reads interactionType, and renders the appropriate UI component. The component receives the typed payload and a respond() callback.

S

Respond

The user takes action (clicks Approve, submits a form, selects options). The component calls respond(outcome, data). EdgeInteract publishes an InteractionResponse to interactions.callback.{interactionId}. Post-receive hooks run here.

A

Acknowledge

The server receives the response on the callback topic, processes it, and sends an InteractionAck back to the user's session. The UI dismisses the interaction component. The cycle is complete.

InteractionRequest Schema

The InteractionRequest object is the entry point to the pipeline. All fields are required unless marked optional:

FieldTypeDescription
interactionIdstring (UUID)Auto-generated unique ID for this interaction instance
typestringInteraction type key: "approval", "confirmation", "form", "picker", "notification"
targetUserIdstringThe user ID of the intended recipient. Can also be a role key for fan-out.
titlestringShort title shown in the UI component header
descriptionstring (optional)Longer contextual description shown below the title
payloadobjectType-specific payload — structure depends on type
timeoutMsnumberMilliseconds before an InteractionTimeout is fired on the callback topic
callbackTopicstring (optional)Defaults to interactions.callback.{interactionId}. Override for custom routing.
correlationIdstring (optional)Attach your workflow execution ID or any correlation key for tracing
priority"normal" | "high" (optional)High-priority interactions appear at the top of the HIL inbox

InteractionResponse Schema

The InteractionResponse is published by the client after the user acts. It is received by the server on the callback topic:

FieldTypeDescription
interactionIdstringMatches the request's interactionId
respondedBystringThe user ID of the user who responded (matters for role-targeted interactions)
outcomestringType-specific outcome: "approved", "rejected", "confirmed", "submitted", "selected", "acknowledged"
dataobject (optional)Type-specific response data (form values, selected IDs, comments)
timestampISO 8601 stringWhen the user responded
sessionIdstringThe EdgeStream session ID of the responding session

Timeout Behavior

Every interaction has a timeoutMs. When the timeout expires without a response:

Always Handle Timeout Never assume a response will arrive. Your server code must handle outcome: "timeout" explicitly. Workflows that ignore timeout will hang indefinitely.

TypeScript Types

// Core types
interface InteractionRequest<TPayload = unknown> {
  interactionId: string;
  type: InteractionTypeKey;
  targetUserId: string;
  title: string;
  description?: string;
  payload: TPayload;
  timeoutMs: number;
  callbackTopic?: string;
  correlationId?: string;
  priority?: 'normal' | 'high';
}

interface InteractionResponse<TData = unknown> {
  interactionId: string;
  respondedBy: string;
  outcome: string;
  data?: TData;
  timestamp: string;
  sessionId: string;
}

interface InteractionTimeout {
  interactionId: string;
  outcome: 'timeout';
  timestamp: string;
}

type InteractionTypeKey =
  | 'approval'
  | 'confirmation'
  | 'form'
  | 'picker'
  | 'notification'
  | string; // custom types

State Machine Summary

StateTransitions ToTrigger
pendingdeliveredRequest published to EdgeStream topic
delivereddisplayedClient session receives the message
deliveredtimed_outNo session receives it within timeoutMs
displayedrespondedUser takes action, respond() called
displayedtimed_outUser does not respond within timeoutMs
respondedacknowledgedServer sends InteractionAck