OfficeDev / Microsoft-Teams-Samples

Welcome to the Microsoft Teams samples repository. Here you will find task-focused samples in C#, JavaScript and TypeScript to help you get started with the Microsoft Teams App!
MIT License
949 stars 749 forks source link

How to capture replies to a bot's message in a Microsoft Teams Channel without mentioning the bot? #1355

Open purvasanap2001 opened 1 month ago

purvasanap2001 commented 1 month ago

I have developed a message extension bot app for Microsoft Teams and I want to capture replies to a message posted by the bot in a Teams channel without requiring users to mention the bot directly. I am using Node.js and TypeScript for my bot. The bot is registered in the azure portal. I want to capture replies to this message without users needing to mention the bot. How can I achieve this?

I have gone through document. As mentioned in it, I cannot see the ChannelMessage.Read.Group and ChatMessage.Read.Chat permissions in both the application and the delegate permissions in azure portal. I have tried using ChannelMessage.Read.All and ChatMessage.Read.All, but it is not working. https://techcommunity.microsoft.com/t5/teams-developer/how-to-capture-replies-to-a-bot-s-message-in-a-microsoft-teams/m-p/4199233/highlight/true#M10455 Could you please provide further guidance on how to resolve this issue?

Any guidance or examples would be greatly appreciated!

Nivedipa-MSFT commented 1 month ago

@purvasanap2001 - Thanks for reporting your issue. You have to add ChannelMessage.Read.Group and ChatMessage.Read.Chat permissions in app manifest not in azure portal.

image

Please follow the steps to capture replies to a bot's message in a Microsoft Teams Channel without mentioning the bot in the documentation below: Receive all conversation messages

please let us know if you have any further query here?

purvasanap2001 commented 1 month ago

@Nivedipa-MSFT , I added the necessary configuration to the manifest.json file and uploaded the manifest to the channel. However, it is not working. When I attempt to send a reply without mentioning the bot, it does not trigger the onMessageActivity method.

 "webApplicationInfo": {
        "id": [BOT_ID],
        "resource": "https://Anystring"
    },
    "authorization": {
        "permissions": {
            "resourceSpecific": [
                {
                    "type": "Application",
                    "name": "ChannelMessage.Read.Group"
                },
                {
                    "type": "Application",
                    "name": "ChatMessage.Read.Chat"
                }
            ]
        }
    }
purvasanap2001 commented 1 month ago

@Nivedipa-MSFT can you please update on this?

purvasanap2001 commented 1 month ago

@sayali-MSFT, can you please help on this?

Nivedipa-MSFT commented 1 month ago

@purvasanap2001 - Could you please verify the id and resource fields in the webApplicationInfo section are correctly configured? The id should be the bot's ID, and the resource should be a valid URL.

purvasanap2001 commented 1 month ago

@Nivedipa-MSFT , Could you please help me understand what the valid URL should be? According to the documentation the webApplicationInfo.resource can be any string.

purvasanap2001 commented 1 month ago

@Nivedipa-MSFT /@sayali-MSFT, Please help on the above query.

Nivedipa-MSFT commented 1 month ago

@purvasanap2001 - Yes, you are correct. The webApplicationInfo.resource can be any string. We have tested bot-receive-channel-messages-withRSC sample and it's working fine at our end. We are able to capture replies to this message without users needing to mention the bot and it does trigger the onMessageActivity method.

Video:

https://github.com/user-attachments/assets/b62633b7-06dc-41d6-9887-8fabdefda265

Could you please test bot-receive-channel-messages-withRSC sample and check again?

purvasanap2001 commented 1 month ago

@Nivedipa-MSFT , I encountered this issue because I uploaded a new manifest without removing the previous app, which prevented the new manifest from overriding the old one. After removing the previous app and then uploading the new manifest, everything worked as expected.

Nivedipa-MSFT commented 1 month ago

@purvasanap2001 - Glad to hear that it's working for you. Could you please share your valuable feedback via Microsoft Teams Developer Community Response Feedback link?