Portal Community

Prerequisites

EdgeStream First EdgeInteract uses EdgeStream as its transport. If you have not set up EdgeStream, do that first before wiring up EdgeInteract.

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:

1

Start the server

Ensure EdgeStream hub is running and EdgeInteract services are registered.

2

Open the React client and authenticate

Log in as the user you'll target. InteractionProvider connects to EdgeStream automatically on mount.

3

Trigger RequestUserConfirmationAsync from the server

Call via an API endpoint, test runner, or your integration test suite.

4

Observe the confirmation dialog appear in the browser

The InteractionContainer detects the incoming interaction and renders the ConfirmationComponent.

5

Click "Yes, Export" and observe the server receive the response

PublishAndWaitAsync resolves with outcome: "confirmed". Your service returns true.

Minimal Working Example Summary

ComponentWhat It Does
AddEdgeInteract()Registers all EdgeInteract server services in DI
IInteractionPublisher.PublishAndWaitAsync()Sends the request and awaits the response as a Task
InteractionProviderClient context — connects to EdgeStream, manages interaction queue
InteractionContainerRenders the appropriate UI component for each incoming interaction
Next Steps You have the basics working. Explore the remaining guides in this series to learn about the interaction pipeline, hooks, all interaction types, React bindings, and observability.