![]() |
VOOZH | about |
dotnet add package Microsoft.AI.Actions --version 0.1.0
NuGet\Install-Package Microsoft.AI.Actions -Version 0.1.0
<PackageReference Include="Microsoft.AI.Actions" Version="0.1.0" />
<PackageVersion Include="Microsoft.AI.Actions" Version="0.1.0" />Directory.Packages.props
<PackageReference Include="Microsoft.AI.Actions" />Project file
paket add Microsoft.AI.Actions --version 0.1.0
#r "nuget: Microsoft.AI.Actions, 0.1.0"
#:package Microsoft.AI.Actions@0.1.0
#addin nuget:?package=Microsoft.AI.Actions&version=0.1.0Install as a Cake Addin
#tool nuget:?package=Microsoft.AI.Actions&version=0.1.0Install as a Cake Tool
The Microsoft.AI.Actions NuGet package provides source generators, attributes, and helper classes to simplify creation and consumption of Windows App Actions.
For more information about Windows App Actions, visit the App Actions on Windows Overview documentation.
Create a class and annotate it with the [ActionProvider] attribute:
using Microsoft.AI.Actions.Annotations;
using Windows.AI.Actions;
[ActionProvider]
public sealed class MyActionsProvider
{
[WindowsAction(
Description = "Send a message to a contact",
Icon = "ms-resource://MyApp/Assets/MessageIcon.png",
FeedbackHandler = nameof(SendMessageFeedback),
UsesGenerativeAI = false
)]
[WindowsActionInputCombination(
Inputs = ["Contact"],
Description = "Send message to '${Contact.Text}'"
)]
[WindowsActionInputCombination(
Inputs = ["Contact", "Message"],
Description = "Send '${Message.Text}' to '${Contact.Text}'"
)]
public async Task<SendMessageResult> SendMessage(
[Entity(Name = "Contact")] string contact,
[Entity(Name = "Message")] string? message,
InvocationContext context)
{
// Your action logic here
string result = await ProcessMessageAsync(contact, message);
return new SendMessageResult
{
Text = context.EntityFactory.CreateTextEntity(result)
};
}
public Task SendMessageFeedback(ActionFeedback feedback, InvocationContext context)
{
// Handle user feedback for the action
return Task.CompletedTask;
}
}
public record SendMessageResult
{
public required TextActionEntity Text { get; init; }
}
The source generator will automatically create the necessary COM server infrastructure and action registration code during compilation.
[ActionProvider]Marks a class as an action provider. The source generator will create COM server registration code for this class.
Properties:
ClsId: Optional custom CLSID for the COM server[WindowsAction]Defines a Windows action method that can be invoked by the system.
Properties:
Id: Unique identifier for the actionDescription: Human-readable description of the actionIcon: Path to the action's icon resourceFeedbackHandler: Name of the method that handles action feedbackUsesGenerativeAI: Indicates if the action uses AI/ML capabilitiesIsAvailable: Whether the action is currently availableDisplaysUI: Whether the action shows user interfaceContentAgeRating: Age rating for the action contentPositiveFeedbackUri: URI for positive feedbackNegativeFeedbackUri: URI for negative feedback[WindowsActionInputCombination]Defines valid input combinations for an action method. Multiple attributes can be applied to support different parameter combinations.
Properties:
Inputs: Array of input parameter namesWhere: Optional conditions for the input combinationDescription: Description template for this input combination[Entity]Annotates action parameters to specify their semantic meaning and type.
Properties:
Name: Semantic name of the entityKind: Type of entity (from ActionEntityKind enumeration)Support real-time streaming of text responses:
[WindowsAction(Description = "Generate a story")]
public GetStoryResponse GenerateStory(string prompt, InvocationContext context)
{
return new GetStoryResponse
{
StreamingText = new StreamingTextEntityWriter(
ActionEntityTextFormat.Plain,
textWriter => GenerateStoryAsync(textWriter, prompt)
)
};
}
private async Task GenerateStoryAsync(StreamingTextActionEntityWriter writer, string prompt)
{
// Stream text as it's generated
foreach (var chunk in GenerateTextChunks(prompt))
{
writer.SetText(chunk);
await Task.Delay(100); // Simulate streaming delay
}
}
Handle user feedback for your actions:
public async Task MyActionFeedback(ActionFeedback feedback, InvocationContext context)
{
switch (feedback.Type)
{
case ActionFeedbackType.Positive:
await LogPositiveFeedback(feedback);
break;
case ActionFeedbackType.Negative:
await LogNegativeFeedback(feedback);
break;
}
}
Create various types of entities in your action responses:
public MyActionResult ProcessAction(InvocationContext context)
{
var entityFactory = context.EntityFactory;
return new MyActionResult
{
TextResult = entityFactory.CreateTextEntity("Processing complete"),
NumberResult = entityFactory.CreateNumberEntity(42.0),
// Add other entity types as needed
};
}
The package supports several MSBuild properties for customization:
GenerateActionRegistrationManifest: Generate action registration manifestActionRegistrationManifest: Path to custom action registration manifestGenerateActionsWinRTComServer: Generate WinRT COM server codeRootNamespace: Root namespace for generated codeExample in your .csproj file:
<PropertyGroup>
<GenerateActionRegistrationManifest>true</GenerateActionRegistrationManifest>
<GenerateActionsWinRTComServer>true</GenerateActionsWinRTComServer>
</PropertyGroup>
Build Errors: Ensure you're targeting the correct Windows SDK version. You might need to manually specify <WindowsSdkPackageVersion> for your project:
.NET 8.0 use <WindowsSdkPackageVersion>10.0.26100.59-preview</WindowsSdkPackageVersion>..NET 9.0 use <WindowsSdkPackageVersion>10.0.26100.60-preview</WindowsSdkPackageVersion>.Actions Not Appearing: Verify that your action provider class is properly annotated and that the COM server registration is successful.
Entity Resolution: Check that entity names match between the [Entity] attribute and input combination definitions.
For issues, questions, and contributions, please visit the Windows App Actions documentation or file issues in the appropriate GitHub repository.
This package is licensed under the MIT License. © Microsoft Corporation. All rights reserved.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0-windows10.0.26100 net8.0-windows10.0.26100 is compatible. net9.0-windows net9.0-windows was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0 | 2,385 | 7/2/2025 |