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.

onTeamsMembersAddedEvent handler doesn't run

See original GitHub issue

Versions

What package version of the SDK are you using: ^4.9.0

What nodejs version are you using: v13.6.0

What browser version are you using: Chrome 81.0.4044.138

What os are you using: MacOS 10.14.6

Describe the bug

TeamsActivityHandler.onTeamsMembersAddedEvent handler doesn’t fire.

To Reproduce

  1. Inside Teams, Upload custom app -> select .zip -> Add
  2. Observe that app home screen is now open in web app
  3. Observe POST request to bot endpoint (using ngrok)
// POST /api/messages

{
    "membersAdded": [
        {
            "id": "29:1hjD7KSnkCFRm5xasdfd4Jt0Kw9Ehhk56B_T0KB6b1428DEgDa0s7bOAV71kcBtXa_w",
            "aadObjectId": "32adf3ba-8b97-44c7-a06c-e2d4f7sdsda38cbc"
        },
        {
            "id": "28:85a028da-48d7-4237-b1ac-4231c4544fe8"
        }
    ],
    "type": "conversationUpdate",
    "timestamp": "2020-05-13T09:38:52.6203787Z",
    "id": "f:e9e5ac1a-dbf0-38b0-1d1f-dd6b5c5b34fe",
    "channelId": "msteams",
    "serviceUrl": "https://smba.trafficmanager.net/amer/",
    "from": {
        "id": "29:1hjD7KSnkCmRm5x3iCCDMB6Ivlq4AYc1aID9JnJB4Jt0Kw9Ehhk56B_T0KB6b1428DEgDa0s7bOAV71kcBtXa_w",
        "aadObjectId": "12alf9ba-8b97-44c7-a06c-e2d4f7a38cbc"
    },
    "conversation": {
        "conversationType": "personal",
        "tenantId": "a2aee900-2e61-4451-97f0-f45baa3db628",
        "id": "a:14mtI5vt1TkHonyxiEu3mNptiDttg80gtLHGBUWkdzmvmOrDlYSsx7ELKGMegDBxuvpPFQd0bKL2CUrRVfHrAdOXGlfn64mej1UOCAQlal-j4N-OOo9YUnXe9q5L-yDsc"
    },
    "recipient": {
        "id": "28:85b828da-48f7-4237-b0ac-4231c4545fe8",
        "name": "MyBot"
    },
    "channelData": {
        "tenant": {
            "id": "a2aee900-2e61-4451-97f0-f45baa3db628"
        }
    }
}
// server.js
const bot = new MyBot()
app.post('/api/messages', async (req, res) => {
  adapter.processActivity(req, res, async (context) => {
    if (context.activity.type !== ActivityTypes.Invoke) {
      await bot.run(context)
    }
  })
})

// bot.js
module.exports.MyBot = class MyBot extends TeamsActivityHandler {
  constructor() {
      super()
      this.onTeamsMembersAddedEvent(async (membersAdded, teamInfo, turnContext, next) => {
        console.log('onTeamsMembersAddedEvent')
        await next()
      })
  }
}

Expected behavior

‘onTeamsMembersAddedEvent’ string output to console

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

this.onConversationUpdate works (by work, I mean I can see that the handler code is executed)

So does this.onMembersAdded.

Interestingly, using both this.onMembersAdded and this.onTeamsMembersAddedEvent at the same time, neither of them fire. When I remove, this.onTeamsMembersAddedEvent, this.onMembersAdded fires. this.onConversationUpdate always fires no matter what other handlers are registered.

[bug]

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mdrichardsoncommented, May 13, 2020

Confirmed that I can repro this on v4.9.0, but not prior. Digging into this now.

0reactions
EricDahlvangcommented, May 14, 2020

Hi @oliviert

Thank you for reporting this!

We have a fix https://github.com/microsoft/botbuilder-js/pull/2237 which should be released in the next few days as v4.9.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

TeamsActivityHandler class - Microsoft Learn
A promise that represents the work queued. Inherited Method Details. onCommand(BotHandler). Registers an activity event handler for the command activity.
Read more >
ms bot framework onMembersAddedActivity does not get ...
Developers may handle Conversation Update activities sent from Microsoft Teams via two ... Event() (e.g. onTeamsMembersAdded() ), or instead ...
Read more >
OnMembersAddedAsync doesn't fire when bot is added to a ...
Version 4.4.3 Describe the bug Adding the Echo Bot to a new team doesn't fire the OnMembersAddedAsync event handler, which contradicts the ...
Read more >
Event Handler Doesn't get Parameter - Microsoft Dynamics AX ...
Dear All,. I have an issue on my code. My event handler doesn't get parameter. Here is my code and variable on debugger....
Read more >
Removing Event Handler Crashes the Designer
[severity:It's more difficult to complete my work]. Create an event handler for a WinForms control. Maybe it is Validated. Doesn't matter what event....
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