Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,20 @@
Console.WriteLine(ex);
}

var installationId = "";

Check warning on line 90 in samples/graph-activity-feed/csharp/ActivityFeedNotification/Controllers/HomeController.cs

View workflow job for this annotation

GitHub Actions / Build All "graph-activity-feed" csharp

The variable 'installationId' is assigned but its value is never used

Check warning on line 90 in samples/graph-activity-feed/csharp/ActivityFeedNotification/Controllers/HomeController.cs

View workflow job for this annotation

GitHub Actions / Build All "graph-activity-feed" csharp

The variable 'installationId' is assigned but its value is never used


if (taskDetails.taskInfoAction == "customTopic")
{
ChatMessageHelper chatMessage = new ChatMessageHelper(_configuration);
var getChannelMessage = await chatMessage.CreateChatMessageForChannel(taskDetails, taskDetails.access_token);
//var getChannelMessage = await chatMessage.CreateChatMessageForChannel(taskDetails, taskDetails.access_token);
var requestBody = new Microsoft.Graph.Beta.Users.Item.Teamwork.SendActivityNotification.SendActivityNotificationPostRequestBody
{
Topic = new TeamworkActivityTopic
{
Source = TeamworkActivityTopicSource.Text,
Value = "Deployment Approvals Channel",
WebUrl = getChannelMessage.WebUrl
WebUrl = "https://teams.microsoft.com/l/entity/" + _configuration["AzureAd:MicrosoftAppId"]
},
ActivityType = "taskCreated",
PreviewText = new ItemBody
Expand All @@ -111,15 +111,15 @@
{
new Microsoft.Graph.Beta.Models.KeyValuePair
{
Name = "taskId",
Value = "12322",
Name = "taskName",
Value = taskDetails.taskName ?? "New Task",
},
},
IconId = "taskCreatedId"
};
try
{
await graphClient.Users["{userId}"].Teamwork
await graphClient.Users[_configuration["AzureAd:UserId"]].Teamwork
.SendActivityNotification.PostAsync(requestBody);
}
catch (Exception ex)
Expand Down Expand Up @@ -148,14 +148,14 @@
new KeyValuePair
{
Name = "taskName",
Value = "12322",
Value = taskDetails.taskName ?? "New Task",
},
},
IconId = "taskCreatedId"
};
try
{
await graphClient.Users["{userId}"].Teamwork
await graphClient.Users[_configuration["AzureAd:UserId"]].Teamwork
.SendActivityNotification.PostAsync(requestBody);
}
catch (Exception ex)
Expand Down Expand Up @@ -194,7 +194,7 @@
Recipient = new AadUserNotificationRecipient
{
OdataType = "microsoft.graph.aadUserNotificationRecipient",
UserId = "{userId}",
UserId = _configuration["AzureAd:UserId"],
},
TemplateParameters = new List<KeyValuePair>
{
Expand Down Expand Up @@ -233,7 +233,7 @@
Recipient = new AadUserNotificationRecipient
{
OdataType = "microsoft.graph.aadUserNotificationRecipient",
UserId = "{userid}",
UserId = _configuration["AzureAd:UserId"],
},
TemplateParameters = new List<KeyValuePair>
{
Expand Down Expand Up @@ -378,7 +378,7 @@
Recipient = new AadUserNotificationRecipient
{
OdataType = "microsoft.graph.aadUserNotificationRecipient",
UserId = "{userId}",
UserId = _configuration["AzureAd:UserId"],
},
TemplateParameters = new List<KeyValuePair>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"TenantId": "common",
"TenantId": "{TENANT_ID}",
"MicrosoftAppId": "",
"MicrosoftAppPassword": "",
"ApplicationIdURI": "api://{Base_URL}/{MicrosoftAppId}",
"AuthUrl": "/oauth2/v2.0/token",
"ValidIssuers": "https://login.microsoftonline.com/TENANT_ID/v2.0,https://sts.windows.net/TENANT_ID/"
"ValidIssuers": "https://login.microsoftonline.com/TENANT_ID/v2.0,https://sts.windows.net/TENANT_ID/",
"UserId": ""
},
"Logging": {
"LogLevel": {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified samples/graph-activity-feed/csharp/Images/ActivityFeed.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
12 changes: 10 additions & 2 deletions samples/graph-activity-feed/csharp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,19 @@ Teams Activity feed notification API uses activity to which user want a notifica

## Running the sample

![image](Images/TeamsNotification.png)
![image](Images/1.PersonalNotfication.png)

![image](Images/2.ActivityNotificationForUser.png)

![image](Images/3.GroupChatCustom.png)

![image](Images/4.NotificationInGroupChat.png)

![image](Images/5.TeamsNotification.png)

- Notification triggred by Tab App will appear in Teams Activity Feed

![image](Images/ActivityFeedNotification.png)
![image](Images/6.ActivityFeedNotification.png)


**Custom Activity Icons**
Expand Down
11 changes: 7 additions & 4 deletions samples/graph-activity-feed/nodejs/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
ClientId =
ClientSecret =
TenantId =
AllowedHosts = *
ClientId=
ClientSecret=
TenantId=
AllowedHosts=*
applicationIdUri=
UserId=
TeamsAppId=
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified samples/graph-activity-feed/nodejs/Images/activity-feed.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified samples/graph-activity-feed/nodejs/Images/feed-group-config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified samples/graph-activity-feed/nodejs/Images/feed-group-page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified samples/graph-activity-feed/nodejs/Images/feed-team-config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified samples/graph-activity-feed/nodejs/Images/feed-team-notify.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified samples/graph-activity-feed/nodejs/Images/feed-team-page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 13 additions & 1 deletion samples/graph-activity-feed/nodejs/aad.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
{
"id": "TeamsTab.Read.All",
"type": "Scope"
},
{
"id": "Directory.Read.All",
"type": "Role"
}
]
}
Expand Down Expand Up @@ -130,7 +134,15 @@
"type": "Spa"
},
{
"url": "${{TAB_ENDPOINT}}/auth-end",
"url": "${{TAB_ENDPOINT}}/UserNotification",
"type": "Spa"
},
{
"url": "${{TAB_ENDPOINT}}/GroupChatNotification",
"type": "Spa"
},
{
"url": "${{TAB_ENDPOINT}}/TeamNotification",
"type": "Spa"
}
]
Expand Down
9 changes: 8 additions & 1 deletion samples/graph-activity-feed/nodejs/appManifest/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@
{
"type": "deploymentApprovalRequired",
"description": "New deployment requires your approval",
"templateText": "New deployment requires your approval with {deploymentId}"
"templateText": "New deployment requires your approval with {deploymentId}",
"allowedIconIds": [
"deploymentApprovalRequiredId"
]
},
{
"type": "approvalRequired",
Expand Down Expand Up @@ -100,6 +103,10 @@
"id": "taskCreatedId",
"iconFile": "exclaim.png"
},
{
"id": "deploymentApprovalRequiredId",
"iconFile": "deploymentApprovalRequired.png"
},
{
"id": "approvalRequiredId",
"iconFile": "approvalRequired.png"
Expand Down
61 changes: 61 additions & 0 deletions samples/graph-activity-feed/nodejs/build-app-package.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
const fs = require('fs');
const path = require('path');
const archiver = require('archiver');

// Create build directory if it doesn't exist
const buildDir = path.join(__dirname, 'appManifest', 'build');
if (!fs.existsSync(buildDir)) {
fs.mkdirSync(buildDir, { recursive: true });
}

// Read the manifest file
const manifestPath = path.join(__dirname, 'appManifest', 'manifest.json');
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));

