-
Notifications
You must be signed in to change notification settings - Fork 788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to Send Replies in Microsoft Teams Using Bot Name Instead of Username via Graph API? #1356
Comments
@purvasanap2001 - Thanks for reporting your issue. |
@purvasanap2001- 1. Register Your Bot Go to the Azure Portal: Navigate to the Azure portal. 2. Configure the Microsoft Bot Framework Obtain the Bot Framework SDK: If you haven’t already, you should use the Bot Framework SDK for your preferred programming language. The SDK simplifies sending messages from your bot. Authenticate the Bot: Get the Bot Token: Use the App ID and App Secret from your bot registration to get a token from the Microsoft Identity platform. This token will be used to authenticate your bot. Send Messages Using the Bot Framework API: Use the Direct Line API: If you’re using the Direct Line channel, you can use the Direct Line API to send messages.
3. Configure Messaging Extensions Correct Scopes and Permissions: Verify that your bot has the necessary permissions to post messages in the teams or channels where you intend to use it. Handle the Message Extension: Implement message extensions correctly so that they can interact with Teams and post messages as the bot. 4. Review Permissions and Consents Bot Permissions: Check that your bot has been granted the correct permissions (like ChatMessage.Send, ChannelMessage.Send, etc.) in the Azure AD app registration. Consents: Verify that these permissions have been consented to by the appropriate users or admins. 5. Testing and Debugging |
@sayali-MSFT , Thanks for the guidance, I also need help In the below issue: Like, using the same token I can send a message as A and also as B. I know there was a document for application permission and I tried it But it is for import use and not for sending messages. |
sending messages directly on behalf of different users is not supported by the Graph API using application permissions. Application permissions are generally used for managing teams, channels, and users but not for sending messages as a specific user. If you need to send messages as different users, you will need to obtain an access token for each user individually, which requires them to authenticate and grant permissions. This approach involves: User Consent Flow: Each user would need to authenticate and grant permissions through the OAuth 2.0 consent flow, after which your application can use their access tokens to send messages on their behalf. OAuth Token Management: You would need to manage and securely store access tokens for each user. This is not typically feasible or secure in many scenarios, especially for applications that need to impersonate users programmatically. Example of Sending Messages Using Delegated Permissions
|
I'm working on an external application that sends replies to messages in Microsoft Teams using the Microsoft Graph API. Currently, the replies are sent using the username associated with the authenticated account. However, I want the replies to appear as if they're coming from the bot itself, using the application name registered in the Azure portal. The bot is also registered as a message extension app. Ideally, I want the responses to display the bot's name, rather than the username of the account making the API call. Here are the steps I'm currently following:
The bot is authenticated and authorized using OAuth2 with the appropriate permissions.
I use the /reply Or /message endpoint to send messages.
I know we can use incoming webhook, but we can't use it.
What I'm looking for:
Any specific configurations needed in the Azure portal or Microsoft Graph API to achieve this. How to Send the message with the bot's name instead of the user's name.
Any help would be greatly appreciated!
The text was updated successfully, but these errors were encountered: