botbuilder-js icon indicating copy to clipboard operation
botbuilder-js copied to clipboard

[Nodejs] Ask how to send proactive message message from skill to consumer without "<Unauthorized. Invalid AppId passed on token: skill app id here>"

Open tracyboehrer opened this issue 2 years ago • 2 comments

[GENERAL INFO]

Bot ID: I was able to repro with my bots; CX bot id is: omni-root-bot-dev-v1 App ID: efa2e6fe-bf1e-4521-a746-b3db5c98136c Subscription ID: cde58a60-b083-4190-8122-66243d80da50 Exact Time Frame In UTC:

[PROBLEM DESCRIPTION] The customer has a root bot (skill consumer) calling a skill bot, using our samples.

He sends a proactive message to the skill bot. The skill bot receives the message. The root should also receive the message.

When sending the proactive message from the skill to the root, he receives this error

[onTurnError] Exception caught in sendEoCToParent: Error: "Unauthorized. Invalid AppId passed on token: <>"

[TROUBLESHOOTING STEPS] Attempted a repro on my machine using these steps:

  1. For the skill and root, use the sample 80 BotBuilder-Samples/samples/javascript_nodejs/80.skills-simple-bot-to-bot at main · microsoft/BotBuilder-Samples (github.com)

  2. In the skill bot added the proactive messages using this sample BotBuilder-Samples/index.js at main · microsoft/BotBuilder-Samples (github.com)

  3. For both skill and root, filled in all the app id's in the env files.

  4. Started the skill by running npm install npm start

  5. Started the root by running npm install npm start

  6. Opened both of them in the emulator (along with ms app id and pass). The root connects successfully to the skill.

  7. In the browser, accessed this http://localhost:39783/api/notify where this 39783 is the port which the skill runs on.

  8. The skill receives the proactive hello.

image

  1. The root does not receive the proactive hello. Instead, it throws this error [onTurnError] Exception caught in sendEoCToParent: Error: "Unauthorized. Invalid AppId passed on token: 2095c97d-8c67-45e4-9454-c19b3f075fb5"

where this 2095c97d-8c67-45e4-9454-c19b3f075fb5 is the msappid of my skill

I am sharing with you the complete code which I used to repro.

[BUSINESS IMPACT] <How is this impacting customer?> The S500 strategic customer is stuck in his development. <Are multiple customers impacted?> Yes, we have also one stack overflow thread node.js - NodeJS Proactive Messaging in Bot-framework for Skill Bot - Stack Overflow <If issue is regarding a specific bot, is the bot in production?> Not yet; but the dev is blocked by the error.

[ASK FOR PG] Could you please guide us on how the root can receive the proactive hello?

[DATA GAP] A sample illustrating sending proactive message from skill to consumer (root).

[TA/Support Consulted] None.


ADDITIONAL INFORMATION FROM AZURE SUPPORT CENTER

Support Request Number: 2205160040002645

Subscription Id: cde58a60-b083-4190-8122-66243d80da50

Resource Group: omni-root-dev-v1

Resource Uri: omni-root-bot-dev-v1

Tenant Id: db05faca-c82a-4b9d-b9c5-0f64b6755421

IcM Link: https://portal.microsofticm.com/imp/v3/incidents/details/308860537/home

tracyboehrer avatar Aug 05 '22 19:08 tracyboehrer

@ceciliaavila @JuanAr Can you help us reproduce this and possibly find a solution?

tracyboehrer avatar Aug 05 '22 19:08 tracyboehrer

Hi @tracyboehrer,

In order for a Consumer/Skill scenario to work properly with proactive messages, the skills' continueConversationAsync method differs from the Proactive sample. Moreover, this implementation is being used by the WaterfallHost and Skill bots in the FunctionalTests repo (same sample applies for DotNet bots). Additionally, we found the issue BotBuilder-Samples#2312 which has a discussion about performing proactive messages from Consumer/Skill bots.

Note: The following steps have been extracted from the FunctionalTests repo showing how the proactive message functionality works.

Guide for adding proactive messages to a skill bot

  1. Add the proactive endpoint (api/notify) to handle the continuationParameters state, that contains the Claims, ConversationReference and oAuthScope into the index.js file, and share it as a parameter to the bot.js file (inherited from the ActivityHandler class). image
  2. In the bot.js file, add a method to set the continuationParameters state when the onMessage event is executed, and the ability to remove the reference in the onTurn event once the proactive message is received from the continued conversation. image
  3. Connect the Consumer bot with the Skill and perform the proactive functionality by hitting the Skill api/notify endpoint. image

Thanks!

sw-joelmut avatar Aug 11 '22 18:08 sw-joelmut