Skip to content
Introducing AI Conversations: Natural Language Interaction for Your Apps! Learn More

AI Conversations | Getting Started

Shiny.AiConversation is a centralized AI conversation service that combines Microsoft.Extensions.AI chat completions with Shiny.Speech for speech recognition, text-to-speech, wake word detection, and audio feedback — all behind a single IAiConversationService interface.

Building a conversational AI experience in a mobile or web app typically means stitching together many concerns yourself: managing chat client authentication, wiring up speech-to-text and text-to-speech, handling microphone permissions, coordinating state between listening/thinking/responding phases, playing audio cues, persisting message history, and exposing tools for the AI to call. Each of these is a separate library with its own lifecycle and threading model.

Shiny.AiConversation collapses all of that into a single service registration and one interface. By default, it resolves IChatClient directly from your DI container — just register your chat client and the library handles the rest. For advanced scenarios (on-demand authentication, token refresh), you can implement IChatClientProvider. Either way, the library manages the entire flow — from capturing the user’s voice, streaming it through speech recognition, sending the transcript to the chat model, reading the response aloud, and optionally persisting the conversation. The entire flow is observable through a simple Status property so your UI always knows what’s happening.

This means you can go from zero to a fully functional voice-enabled AI assistant with wake word support, audio feedback, and chat history in under 50 lines of registration code — and swap AI backends (OpenAI, Azure, Ollama, GitHub Copilot) without changing your app logic.

GitHubGitHub stars for shinyorg/aiconversation
DownloadsNuGet downloads for Shiny.AiConversation
Frameworks
.NET
.NET MAUI
Operating Systems
Android
iOS
Windows
Web
  • Text chat — send messages via TalkTo() and receive streaming AI responses
  • Voice chatListenAndTalk() captures speech and sends it to the AI in one call
  • Wake word — hands-free activation with StartWakeWord("Hey Copilot") that listens continuously
  • Text-to-speech — AI responses can be read aloud automatically
  • Audio feedback — configurable sound effects for thinking, responding, ok, cancel, and error states
  • Acknowledgement modesNone, AudioBlip, LessWordy, or Full text-to-speech
  • System prompts — prepend instructions to every chat request
  • Message persistence — optional IMessageStore for chat history storage and retrieval
  • AI chat lookup tool — optional AITool that lets the AI search its own conversation history
  • Automatic tool discovery — any AITool registered in DI is automatically included in chat requests, so tools from other libraries (Shiny.DI, Shiny.DocumentDb, Shiny.Mediator, etc.) work out of the box
  • State tracking — observable Status property (Idle, Listening, Thinking, Responding)
  • Pluggable providers — default resolves IChatClient from DI; optionally implement IChatClientProvider for custom auth (OpenAI, Copilot, Ollama, etc.)
  • AOT compatible — fully trimmer-safe with IsAotCompatible enabled
  • Cross-platform — works on MAUI (Android, iOS, Windows) and Blazor (Server, WASM)
┌─────────────────────────────────┐
│ IAiConversationService │ ← Your app talks to this
├─────────────────────────────────┤
│ IChatClientProvider │ ← Default resolves IChatClient from DI
│ ISpeechToTextService │ ← From Shiny.Speech
│ ITextToSpeechService │ ← From Shiny.Speech
│ IAudioPlayer │ ← From Shiny.Speech
│ IMessageStore? │ ← Optional persistence (you implement)
│ IEnumerable<AITool> │ ← Optional AI tools (auto-registered)
└─────────────────────────────────┘
Shiny.AiConversationNuGet package Shiny.AiConversation
  1. Install the NuGet package

    NuGet package Shiny.AiConversation
    Terminal window
    dotnet add package Shiny.AiConversation
  2. Register a chat client

    The simplest approach is to register an IChatClient in DI — the library resolves it automatically:

    builder.Services.AddChatClient(new OpenAIClient("your-api-key").GetChatClient("gpt-4o").AsIChatClient());

    For advanced scenarios (on-demand authentication, token refresh), implement IChatClientProvider instead — see Chat Client Provider.

  3. Register the service in your app

    MAUI (MauiProgram.cs):

    builder.Services.AddShinyAiConversation(opts =>
    {
    // Optional: add message store, configure settings
    });

    Blazor (Program.cs):

    builder.Services.AddShinyAiConversation(opts =>
    {
    // Optional: add message store, configure settings
    });
  4. Configure the service after building

    var aiService = app.Services.GetRequiredService<IAiConversationService>();
    aiService.SystemPrompts.Add("You are a helpful assistant.");
    // Optional: configure sounds (MAUI example)
    aiService.SoundResolver = name => FileSystem.OpenAppPackageFileAsync(name);
    aiService.OkSound = "ok.mp3";
    aiService.ThinkSound = "think.mp3";
    aiService.ErrorSound = "error.mp3";
  5. Use the service

    public class ChatViewModel(IAiConversationService aiService)
    {
    public async Task Send(string message)
    {
    aiService.AiResponded += response =>
    Console.WriteLine($"AI: {response.Message}");
    await aiService.TalkTo(message, CancellationToken.None);
    }
    }
