Skip to content

Commit

Permalink
Merge pull request #1169 from OfficeDev/V-jegadeesh/bot-config-welcome
Browse files Browse the repository at this point in the history
Bot configuration - Welcome card addition
  • Loading branch information
Pawank-MSFT authored Mar 21, 2024
2 parents 66b86fb + e65dff2 commit 75ce26b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 14 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 36 additions & 14 deletions samples/bot-configuration-app/nodejs/teamsBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,38 @@
// Licensed under the MIT License.

const { TeamsActivityHandler, CardFactory } = require("botbuilder");
const fs = require('fs');
class TeamsBot extends TeamsActivityHandler {
constructor() {
super();
this.onMembersAdded(async (context, next) => {
const membersAdded = context.activity.membersAdded;
for (let member = 0; member < membersAdded.length; member++) {
if (membersAdded[member].id !== context.activity.recipient.id) {
await context.sendActivity("Hello and welcome! With this sample you can see the functionality of bot configuration");
}
}
const imagePath = 'Images/configbutton.png';
const imageBase64 = fs.readFileSync(imagePath, 'base64');
const card = CardFactory.adaptiveCard({
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "TextBlock",
"text": "Hello and welcome! With this sample, you can experience the functionality of bot configuration. To access Bot configuration, click on the settings button in the bot description card.",
"wrap": true,
"size": "large",
"weight": "bolder"
},
{
"type": "Image",
"url": `data:image/jpeg;base64,${imageBase64}`,
"size": "auto"
}
],
"fallbackText": "This card requires Adaptive Card support."
});

await context.sendActivity({
text: '',
attachments: [card]
});

await next();
});
Expand Down Expand Up @@ -62,15 +84,15 @@ class TeamsBot extends TeamsActivityHandler {
*/
const adaptiveCard = CardFactory.adaptiveCard(this.adaptiveCardForContinue());
response = {
config: {
value: {
card: adaptiveCard,
height: 200,
width: 200,
title: 'test card',
},
type: 'continue',
config: {
value: {
card: adaptiveCard,
height: 200,
width: 200,
title: 'test card',
},
type: 'continue',
},
};
return response;
}
Expand Down

0 comments on commit 75ce26b

Please sign in to comment.