Share via

Send activity feed without actor

David Cabielles Hernández 21 Reputation points
2022-02-22T17:16:27.79+00:00

Hello,

I'm developing a system of activity feed. It works like a charm if I use an accessToken of a logged user.
My main problem occurs because I need that the feeds would be send by the application (I don't want to see an avatar of a user or his info, just app info.).

I read here: https://learn.microsoft.com/en-us/graph/teams-send-activityfeednotifications that the actor depends on the calls, but I can't find in the documentation how to do a request without accessToken, just as an app. I need to send it to a Tab, no chat or Team.

I'm using the next endpoint:
https://graph.microsoft.com/v1.0/users/{RECEIVER ID}/teamwork/sendActivityNotification

With the next body:

{  
    "topic": {  
        "source": "entityUrl",  
        "value":  
        "https://graph.microsoft.com/v1.0/users/{RECEIVER ID}/teamwork/installedApps/{INSTALLED APP ID}"  
    },  
    "activityType": "taskCreated",  
    "previewText": {  
        "content": "New Task Created"  
    },  
    "templateParameters": [  
        {  
        "name": "taskId",  
        "value": "Task 12322"  
        }  
    ]  
}  

My permission for TeamsActivity.Send are of kind Application (not delegated).

So my question is, how can I send an activity feed as an application (NO as a user)?

Thank you very much for you help!

Microsoft Teams | Development
Microsoft Teams | Development

Building, integrating, or customizing apps and workflows within Microsoft Teams using developer tools and APIs

Microsoft Security | Microsoft Graph
Microsoft Teams | Microsoft Teams for business | Other

1 answer

Sort by: Most helpful
  1. Sayali-MSFT 5,771 Reputation points Microsoft External Staff Moderator
    2022-02-23T11:22:20.14+00:00

    To access the activity feed, you will need to use a Bot. Also, you can send notification only for message/card sent in 1:1 chat conversation.

    If your bot posts cards/messages into a channel, they'll automatically show up in the user's feed if user has followed that channel.

    Sample code to Starting personal conversations

      var parameters = new ConversationParameters  
            {  
                Members = new ChannelAccount[] { new ChannelAccount(userId) },  
                ChannelData = new TeamsChannelData  
                {  
                    Tenant = new TenantInfo(tenantId),  
                    Notification = new NotificationInfo() { Alert = true }  
                }  
            };  
      
             MicrosoftAppCredentials.TrustServiceUrl(serviceUrl, DateTime.MaxValue);  
            var connectorClient = new ConnectorClient(new Uri(activity.ServiceUrl));  
            var response = await connectorClient.Conversations.CreateConversationAsync(parameters);  
    

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.