// Text chat
await aiService.TalkTo("What is .NET MAUI?", cancellationToken);
// Voice chat (push-to-talk)
await aiService.ListenAndTalk(cancellationToken);
// Hands-free wake word
await aiService.StartWakeWord("Hey Copilot");
// ... user says "Hey Copilot, what's the weather?"
// Service automatically captures and sends to AI
aiService.StopWakeWord();
// Chat history (requires IMessageStore)
var history = await aiService.GetChatHistory(limit: 50);
await aiService.ClearChatHistory();
// Acknowledgement modes
aiService.Acknowledgement = AiAcknowledgement.Full; // Read response aloud
aiService.Acknowledgement = AiAcknowledgement.LessWordy; // Concise TTS
aiService.Acknowledgement = AiAcknowledgement.AudioBlip; // Sound effects only
aiService.Acknowledgement = AiAcknowledgement.None; // Silent

Since AI Conversations uses Shiny.Speech for voice features, you must declare speech and microphone permissions.

Android — Add to AndroidManifest.xml:

<uses-permission android:name="android.permission.RECORD_AUDIO" />

iOS — Add to Info.plist:

<key>NSSpeechRecognitionUsageDescription</key>
<string>This app uses speech recognition</string>
<key>NSMicrophoneUsageDescription</key>
<string>This app uses the microphone for speech recognition</string>

Windows — Add the Microphone capability to your Package.appxmanifest:

<Capabilities>
<DeviceCapability Name="microphone" />
</Capabilities>

All required dependencies are pulled in transitively by the Shiny.AiConversation package — you only need to install the one package.

PackagePurpose
Microsoft.Extensions.AIIChatClient abstraction for AI chat completions
Shiny.SpeechSpeech-to-text, text-to-speech, and audio playback
  • Sample MAUI App — Full chat app with GitHub Copilot, settings, aura visualization
  • Sample Blazor App — Server-side Blazor equivalent with the same features
claude plugin marketplace add shinyorg/skills
claude plugin install shiny-client@shiny
BLE, GPS, Jobs, Notifications, Push, HTTP Transfers, OBD, Music, Health, DataSync — iOS, Android, Windows, MacOS, Linux, Web
claude plugin install shiny-maui@shiny
Shell, Contact Store
claude plugin install shiny-controls@shiny
TableView, BottomSheet, PillView, ImageViewer, Scheduler, Markdown, Mermaid Diagrams — MAUI and Blazor
claude plugin install shiny-mediator@shiny
Mediator/CQRS with middleware and source generators
claude plugin install shiny-data@shiny
DocumentDB and Spatial data libraries
claude plugin install shiny-aspire@shiny
Orleans and Gluetun Aspire integrations
claude plugin install shiny-extensions@shiny
DI, Stores, Reflector, Localization, Hosting modules
copilot plugin marketplace add https://github.com/shinyorg/skills
copilot plugin install shiny-client@shiny
BLE, GPS, Jobs, Notifications, Push, HTTP Transfers, OBD, Music, Health, DataSync — iOS, Android, Windows, MacOS, Linux, Web
copilot plugin install shiny-maui@shiny
Shell, Contact Store
copilot plugin install shiny-controls@shiny
TableView, BottomSheet, PillView, ImageViewer, Scheduler, Markdown, Mermaid Diagrams — MAUI and Blazor
copilot plugin install shiny-mediator@shiny
Mediator/CQRS with middleware and source generators
copilot plugin install shiny-data@shiny
DocumentDB and Spatial data libraries
copilot plugin install shiny-aspire@shiny
Orleans and Gluetun Aspire integrations
copilot plugin install shiny-extensions@shiny
DI, Stores, Reflector, Localization, Hosting modules
View Skills Repository