0
votes
  1. I have developed a bot which sends Proactive messages to user
  2. I also cretaed bots which trigger skills. I was trying to write something where a skills bot/Dialog would be able to send proactive message received via webhooks to the user and continue with the existing Skill dialog. I am not able to quite understand that. If anyone could help me there.

I used the sample from here to create a simple Skill bot which saves the ConversationReference of the current Activity and calls a service in OnMessageActivityReceived()

// Save ConversationReference
var conversationReference = activity.GetConversationReference();
_conversationReferences.AddOrUpdate(conversationReference.User.Id, conversationReference, (key, newValue) => conversationReference);

// Calling external service
HttpResponseMessage responsemMsg = await client.PostAsync(RequestURI, stringContent);
if (responsemMsg.IsSuccessStatusCode)
{
    var apiResponse = await responsemMsg.Content.ReadAsStringAsync();

    //Post the API response to bot again
    await turnContext.SendActivityAsync(MessageFactory.Text($"Message Sent {turnContext.Activity.Text}"), cancellationToken);

}

The called service eventually emits an event which calls an action in the NotifyController in my Skills Bot. It tries to grab the ConverstaionReference and send the activity using the TurnContext.


//I am using the Skill Bot Id for _appId parameter
await ((BotAdapter)_adapter).ContinueConversationAsync(_appId, conversationReference, async (context, token) =>
 {
     await context.SendActivityAsync(proMsg.eventName);
     await context.SendActivityAsync(proMsg.context.ToString());
  }, new System.Threading.CancellationToken());

This SendActivity fails and OnTurnError from the Skill Bot handles the exception. I am not sure where excatly I am going wrong. I am new to the Bot framework learning.

2
What have you tried so far? If you can provide some code you are working on and what errors or roadblocks you are facing, people will be better able to help you. - billoverton
@billoverton I have updated my question to add code snippets. - naina

2 Answers

0
votes

My issue got resolved by using the ContinueConversation() overload with ClaimsIdentity and setting the right claims for audience, appid etc. It was basically authentication issue.

public virtual Task ContinueConversationAsync(ClaimsIdentity claimsIdentity, ConversationReference reference, string audience, BotCallbackHandler callback, CancellationToken cancellationToken);
0
votes

@piotr: this is how I created the claimsIdentity:

System.Collections.Generic.List<Claim> lclaim = new System.Collections.Generic.List<Claim>
        {
            new Claim(AuthenticationConstants.VersionClaim, "2.0"),
            new Claim(AuthenticationConstants.AudienceClaim, <SkillBotId>),
            new Claim(AuthenticationConstants.AppIdClaim, <SkillBotId>),
            new Claim(AuthenticationConstants.AuthorizedParty, <SkillBotId>),
        };
        ClaimsIdentity ci = new ClaimsIdentity(lclaim);

        async Task BotCallBack(ITurnContext turnContext, CancellationToken token)
        {
            <code to send activity back to parent bot>
        }

        await ((BotAdapter)this.botFrameworkHttpAdapter).ContinueConversationAsync(
            ci,
            conversationData.ConversationReference,
            <ParentBotId>,
            callback: BotCallBack,
            default).ConfigureAwait(false);