Not receiving onMembersAdded event on Azure Bot Server

Asif 0 Reputation points
2024-07-16T08:00:26.8433333+00:00

We are experiencing an issue with our Azure Bot service where the onMembersAdded event is not being received on the Bot server for some users. The Bot is installed via the app manifest, which is configured to install the Bot when the app is installed for any user.

It's unclear whether the Bot is not installing for the affected users or the onMembersAdded event is not being fired for them. We checked the Bot server logs and have not received any event for the users to whom the Bot is not installed but the app is installed.

We have two questions:

  1. How can we detect if the Bot is not installed or if the onMembersAdded event is not fired for the users?
  2. Is it possible to get the user Bot details required to send the cards/messages to users without receiving the onMembersAdded event?
Azure AI Bot Service
Azure AI Bot Service
An Azure service that provides an integrated environment for bot development.
842 questions
{count} votes

1 answer

Sort by: Most helpful
  1. YutongTie-MSFT 52,866 Reputation points
    2024-07-30T02:20:36.3066667+00:00

    Hello Asif,

    Thanks for reaching out to us, you may need to use Azure Graph API to achieve it. There are some steps you may want to try -

    Detecting Bot Installation and onMembersAdded Event Issues

    a. Check Bot Installation:

    • Bot Installation Logs: Make sure you have proper logging around the bot installation and configuration. Check the bot’s installation status and logs on the Microsoft Teams Admin Center to see if the bot is installed for users who are not receiving the event.
    • Teams App Catalog: Verify that the app is correctly listed in the Teams app catalog and that users have the app installed. Sometimes, users might not have permissions to install apps or there might be deployment issues.

    b. Verify onMembersAdded Event Handling:

    • Bot Configuration: Ensure that your bot is correctly handling the onMembersAdded event and that the logic to handle this event is functioning correctly. Sometimes, bugs or errors in the event handling code might prevent the event from being processed correctly.
    • Event Handling Code: Review the code where the onMembersAdded event is processed. Make sure the bot is correctly registered to handle this event and that there are no conditions or filters that might be causing some events to be ignored.

    c. Test in Different Scenarios:

    • Test in Different Teams and Channels: Try adding the bot to different teams and channels to see if the issue is specific to certain teams or channels.
    • Check User Permissions: Ensure that the users have the correct permissions to add the bot and that there are no policy restrictions in place that might prevent the bot from being added.

    Obtaining User Details Without onMembersAdded Event

    If the onMembersAdded event is not firing, you can still get user details using other methods:

    a. Use Microsoft Graph API:

    • User Information: You can use the Microsoft Graph API to query user details, such as their userId or email. The Graph API can provide information about users in a team or organization, which can be used to send messages or cards.

    b. Bot Framework’s REST API:

    • Bot Framework API: Use the Bot Framework’s REST API to fetch user profiles and details if you have user IDs.

    c. Manual User Interaction:

    • Direct Interaction: If you have an alternate way to interact with users (e.g., via a web form or another bot interaction), you can ask users to provide their details directly.

    Please take a look and let us know how it works. I hope this helps! Let us know if you have any other question.

    Regards,

    Yutong

    -Please kindly accept the answer if you feel helpful to support the community, thanks a lot.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.