User Response
When the user takes action on an interaction — clicking Approve, submitting a form, selecting options — the component calls respond(). This triggers the InteractionResponsePublisher to build and publish the InteractionResponse.
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
| Field | Type | Description |
|---|---|---|
interactionId | string | Matches the original request's interactionId |
respondedBy | string | User ID of the responding user — injected by InteractionResponsePublisher from the authenticated session |
outcome | string | Type-specific outcome string. See interaction type reference for valid values. |
data | object (optional) | Type-specific response data. May be null for simple outcomes (e.g., "acknowledged"). |
timestamp | ISO 8601 | Set by the client when respond() is called |
sessionId | string | The EdgeStream session ID of the responding session — for audit and security |
correlationId | string (optional) | Passed through from the original request |
What respond() Does Internally
Build InteractionResponse
InteractionResponsePublisher creates the response object, populating respondedBy from the authenticated session and timestamp from Date.now().
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.
Remove from Queue
The interaction is removed from the local InteractionQueue. The InteractionContainer advances to the next interaction in the queue (if any).
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
| Type | Valid Outcomes | Data Shape |
|---|---|---|
approval | approved, rejected, abstained | { comment?: string } |
confirmation | confirmed, cancelled | none |
form | submitted | submitted form field values object |
picker | selected | { selectedIds: string[] } |
notification | acknowledged | none |
outcome is valid for the declared interaction type. An invalid outcome triggers a validation error response back to the client.