如何在Composer机器人项目中安装BotBuilder-Samples的handoff-library?相关安装指引缺失及文档不匹配问题咨询
You’re definitely not missing something obvious here—this experimental handoff library is light on Composer-specific setup docs, which is a total pain. Let’s break down the actual steps to get it integrated, since the standard custom action guide doesn’t cover pre-built library cases like this:
1. Prep the Handoff Library Files
Since you already cloned the repo, head to the experimental/handoff-library folder.
- Open the
Microsoft.Bot.Builder.HandoffC# project in Visual Studio (or use the .NET CLI) and build it:dotnet build - Grab the compiled
Microsoft.Bot.Builder.Handoff.dlland any related dependency DLLs from thebin/Debug(orRelease) directory—don’t skip the dependencies, they’re crucial.
2. Add the Library to Your Composer Project
- Navigate to your Composer bot’s root folder and create a new directory (name it something like
CustomLibrariesto keep things organized). - Copy all the DLLs from step 1 into this new folder.
- Now, edit your bot’s
.csprojfile (it lives in theGeneratedfolder for C# bots):- Add a reference to the handoff DLL by inserting this snippet inside the
<Project>tag:<ItemGroup> <Reference Include="Microsoft.Bot.Builder.Handoff"> <HintPath>..\CustomLibraries\Microsoft.Bot.Builder.Handoff.dll</HintPath> </Reference> <!-- Add references for any other dependency DLLs here too --> </ItemGroup>
- Add a reference to the handoff DLL by inserting this snippet inside the
- Save the file and restart Composer so it picks up the new library reference.
3. Register the Handoff Services
- Open your bot’s
Program.csfile (also in theGeneratedfolder). Look for the section where bot services are registered (you’ll see lines likebuilder.Services.AddBotRuntime()). - Add the handoff service registration:
builder.Services.AddHandoff(); - Don’t forget to add the using statement at the top of the file:
using Microsoft.Bot.Builder.Handoff;
4. Use Handoff Actions in Your Dialogs
Since this is an experimental library, Composer’s UI might not auto-populate the handoff actions. You’ll need to either:
- Manually add actions via Composer’s code editor, referencing the fully qualified class names from the library (check the repo’s source code for exact names like
TriggerHandoffAction). - Use the "Custom Action" option in Composer’s dialog designer and input the full class path for the handoff action you want to use.
Why the Official Custom Action Guide Doesn’t Fit
The standard guide walks you through building a custom action from scratch, but this handoff library is a pre-built component. You don’t need to create the action project itself—just reference the compiled DLL and register its services. That’s where the guide diverges, which is why it didn’t match your use case.
If you hit snags, double-check that:
- All dependency DLLs from the library’s build are copied over.
- Your bot’s .NET version matches the library’s (it should target .NET 6 or higher, same as most modern Composer bots).
内容的提问来源于stack exchange,提问作者Karric

