Forum Discussion
Send Message as User/Bot Using Graph API Based on User's Email Existence in Microsoft Teams Channel
How the authentication is different from user authentication as in user authentication we use grant_type as authorization_code.
Also can we send the messages by user/bot using single token?
Authenticating a Bot or Service Account to Send Messages
To authenticate a bot or service account to send messages, you typically use OAuth 2.0. Here’s a general approach:
-
Register the Bot: First, you need to register your bot with the Azure Bot Service. This will give you an App ID and a secret.
-
Obtain a Token: Use the App ID and secret to obtain a token from the Microsoft identity platform. This token will be used to authenticate your bot when sending messages.
-
Send Messages: Use the obtained token to send messages through the Bot Framework.
Difference Between Bot Authentication and User Authentication
The main difference between bot authentication and user authentication lies in the type of token and the flow used:
-
Bot Authentication: Uses a service-to-service token. No user login is required. The bot uses its App ID and secret to obtain a token from the Microsoft identity platform. This token is then used to authenticate the bot when sending messages
-
User Authentication: Uses an authorization code flow. The user logs in and grants permission to the bot to access resources on their behalf. The bot uses the authorization code to obtain an access token, which is then used to perform actions on behalf of the user
Ref Doc: User authentication in the Azure AI Bot Service - Bot Service | Microsoft Learn
Bot Framework SDK authentication basics - Bot Service | Microsoft Learn
Sending Messages by User/Bot Using a Single Token
If you need to perform actions on behalf of a user, you can use the user’s token to send messages through the bot. Ensure that the token has the necessary permissions to perform the required actions.
- Nivedipa-MSFTAug 28, 2024Microsoft
@ XDeveloper29 - Could you please share your valuable feedback via Microsoft Teams Developer Community Response Feedback link?