Portal Community

The respond() Callback

Every interaction component receives a respond(outcome, data?) function as a prop. This is the single point of contact between the UI and the EdgeInteract pipeline:

// respond signature
type RespondFn = (outcome: string, data?: unknown) => Promise<void>;

// Example: user clicks "Approve" in an ApprovalComponent
function ApprovalComponent({ interaction, respond }: InteractionComponentProps) {
  const handleApprove = async () => {
    await respond('approved', { comment: 'Looks good to me.' });
    // UI dismissal happens automatically after respond() resolves
  };

  const handleReject = async () => {
    await respond('rejected', { comment: 'Budget exceeded.' });
  };

  return (
    <div>
      <h3>{interaction.title}</h3>
      <button onClick={handleApprove}>Approve</button>
      <button onClick={handleReject}>Reject</button>
    </div>
  );
}

InteractionResponse Schema

FieldTypeDescription
interactionIdstringMatches the original request's interactionId
respondedBystringUser ID of the responding user — injected by InteractionResponsePublisher from the authenticated session
outcomestringType-specific outcome string. See interaction type reference for valid values.
dataobject (optional)Type-specific response data. May be null for simple outcomes (e.g., "acknowledged").
timestampISO 8601Set by the client when respond() is called
sessionIdstringThe EdgeStream session ID of the responding session — for audit and security
correlationIdstring (optional)Passed through from the original request

What respond() Does Internally

1

Build InteractionResponse

InteractionResponsePublisher creates the response object, populating respondedBy from the authenticated session and timestamp from Date.now().

2

Publish to Callback Topic

The response is serialized to JSON and published via EdgeStream to interactions.callback.{interactionId}. The server is subscribed to this topic and receives it immediately.

3

Remove from Queue

The interaction is removed from the local InteractionQueue. The InteractionContainer advances to the next interaction in the queue (if any).

4

Await Acknowledgement

respond() returns a promise that resolves when the InteractionAck arrives back from the server. This confirms the server processed the response. Components can show a loading state while awaiting the ack.

Outcome Values by Type

TypeValid OutcomesData Shape
approvalapproved, rejected, abstained{ comment?: string }
confirmationconfirmed, cancellednone
formsubmittedsubmitted form field values object
pickerselected{ selectedIds: string[] }
notificationacknowledgednone
Invalid Outcomes Are Rejected The response validation hook on the server checks that the outcome is valid for the declared interaction type. An invalid outcome triggers a validation error response back to the client.