Search code examples
c#botframework

Virtual Assistant Skill - how to kill/end the current skills bot you are in


I was trying to implement an msbot skill that handles the directory services, such as the contact number and email of a person. My issue is I cannot get out of the skills bot. I have tried everything but nothing works.

I am trying to do the following on the skills bot to end or kill it, and return the dialog state to the parent:

  • EndDialogAsync()
  • CancelAllDialogsAsync()
  • EndComponentAsync()

but unfortunately I am not able to return to the parent bot, instead it keeps comming back to the skills bot, and its not what I wanted. I maybe doing it wrong, I am not sure how to end the skills bot state and return to the parent bot, as the main functions are there.


Solution

  • You need to send an EndOfConversation Activity. See how our skills sample does it:

    protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
    {
        if (turnContext.Activity.Text.Contains("end") || turnContext.Activity.Text.Contains("stop"))
        {
            // Send End of conversation at the end.
            await turnContext.SendActivityAsync(MessageFactory.Text($"ending conversation from the skill..."), cancellationToken);
            var endOfConversation = Activity.CreateEndOfConversationActivity();
            endOfConversation.Code = EndOfConversationCodes.CompletedSuccessfully;
            await turnContext.SendActivityAsync(endOfConversation, cancellationToken);
        }
    [...]