Notifications with sendActivityNotification API

Copper Contributor

 

Hi All,

 

I am using sendActivityNotification API to send activity feed notifications to a user. 

Sometimes API works fine and multiple times it gives errors related to "

Specified activity with type 'mldt_notify' could not be found in the app manifest' 

 

Cross-checked the manifest file, entry is present under activities. Attaching the section from the file.

 

"activities": {
"activityTypes": [
{
"type": "mldt_notify",
"description": "Notification",
"templateText": "MultiLine Message"
}
]
}
}

 

Not sure why it is failing, please suggest if I am doing something wrong.

 

Thanks,

Pratap

 

 

18 Replies
@Pratapkarn2186-Thanks for reporting your issue.
We will investigation this issue and get back to you.
@Sayali-MSFT: Is there anything else that can be done to figure out what is going wrong ??
We have already build a feature based on this approach, now we see API response is not consistent.

@Pratapkarn2186 - Can you please add {actor} in templateText section.

"activities": {
"activityTypes": [
{
"type": "mldt_notify",
"description": "Notification",
"templateText": "{actor} MultiLine Message"
}
]
}


You can refer here:
Send activity feed notifications to users in Microsoft Teams - Microsoft Graph | Microsoft Learn



hi @Sayali-MSFT, i tried as suggested by adding actor but the result is the same.

"message"=>"Specified activity with type 'mldt_notify' could not be found in the app manifest.", "innerError"=>{"date"=>"2022-09-20T10:42:10", "request-id"=>"010d297d-1b37-4c24-9735-895ed1ba0ccf", "client-request-id"=>"010d297d-1b37-4c24-9735-895ed1ba0ccf"

Thanks,
Pratap


@Pratapkarn2186 - Can you share the request and response for the API you are calling along with headers. You can skip access token information and also share the manifest.

Hi @sayali-MST, please find the details.

Request : https://graph.microsoft.com/v1.0/users/email address removed for privacy reasons/teamwork/sendActivi... --header 'Authorization: XXXXXXX' --header 'Content-Type: application/json' --header 'Accept: application/json'

Data : {"topic":{"source":"text","value":"New message","WebUrl":"https://teams.microsoft.com/l/entity/XXXX/YYY"},"activityType":"mldt_notify","previewText":{"content":"Check New Messaging"}}


Another observation API sometimes works and randomly gives below gives :

Application with AAD App Id 'XXXXXX' is not authorized to generate custom text notifications about '/v1.0/users/XXXXXX/teamwork/Microsoft.Teams.GraphSvc.sendActivityNotification' to the recipient. Ensure that the expected Teams app is installed in the target scope (user, team, or chat).

@Pratapkarn2186 - Could you please create a new app and install the app in relevant scope (teams or group chat) to make the API work.
Also the API requires few application level permissions to work.
While testing it using Graph Explorer, it will create its own app id that is not related to actual app, that's why it is causing forbidden error. Could you please try to test your API using Postman tool.

@Sayali-MSFT  

Screenshot 2022-09-26 at 3.25.48 PM.png

The app is published in personal scope, then I search for the application and just add.

 

I don't see any option for scope, but it says "works in Teams"

Screenshot 2022-09-27 at 9.30.02 AM.png


Is something else that needs to be done ??

@Pratapkarn2186 - Have you try to test your API using Postman tool?


@Sayali-MSFT: I tried with the postman and got an error.

API Request: https://graph.microsoft.com/v1.0/users/xxxxx/teamwork/sendActivityNotification

Response:

{
"error": {
"code": "Forbidden",
"message": "Application with AAD App Id 'xxxxxxx' is not authorized to generate custom text notifications about '/v1.0/users/xxxxx/teamwork/Microsoft.Teams.GraphSvc.sendActivityNotification' to the recipient. Ensure that the expected Teams app is installed in the target scope (user, team, or chat).",
"innerError": {
"date": "2022-09-27T07:59:00",
"request-id": "c52396c3-54cf-4050-b861-6ee5b102519c",
"client-request-id": "c52396c3-54cf-4050-b861-6ee5b102519c"
}
}
}
@Pratapkarn2186-Could you please share the manifest json , So that we can try it from our end and let you know.

@Sayali-MSFT 

Please find the manifest file.

 

{

  "$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.14/MicrosoftTeams.schema.json",

  "version": "1.0.1",

  "manifestVersion": "1.14",

  "id": "xxxxx-xxx-xxx-xxxx-vvvvvvvv",

  "packageName": "com.package.name",

  "name": {

    "short": "Vavmex-500",

    "full": ""

  },

  "developer": {

    "name": "xxxx",

    "mpnId": "",

    "websiteUrl": "https://xxxxx.ai",

    "privacyUrl": "https://xxxxx.ai",

    "termsOfUseUrl": "https://xxxx.ai/t&c"

  },

  "description": {

    "short": "Messaging App",

    "full": "Application is used to send and receive messages"

  },

  "icons": {

    "outline": "outline.png",

    "color": "color.png"

  },

  "accentColor": "#FFFFFF",

  "staticTabs": [

    {

      "entityId": "xxxxx-xxxx-xxxx-xxx-xxxxxxx",

      "name": "MultiLine",

      "contentUrl": "https://xxxxx.xxxxxx.net ",

      "scopes": [

        "personal"

      ]

    },

    {

      "entityId": "about",

      "scopes": [

        "personal"

      ]

    }

  ],

  "validDomains": [

    "xxxxx.xxxxx.net"

  ],

  "webApplicationInfo": {

    "id": "xxxxx-393c-xxxx-930b-xxxxxxxxx",

    "resource": "api://xxxxxx.xxxxx.net/xxxxx-393c-47c5-xxxx-xxxxx"

  },

  "isFullScreen": true,

  "activities": {

    "activityTypes": [

      {

        "type": "notify",

        "description": "Notification",

        "templateText": "MultiLine"

      }

    ]

  }

}

@Sayali-MSFT : App which is created in Azure need to be assigned to individual users ??

Screenshot 2022-09-28 at 10.05.39 AM.png


@Sayali-MSFT: Did you get a chance to look Manifest file.
We tried with the manifest you shared it worked for us. Also included the request body you shared and changed team and user id's it also worked.
Can you try to change id in your manifest and see all old instances are deleted.

Also got the related thread -
https://stackoverflow.com/questions/66346794/application-with-aad-app-id-is-not-authorized-to-genera...

@Sayali-MSFT  Did you do anything on the azure app i.e. assigning the app created to users ??

 

Pratapkarn2186_0-1664617214073.png

 

@Pratapkarn2186 -No need to assigning the app created to users.