AI in business

An AI assistant inside your Blazor application, not another chat window

How to add an AI assistant to a Blazor business application that knows your data and respects user permissions, with Microsoft.Extensions.AI and .NET 10.

Vlado Pandžić

Vlado Pandžić · Founder · Senior .NET architect
Published · 5 min read

Most employees already use ChatGPT. They copy an order, a complaint or a paragraph of a contract into it, get an answer, and copy the answer back. It helps, but company data ends up in a tool nobody controls, and the assistant knows nothing about your customers, your orders or who is allowed to see what.

An assistant inside your own Blazor application works differently. It lives next to the screen the user is working on, it reads data through the same services the application already uses, and it only sees what that user is allowed to see.

What it can do on a normal working day

  • “Which of customer Novak’s orders are late, and why?” The assistant looks up the orders and delivery dates and answers in two sentences, instead of the user filtering three tables.
  • “Draft a reply to this complaint.” It reads the complaint and the order history and prepares a draft that the user edits and sends.
  • “Summarise this contract and list the deadlines.” It reads the attached document and pulls out what matters, with a link to the exact place in the text.

In every case, the person decides. The assistant looks things up and prepares, and the user confirms. The same approach inside an inbox or helpdesk is described in AI suggested replies.

How it works, in plain words

  1. 1The user asks on the screen
  2. 2The model decides which data it needs
  3. 3Your services fetch it, with the user's permissions
  4. 4The answer appears as it is written

The key idea is that the model never goes to the database by itself. You give it “tools”, which are ordinary methods of your existing services, and it can only call those. When it wants late orders, it calls OrderService, and OrderService checks permissions exactly as it does for every other screen.

What it looks like in .NET

In .NET, this is built with Microsoft.Extensions.AI, which gives one IChatClient interface for Azure OpenAI and other models. The client is registered once, with automatic tool calling switched on. The application signs in to Azure with its own managed identity, so there is no API key in the configuration:

builder.Services.AddSingleton<IChatClient>(
    new ChatClientBuilder(
            new AzureOpenAIClient(new Uri(endpoint), new DefaultAzureCredential())
                .GetChatClient(deployment).AsIChatClient())
        .UseFunctionInvocation()
        .Build());

The Blazor component, running in Interactive Server mode, gives the model one tool and shows the answer as it arrives:

@inject IChatClient Chat
@inject OrderService Orders
@inject AuthenticationStateProvider Auth

<textarea @bind="question"></textarea>
<button @onclick="AskAsync">Ask</button>
<p>@answer</p>

@code {
    private string question = "";
    private string answer = "";

    private async Task AskAsync()
    {
        var user = (await Auth.GetAuthenticationStateAsync()).User;
        var options = new ChatOptions
        {
            Tools = [AIFunctionFactory.Create(
                (string customer) => Orders.GetLateOrdersAsync(customer, user),
                "get_late_orders",
                "Returns late orders for a customer that the current user is allowed to see")]
        };

        answer = "";
        await foreach (var update in Chat.GetStreamingResponseAsync([new ChatMessage(ChatRole.User, question)], options))
        {
            answer += update.Text;
            StateHasChanged();
        }
    }
}

GetLateOrdersAsync receives the signed-in user, so the assistant can never see more than that user could see on any other screen. That is the same rule as in the Blazor security checklist: permissions belong in the service, not in the UI, and not in the prompt.

A prototype in a day, production in weeks

Microsoft has an AI Chat Web App template (dotnet new aichatweb). It creates a Blazor Interactive Server application with a finished chat interface that can answer questions from documents you put in a folder. It is an excellent way to show management in one day what an assistant looks like on your own documents.

But it is a prototype, not production. For real use, it still needs your permissions, your data sources, logging and cost control.

Rules for production

  • The assistant sees only what the user sees. Every tool calls your services with the signed-in user, and the service checks permissions.
  • A person confirms every action. The assistant may prepare an email, an order change or a credit note, but the user clicks send.
  • Keys and the model stay on the server. That is one more reason to run the assistant screen in Interactive Server mode rather than WebAssembly, as explained in Blazor Server vs WebAssembly vs Auto.
  • Everything is logged and monitored. Microsoft.Extensions.AI supports OpenTelemetry, so questions, tool calls and response times end up in the same monitoring as the rest of the application.
  • Costs have a limit. A limit per user and per day, and a check of which questions are the most expensive.
  • Data stays where it should. According to Microsoft, prompts and answers in Azure OpenAI are not available to OpenAI and are not used to train models. With a regional deployment, they are processed in the geography you choose, while Global and Data Zone deployments can process them more widely, so choose the deployment type deliberately.

Where to start

Pick one screen and one kind of question that your team asks every day and that currently takes several clicks or a phone call. Build the assistant for that alone, measure how much time it saves, and only then expand. A broader view of which AI features pay off in .NET applications is in the article on adding AI to an existing .NET application.

How we work

This is exactly what we do: we bring AI into business processes, including assistants inside existing Blazor and .NET applications, with permissions, confirmation by a person and cost control from the first day. We start with one screen and one measurable saving. More on our AI work, and the first step is a free 30-minute call.

Sources

This article is general information only, not legal, tax, financial or other professional advice. Scenarios, examples and calculations are illustrative. Terms of use and disclaimer.

Related articles

© 2026 ProCoding — All rights reserved.Legal notice and privacyTerms of useSplit, Croatia