// Replace environment variables in manifest
const envReplacements = {
'{{TEAMS_APP_ID}}': process.env.TEAMS_APP_ID || 'placeholder-teams-app-id',
'{{TAB_DOMAIN}}': process.env.TAB_DOMAIN || 'placeholder-domain',
'{{AAD_APP_CLIENT_ID}}': process.env.AAD_APP_CLIENT_ID || 'placeholder-client-id',
'{{TEAMSFX_ENV}}': process.env.TEAMSFX_ENV || 'local'
};

let manifestString = JSON.stringify(manifest, null, 2);
Object.entries(envReplacements).forEach(([placeholder, value]) => {
manifestString = manifestString.replace(new RegExp(`\\$\\{\\{${placeholder.slice(2, -2)}\\}\\}`, 'g'), value);
});

// Write the processed manifest
const outputManifestPath = path.join(buildDir, `manifest.${process.env.TEAMSFX_ENV || 'local'}.json`);
fs.writeFileSync(outputManifestPath, manifestString);

// Create the zip file
const outputZipPath = path.join(buildDir, `appManifest.${process.env.TEAMSFX_ENV || 'local'}.zip`);
const output = fs.createWriteStream(outputZipPath);
const archive = archiver('zip', { zlib: { level: 9 } });

output.on('close', () => {
console.log(`App package created: ${outputZipPath} (${archive.pointer()} total bytes)`);
});

archive.on('error', (err) => {
throw err;
});

archive.pipe(output);

// Add manifest file
archive.file(outputManifestPath, { name: 'manifest.json' });

// Add all PNG files from appManifest directory
const appManifestDir = path.join(__dirname, 'appManifest');
const files = fs.readdirSync(appManifestDir);
files.forEach(file => {
if (file.endsWith('.png')) {
const filePath = path.join(appManifestDir, file);
archive.file(filePath, { name: file });
console.log(`Added icon: ${file}`);
}
});

archive.finalize();
10 changes: 4 additions & 6 deletions samples/graph-activity-feed/nodejs/m365agents.local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,11 @@ provision:
# Path to manifest template
manifestPath: ./appManifest/manifest.json

# Build Teams app package with latest env value
- uses: teamsApp/zipAppPackage
# Build Teams app package manually to ensure all icons are included
- uses: cli/runNpmCommand
with:
# Path to manifest template
manifestPath: ./appManifest/manifest.json
outputZipPath: ./appManifest/build/appManifest.${{TEAMSFX_ENV}}.zip
outputJsonPath: ./appManifest/build/manifest.${{TEAMSFX_ENV}}.json
workingDirectory: .
args: run build:app-package
# Validate app package using validation rules
- uses: teamsApp/validateAppPackage
with:
Expand Down
Loading
Loading