MODULE 05 · LESSON 5.7
Embed SurfaceChatLink on a business page
Embed SurfaceChatLink beside a service request.
Lesson 27 of 86 · FabrCore 2.0
Overview
SurfaceChatLink places an inline launcher wherever the component is rendered and opens a chat panel for its target agent. This lets users ask about work without navigating away from a business page. Position affects the opened panel, not viewport placement of the launcher.
The link targets a workspace agent
SurfaceChatLink renders an inline launcher and opens a panel bound to its target agent/recipe. Put it next to the request details so a user can discuss the current work without navigating to a separate chat application. The panel position controls the opened panel; it does not pin the launcher to the viewport.
Creation and existing instances differ
A recipe can describe the instance to create, but an existing instance may retain its previously stored configuration. Changing a Razor parameter is not proof that a running agent changed type, model or tools. Use the supported update/reconfiguration path when that is the intent. Keep the request ID explicit when supplying page context.
Place chat beside the request
Download the Operations Desk source. The README lists project setup, package prerequisites and local ports.
- Place the Razor example on ServiceRequest.razor or in a layout. Set AgentHandle to assistant or an authorized full handle. Omit it only when the link should follow the workspace's selected agent.
- Set Title, Tooltip, Icon, WelcomeMessage, Position and InitialSize. Add explicit container CSS if you want a fixed launcher rather than an inline button.
- Provision the agent in trusted application code or use the explicit CreateAgent flow in the next lesson. Open the panel, send a request and try resize/minimize.
@using FabrCore.Surface.Components
<SurfaceChatLink AgentHandle="assistant"
Title="Assistant"
Tooltip="Open assistant"
OnMessageReceived="HandleAgentMessageAsync"
InitialSize="SurfaceChatLinkSize.Medium"
Position="SurfaceChatLinkPosition.BottomRight" />
@page "/"
<PageTitle>Operations Desk</PageTitle>
<main class="container py-5">
<header class="d-flex justify-content-between"><h1>Service request SR-1042</h1><SurfaceNotify SurfacePath="/surface" /></header>
<p>Printer unavailable · Open</p>
<p>Choose Create in the chat panel to provision the echo assistant. <a href="/surface">Open the command center</a>.</p>
<p role="status">@pageStatus</p>
<SurfaceChatLink AgentHandle="assistant" Title="Request assistant" Tooltip="Ask about this request"
WelcomeMessage="Ask about SR-1042" Position="SurfaceChatLinkPosition.BottomRight"
InitialSize="SurfaceChatLinkSize.Medium" CreateAgent="CreateAsync"
AllowReset="true" OnMessageReceived="ReceivedAsync" />
</main>
@code {
private string pageStatus = "No page updates yet.";
private Task<AgentHealthStatus> CreateAsync(SurfaceChatLinkCreateAgentContext context)
=> context.PrincipalContext.CreateAgent(new AgentConfiguration {
Handle = context.AgentAlias, AgentType = "ops-echo", Models = "default",
Description = "Request page assistant", ForceReconfigure = false
});
private Task<bool> ReceivedAsync(AgentMessage message)
{
if (message.MessageType == "data-changed")
{
pageStatus = "The agent reported a change. Reload authorized request data here.";
StateHasChanged();
return Task.FromResult(false);
}
return Task.FromResult(true);
}
}
Compare the request page and workspace
- Open ServiceRequest.razor for SR-1042 and click Request assistant. If the instance is missing, use Create, then send a recognizable message.
- Confirm the panel targets the expected agent and that its recipe matches the intended echo or AI alias. If changing to AI, explicitly update the instance and configure the model first.
- Open /surface for the same principal and inspect the corresponding agent timeline. The page panel should be another view of that workspace, not an unrelated chat database.
The component provides a contextual entry point into the shared workspace. It does not automatically know which business fields your agent needs.
If the result is different
A bare handle resolves for the current principal. If the panel targets the wrong instance, inspect principal context and the configured AgentHandle before changing routing code.
Go deeper
Explore the related documentation.