@Namitha M - Please follow below steps to add Bot to group chat and send message using the Bot in that group chat.
Create a bot: You need to create a bot using the Bot Framework SDK for Python. Make sure to set the "isNotificationOnly" property to False if you want the bot to interact with users.
Register the bot with Microsoft Teams: After creating the bot, you need to register it with Microsoft Teams. This will provide you with a Bot ID that you can use to add the bot to a group chat.
Create a group chat: You can create a group chat using the Microsoft Graph API. The API will return a chat ID that you can use to add the bot to the chat.
Add the bot to the group chat: To add the bot to the group chat, you can use the Microsoft Graph API. You need to make a POST request to the /chats/{chat-id}/members
endpoint with the Bot ID in the request body.
Send a message using the bot: To send a message using the bot, you can use the Bot Framework SDK for Python. You need to create a message activity and send it to the group chat using the chat ID.
Here's a sample code snippet to send a message using the bot:
from botbuilder.core import TurnContext
async def send_message(turn_context: TurnContext):
message = MessageFactory.text("Hello, I'm your bot!")
await turn_context.send_activity(message)
Ref Doc:
- https://learn.microsoft.com/en-us/microsoftteams/platform/sbs-teams-conversation-bot?tabs=dev
- https://learn.microsoft.com/en-us/graph/api/resources/chat?view=graph-rest-1.0
Thanks,
Nivedipa
If the response is helpful, please click "Accept Answer" and upvote it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate.