Getting Started
Stand up a minimal EdgeInteract integration in under 30 minutes. This guide walks through the minimum code to send a confirmation interaction from the server and receive the response in a React client.
Prerequisites
- EdgeStream is already configured in your project (both server and client)
- An authenticated user session is available (EdgeInteract requires a user ID to target)
- React 18+ on the client side
Step 1 — Server: Register EdgeInteract Services
In your ASP.NET Core Program.cs or Startup.cs, register the EdgeInteract services after EdgeStream:
// Program.cs
builder.Services.AddEdgeStream(options => {
options.HubPath = "/edge-stream";
});
builder.Services.AddEdgeInteract(options => {
options.DefaultTimeoutMs = 300_000; // 5 minutes default
options.AuditLog.Enabled = true;
});
// Register built-in hooks
builder.Services.AddInteractionHook<AuditInteractionHook>();
builder.Services.AddInteractionHook<RateLimitInteractionHook>();
Step 2 — Server: Publish an Interaction
Inject IInteractionPublisher into your service or execution node and publish an interaction:
// ExampleService.cs
public class ExampleService
{
private readonly IInteractionPublisher _publisher;
public ExampleService(IInteractionPublisher publisher)
{
_publisher = publisher;
}
public async Task<bool> RequestUserConfirmationAsync(string userId)
{
var request = new InteractionRequest
{
Type = InteractionTypes.Confirmation,
TargetUserId = userId,
Title = "Confirm Data Export",
Payload = new ConfirmationPayload
{
Message = "Export all customer records to CSV? This will include 3,421 records.",
ConfirmLabel = "Yes, Export",
CancelLabel = "Cancel"
},
TimeoutMs = 300_000 // 5 minutes
};
var response = await _publisher.PublishAndWaitAsync(request);
return response.Outcome == "confirmed";
}
}
Step 3 — Client: Wrap App with InteractionProvider
In your React app's entry point, add InteractionProvider inside the EdgeStream provider:
// App.tsx
import { EdgeStreamProvider } from 'edge-stream-react';
import { InteractionProvider } from 'edge-interact-react';
import { InteractionContainer } from 'edge-interact-ui';
function App() {
return (
<EdgeStreamProvider hubUrl="/edge-stream">
<InteractionProvider>
{/* InteractionContainer renders incoming interactions as UI */}
<InteractionContainer />
<YourAppContent />
</InteractionProvider>
</EdgeStreamProvider>
);
}
Step 4 — Test It
With the server and client wired up:
Start the server
Ensure EdgeStream hub is running and EdgeInteract services are registered.
Open the React client and authenticate
Log in as the user you'll target. InteractionProvider connects to EdgeStream automatically on mount.
Trigger RequestUserConfirmationAsync from the server
Call via an API endpoint, test runner, or your integration test suite.
Observe the confirmation dialog appear in the browser
The InteractionContainer detects the incoming interaction and renders the ConfirmationComponent.
Click "Yes, Export" and observe the server receive the response
PublishAndWaitAsync resolves with outcome: "confirmed". Your service returns true.
Minimal Working Example Summary
| Component | What It Does |
|---|---|
AddEdgeInteract() | Registers all EdgeInteract server services in DI |
IInteractionPublisher.PublishAndWaitAsync() | Sends the request and awaits the response as a Task |
InteractionProvider | Client context — connects to EdgeStream, manages interaction queue |
InteractionContainer | Renders the appropriate UI component for each incoming interaction |