Search code examples
botframeworkmicrosoft-teams

Clickable activity feed notifications


We have built a custom bot service app which leverages the REST endpoints provided by the BotFramework as well as a few graph api calls.

The Graph API documents the ability to send activity feed notifications, which we have working fine.

Is there any way to make the notifications clickable so that they are more useful? Originally I assumed the webUrl key/val in the topic could accomplish this goal, but whether using the commented out code (running in a function so it is valid in .js files) or the one below, nothing occurs when the person clicks.

Tips? Suggestions? Are we misunderstanding the capabilities of activity feed notifications?

We are delivering the following payload via the graph api to /appCatalogs/teamsApps/${this.Config.TEAMS_APP_EXTERNAL}

While the notifications do arrive and do everything they should do, when clicking on the notification, it doesn't take them anywhere.

{
      topic: {
        // source: 'entityUrl',
        // value: `https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/${this.Config.TEAMS_APP_EXTERNAL}`
        source: 'text',
        value: 'I am the source',
        webUrl: 'https://teams.microsoft.com/l/message/'
      },
      activityType: 'generic',
      previewText: {
        content
      },
      recipients: [
        {
          '@odata.type': 'microsoft.graph.aadUserNotificationRecipient',
          userId
        }
      ],
      templateParameters: [
        {
          name: 'text',
          value
        }
      ]
    }

Solution

  • You can include a deep link in the webUrl property of the notification payload to make activity feed notifications clickable.

    In your code snippet, you have set the webUrl property to 'https://teams.microsoft.com/l/message/'. This URL does not provide any specific destination or content for the user to navigate to.

    You need to replace this URL with a valid deep link that corresponds to the desired location or content within your app.

    webUrl: 'https://teams.microsoft.com/l/entity/{appId}/{entityId}?webUrl={encodedWebUrl}'
    

    {appId}: The ID of your Teams app. You can find this in the Teams admin center.

    {entityId}: The ID of the specific entity or content within your app that you want to navigate to.

    {encodedWebUrl}: The URL-encoded version of the web URL that you want to open when the user clicks on the notification.

    For example, if you want to navigate to a specific page in your app with the URL https://example.com/myapp/page1, you can construct the deep link URL as follows:

    webUrl: 'https://teams.microsoft.com/l/entity/{appId}/{entityId}?webUrl=https%3A%2F%2Fexample.com%2Fmyapp%2Fpage1'
    

    By including a valid deep link in the webUrl property, clicking on the activity feed notification will take the user to the specified location or content within your app.