能否通过主动通知触发目标对话中的Bot Action Dialog?
Absolutely, you can trigger the target dialog in your Skill Bot once you've retrieved the necessary conversation details from the Proactive State accessor—just relying on SendActivityAsync() with a plain message won't cut it, but with a few targeted steps, you can get this working. Here's what you need to do:
Key Steps to Make It Work
1. Grab the full ConversationReference, not just the ID
Don't stop at retrieving just the conversation ID. You need the complete ConversationReference object stored in your proactive state—it includes critical details like ServiceUrl, ChannelId, User info, and Bot info. This full reference is required to re-establish a valid connection between your VA and Skill Bot.
2. Reconnect to the Skill and send a trigger-specific activity
Instead of sending a generic message, send an event activity that your Skill Bot is programmed to recognize. This tells the Skill exactly which dialog to launch, rather than expecting it to infer intent from plain text.
Here's a quick C# example for your VA:
// Retrieve the stored ConversationReference from proactive state var conversationReference = await _proactiveStateAccessor.GetAsync(turnContext, () => new ConversationReference(), CancellationToken.None); // Create an event activity to trigger the target dialog var triggerEvent = Activity.CreateEventActivity(); triggerEvent.Name = "LaunchTargetDialog"; // Unique name your Skill will listen for triggerEvent.Value = new { DialogParam = "Any data you need to pass" }; // Optional parameters // Use the adapter to continue the conversation with the Skill await turnContext.Adapter.ContinueConversationAsync( _botAppId, conversationReference, async (skillTurnContext, ct) => { // Send the event to the Skill await skillTurnContext.SendActivityAsync(triggerEvent, ct); }, CancellationToken.None);
3. Handle the trigger event in your Skill Bot
In your Skill Bot's main bot class, override the OnEventActivityAsync method to listen for the specific event and launch your target dialog:
protected override async Task OnEventActivityAsync(ITurnContext<IEventActivity> turnContext, CancellationToken cancellationToken) { if (turnContext.Activity.Name == "LaunchTargetDialog") { // Extract any passed parameters if needed var dialogParams = turnContext.Activity.Value as dynamic; // Start your target dialog await turnContext.BeginDialogAsync(nameof(YourTargetDialog), dialogParams?.DialogParam, cancellationToken); } else { // Fallback to base handling for other events await base.OnEventActivityAsync(turnContext, cancellationToken); } }
4. Double-check state and trust configurations
- State Persistence: Ensure your Skill Bot's
DialogStateis properly persisted (using a state provider like Cosmos DB or Azure Blob Storage). This lets the dialog track its progress after being triggered proactively. - Cross-Bot Trust: Verify that your VA's app ID is listed in the Skill's
AllowedCallersconfiguration, and vice versa. Missing this will block the VA from sending messages to the Skill.
内容的提问来源于stack exchange,提问作者Manish Sridhar

