question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BotFramework ReactWebChat With DirectLineAppServiceExtension getting repeated welcome message on specific time interval

See original GitHub issue

Version

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.

image

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:

  1. Create Azure Bot and customize code with Bot framework sdk
  2. Enable Direct Line App Service Extension
  3. Create SPFX react Web Chat application that will first fetch for token on componentDidMount() react event hook
  4. Load Bot interface on React Render() method on button click
  5. Welcome screen will appear for the first time
  6. 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

165280318-a678deee-57fa-4c71-8a6c-949cd0ff85d6

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:closed
  • Created a year ago
  • Comments:22 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
dmvtechcommented, May 23, 2022

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.

1reaction
dmvtechcommented, May 5, 2022

hi @pravinambekar Sorry for the delay. Thank you for the additional information. I am going over that and will get back to you soon.

Read more comments on GitHub >

github_iconTop Results From Across the Web

question - Microsoft Learn
BotFramework ReactWebChat With DirectLineAppServiceExtension getting repeated welcome message on specific time interval.
Read more >
reactjs - BotFramework ReactWebChat With ... - Stack Overflow
BotFramework ReactWebChat With DirectLineAppServiceExtension getting repeated welcome message on specific time interval.
Read more >
Sending a Welcome Message using the v4 Bot Framework ...
Most of the time, when interfacing with a bot, the bot will send you a "welcome message" or introduce itself before you type...
Read more >
botframework-webchat-component | Yarn - Package Manager
This repository contains code for the Bot Framework Web Chat component. The Bot Framework Web Chat component is a highly-customizable web-based client for ......
Read more >
Web Chat samples - Microsoft Open Source
Sample Name, Description, Link. Migration. 00.migration/a.v3-to-v4, Demonstrates how to migrate from your Web Chat v3 bot to v4. Migration Demo. Getting ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found