Teams Bot's functionality without turn context

Jun 26 Reputation points
2022-12-02T22:51:34.883+00:00

Hello Microsoft community,

I want to create an application that can get list of members and channels of Teams, and send a notification message to user or channel upon trigger (coming from different service). I need to access multiple tenants (customers) upon their install or authorization.

It sounds like a webhook at first, but according to https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/what-are-webhooks-and-connectors, the webhook is not capable of receiving Teams context (e.g. get list of members/channels)

I also looked at using Graph API, but it appears sending message is only supported using delegated user, not with application permission, according to https://learn.microsoft.com/en-us/graph/api/chatmessage-post?view=graph-rest-1.0&tabs=http

I'm now looking at creating a Teams bot. It appeared https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/python/16.proactive-messages is close to what I need. But as I go through the SDK, turn context seems to be a fundamental. Meaning the user have created/initialized a conversation before. I want the bot to send notification without any previous history upon trigger.

Based on the above use-case, is Teams bot the way to go ? If so, is there any example of bot pulling Teams data and sending notification without turn context ? (assuming I know customers' tenant id). If not, what would be a recommended approach ?

Azure AI Bot Service
Azure AI Bot Service
An Azure service that provides an integrated environment for bot development.
746 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,592 questions
Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
2,846 questions
{count} votes

Accepted answer
  1. Nivedipa-MSFT 2,806 Reputation points Microsoft Vendor
    2022-12-05T05:21:39.637+00:00

    @Jun - Without turnContext you cannot send the notification.
    You must create the conversation before sending the message. For example, a new one-to-one chat or a new conversation thread in a channel.

    Using proactive messages you can send notifications.
    To send a proactive message, follow these steps:

    Get the user ID, team ID, or channel ID, if necessary.
    Create the conversation, if necessary.
    Get the conversation ID.
    Send the message.

    Please refer below proative messages samples.
    https://learn.microsoft.com/en-us/microsoftteams/platform/bots/how-to/conversations/send-proactive-messages?tabs=dotnet#code-sample

    Ref Doc: https://learn.microsoft.com/en-us/microsoftteams/platform/bots/how-to/conversations/send-proactive-messages?tabs=dotnet

    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.


0 additional answers

Sort by: Most helpful