BotFramework ReactWebChat With DirectLineAppServiceExtension getting repeated welcome message on specific time interval
See original GitHub issueVersion
What package version of the SDK are you using. Bot Builder V4 SDK .Net Core 3.1
Describe the bug
I have C# SDK based azure bot developed and deployed on azure, this bot is using Language(Custom Question Answering) service for answering users questions. The front end part is a SPFX React WebChat which is a webpart of another sharepoint site and the communication with Bot service is happening over DirectLineApp Service Extension (Web Socket).
The bot is working fine in Emulator or in Test WebChat(In portal) but i am facing issue about repeated welcome message when running it from spfx react webchat.
The problem i analyzed so far is that the event OnMembersAddedAsync have the comparison logic for member added and turncontext receipent id where the values are different always. Which are something like: MemID- dl_ab955807-50ea-4dd8-8bd7-ef6598e0c050 —> direct line guid generated while requesting token ReceipentID- xxxx-bot-t-xxxx@kT5LB7DBjMs —> Bot handle id@Site id
Which are never same for any request.
foreach (var member in turnContext.Activity.MembersAdded)
{
if (member.Id != turnContext.Activity.Recipient.Id)
{
var welcomeCard = CreateAdaptiveCardAttachment();
var response = MessageFactory.Attachment(welcomeCard);
await turnContext.SendActivityAsync(response, cancellationToken);
}
}
To Reproduce
Steps to reproduce the behavior:
- Create Azure Bot and customize code with Bot framework sdk
- Enable Direct Line App Service Extension
- Create SPFX react Web Chat application that will first fetch for token on componentDidMount() react event hook
- Load Bot interface on React Render() method on button click
- Welcome screen will appear for the first time
- Welcome screen will reappear approximately after 5 to 7 min (Screen shot attached herewith)
Expected behavior
Once the bot is successfully hosted and running on azure, the bot should respond to user request properly at first it when client side UI launch the app or bot window it should fetch the token then it should greet user with the welcome message and for next subsequent communication it should answer users queries. (In my case the bot responding well to user queries but welcome screen re appears multiple times)
Screenshots
Additional context
Fetch token method in react webchat
private async fetchToken() {
var myToken ='<<--Secret Key-->>';
const res = await fetch('https://fxxx-test-xxx.azurewebsites.net/api/GetLRToken',
{ method: 'GET',
headers: {'accept': 'application/json'}
});
var { token } = await res.json();
console.log(token);
this.setState({
directLine: await createDirectLineAppServiceExtension({
domain: 'https://cxx-bot-t-xxx.azurewebsites.net/.bot/v3/directline',
token,
}),
});
this.state.directLine.postActivity({
from: { id: "serId", name: "USER_NAME" },
name: "requestWelcomeDialog",
type: "event",
value: "token"
}).subscribe(
id => console.log(`Posted activity, assigned ID ${id}`),
error => console.log(`Error posting activity ${error}`)
);
}
Tracking Status
Dotnet SDK TODO
- PR
- Merged
Javascript SDK TODO
- PR
- Merged
Python SDK TODO
- PR
- Merged
Java SDK TODO
- PR
- Merged
Samples TODO
- PR
- Merged
Docs TODO
- PR
- Merged
Tools TODO
- PR
- Merged
Issue Analytics
- State:
- Created a year ago
- Comments:22 (4 by maintainers)
Hi @pravinambekar
I am now able to reproduce (it was not trivial getting it set up correctly). Investigation so far has yet to yield any root causes. I am currently finding the correct resources to help narrow that down.
hi @pravinambekar Sorry for the delay. Thank you for the additional information. I am going over that and will get back to you soon.