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.
| GitHub | |
| Downloads |
Features
Section titled “Features”- Text chat — send messages via
TalkTo()and receive streaming AI responses - Voice chat —
ListenAndTalk()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 modes —
None,AudioBlip,LessWordy, orFulltext-to-speech - System prompts — prepend instructions to every chat request
- Message persistence — optional
IMessageStorefor chat history storage and retrieval - AI chat lookup tool — optional
AIToolthat lets the AI search its own conversation history - Automatic tool discovery — any
AIToolregistered 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
Statusproperty (Idle,Listening,Thinking,Responding) - Pluggable providers — default resolves
IChatClientfrom DI; optionally implementIChatClientProviderfor custom auth (OpenAI, Copilot, Ollama, etc.) - AOT compatible — fully trimmer-safe with
IsAotCompatibleenabled - Cross-platform — works on MAUI (Android, iOS, Windows) and Blazor (Server, WASM)
Architecture
Section titled “Architecture”┌─────────────────────────────────┐│ 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)└─────────────────────────────────┘-
Install the NuGet package
Terminal window dotnet add package Shiny.AiConversation -
Register a chat client
The simplest approach is to register an
IChatClientin 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
IChatClientProviderinstead — see Chat Client Provider. -
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}); -
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"; -
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);}}
Quick Example
Section titled “Quick Example”// Text chatawait aiService.TalkTo("What is .NET MAUI?", cancellationToken);
// Voice chat (push-to-talk)await aiService.ListenAndTalk(cancellationToken);
// Hands-free wake wordawait aiService.StartWakeWord("Hey Copilot");// ... user says "Hey Copilot, what's the weather?"// Service automatically captures and sends to AIaiService.StopWakeWord();
// Chat history (requires IMessageStore)var history = await aiService.GetChatHistory(limit: 50);await aiService.ClearChatHistory();
// Acknowledgement modesaiService.Acknowledgement = AiAcknowledgement.Full; // Read response aloudaiService.Acknowledgement = AiAcknowledgement.LessWordy; // Concise TTSaiService.Acknowledgement = AiAcknowledgement.AudioBlip; // Sound effects onlyaiService.Acknowledgement = AiAcknowledgement.None; // SilentPlatform Permissions
Section titled “Platform Permissions”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>Dependencies
Section titled “Dependencies”All required dependencies are pulled in transitively by the Shiny.AiConversation package — you only need to install the one package.
| Package | Purpose |
|---|---|
Microsoft.Extensions.AI | IChatClient abstraction for AI chat completions |
Shiny.Speech | Speech-to-text, text-to-speech, and audio playback |
Samples
Section titled “Samples”- Sample MAUI App — Full chat app with GitHub Copilot, settings, aura visualization
- Sample Blazor App — Server-side Blazor equivalent with the same features
AI Coding Assistant
Section titled “AI Coding Assistant”Step 1 — Add the marketplace:
claude plugin marketplace add shinyorg/skills Step 2 — Install plugins:
claude plugin install shiny-client@shiny claude plugin install shiny-maui@shiny claude plugin install shiny-controls@shiny claude plugin install shiny-mediator@shiny claude plugin install shiny-data@shiny claude plugin install shiny-aspire@shiny claude plugin install shiny-extensions@shiny Step 1 — Add the marketplace:
copilot plugin marketplace add https://github.com/shinyorg/skills Step 2 — Install plugins:
copilot plugin install shiny-client@shiny copilot plugin install shiny-maui@shiny copilot plugin install shiny-controls@shiny copilot plugin install shiny-mediator@shiny copilot plugin install shiny-data@shiny copilot plugin install shiny-aspire@shiny copilot plugin install shiny-extensions@shiny Next Steps
Section titled “Next Steps”- Chat Client Provider — How to implement
IChatClientProviderfor different AI backends - Message Store — Persist and query chat history
- Acknowledgements & Sound — Configure audio feedback and text-to-speech modes
- Wake Word — Hands-free voice activation
- AI Tools — Register AI tools including the built-in chat history lookup