Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed the samples #1516

Merged
merged 7 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -15,7 +15,7 @@
/// </summary>
public class RootDialog : ComponentDialog
{
private readonly string _applicationBaseUrl;

Check warning on line 18 in samples/app-complete-sample/csharp/AppCompleteSample/src/dialogs/RootDialog.cs

View workflow job for this annotation

GitHub Actions / Build All "app-complete-sample" csharp

The field 'RootDialog._applicationBaseUrl' is never used

Check warning on line 18 in samples/app-complete-sample/csharp/AppCompleteSample/src/dialogs/RootDialog.cs

View workflow job for this annotation

GitHub Actions / Build All "app-complete-sample" csharp

The field 'RootDialog._applicationBaseUrl' is never used
protected readonly IStatePropertyAccessor<RootDialogState> _conversationState;
protected readonly IStatePropertyAccessor<PrivateConversationData> _privateState;
private readonly IOptions<AzureSettings> azureSettings;
Expand Down Expand Up @@ -104,7 +104,7 @@
else if (command == DialogMatches.MultiDialog2Match)
{
return await stepContext.BeginDialogAsync(
nameof(MultiDialog2));
nameof(ThumbnailcardDialog));
}
else if (command == DialogMatches.FecthLastExecutedDialogMatch)
{
Expand Down
24 changes: 16 additions & 8 deletions samples/bot-tag-mention/csharp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ This sample app demonstrates the use of tag mention funtionality in teams scope

The simplest way to run this sample in Teams is to use Teams Toolkit for Visual Studio.

1.Install Visual Studio 2022 Version 17.10 Preview 4 or higher Visual Studio
2.Install Teams Toolkit for Visual Studio Teams Toolkit extension
3.In the debug dropdown menu of Visual Studio, select Dev Tunnels > Create A Tunnel (set authentication type to Public) or select an existing public dev tunnel.
4.In the debug dropdown menu of Visual Studio, select default startup project > Microsoft Teams (browser)
5.In Visual Studio, right-click your TeamsApp project and Select Teams Toolkit > Prepare Teams App Dependencies
6.Using the extension, sign in with your Microsoft 365 account where you have permissions to upload custom apps.
7.Select Debug > Start Debugging or F5 to run the menu in Visual Studio.
8.In the browser that launches, select the Add button to install the app to Teams.
1. Install Visual Studio 2022 Version 17.10 Preview 4 or higher Visual Studio
2. Install Teams Toolkit for Visual Studio Teams Toolkit extension
3. In the debug dropdown menu of Visual Studio, select Dev Tunnels > Create A Tunnel (set authentication type to Public) or select an existing public dev tunnel.
4. In the debug dropdown menu of Visual Studio, select default startup project > Microsoft Teams (browser)
5. In Visual Studio, right-click your TeamsApp project and Select Teams Toolkit > Prepare Teams App Dependencies
6. Using the extension, sign in with your Microsoft 365 account where you have permissions to upload custom apps.
7. Select Debug > Start Debugging or F5 to run the menu in Visual Studio.
8. In the browser that launches, select the Add button to install the app to Teams.

If you do not have permission to upload custom apps (sideloading), Teams Toolkit will recommend creating and using a Microsoft 365 Developer Program account - a free program to get your own dev environment sandbox that includes Teams.

Expand Down Expand Up @@ -172,6 +172,14 @@ You can interact with this bot in Teams by sending it a message, or selecting a

**Team channel Scope**

**Create tags within the team channel**
To create tags in Microsoft Teams, follow these steps:

1. Select Teams on the left side of the app and choose the team you want to create tags for.
2. Click the "More options" button (three dots) next to the team name and select "Manage tags".
3. Click "Create tag" and provide a name, description, and assign team members to the tag .


1. **Show Welcome**
- **Result:** The bot will send the welcome card for you to interact with necessary commands
- **Valid Scopes:** team chat
Expand Down
7 changes: 7 additions & 0 deletions samples/bot-tag-mention/nodejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,13 @@ You can interact with this bot in Teams by sending it a message, or selecting a

**Team channel Scope**

**Create tags within the team channel**
To create tags in Microsoft Teams, follow these steps:

1. Select Teams on the left side of the app and choose the team you want to create tags for.
2. Click the "More options" button (three dots) next to the team name and select "Manage tags".
3. Click "Create tag" and provide a name, description, and assign team members to the tag.

1. **Show Welcome**
- **Result:** The bot will send the welcome card for you to interact with necessary commands
- **Valid Scopes:** team chat
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,34 @@ public async Task<ChatMessage> CreateChatMessageForChannel(TaskDetails taskDetai
chatMessage.HostedContents = chatMessageHostedContentsCollectionPage;
try
{
var channelMessage = await graphClientChat.Teams[taskDetails.teamId].Channels[taskDetails.channelId].Messages
.Request()
.AddAsync(chatMessage);
return channelMessage;
// First, get the list of channels to find the default channel ID
var channels = await graphClientChat.Teams[taskDetails.teamId].Channels
.Request()
.GetAsync();

// Assuming "General" is the name of the default channel
var defaultChannel = channels.CurrentPage.FirstOrDefault(c => c.DisplayName.Equals("General", StringComparison.OrdinalIgnoreCase));

if (defaultChannel != null)
{
// Add the message to the default channel
var createdMessage = await graphClientChat.Teams[taskDetails.teamId].Channels[defaultChannel.Id].Messages
.Request()
.AddAsync(chatMessage);

// Return the created message
return createdMessage;

}
}
catch(Exception e)
catch (ServiceException ex)
{
Console.WriteLine(e);
Console.WriteLine($"Error adding message: {ex.Message}");
// You might want to handle the error further here or return null

}
return null;

}

public async Task<ChatMessage> CreateChannelMessageAdaptiveCard(TaskDetails taskDetails, string accessToken)
Expand All @@ -56,103 +74,124 @@ public async Task<ChatMessage> CreateChannelMessageAdaptiveCard(TaskDetails task
var Card = new AdaptiveCard(new AdaptiveSchemaVersion("1.0"))
{
Body = new List<AdaptiveElement>()
{
new AdaptiveTextBlock()
{
Text="Here is Your Reservation Details:",
Weight = AdaptiveTextWeight.Bolder,
Size = AdaptiveTextSize.Large,
Id="taskDetails"
},
new AdaptiveTextBlock()
{
Text=taskDetails.reservationId,
Weight = AdaptiveTextWeight.Lighter,
Size = AdaptiveTextSize.Medium,
Id="taskTitle"
},
new AdaptiveTextBlock()
{
Text=taskDetails.DeployementTitle,
Weight = AdaptiveTextWeight.Lighter,
Size = AdaptiveTextSize.Medium,
Id="taskdesc"
},
new AdaptiveTextBlock()
{
Text=taskDetails.currentSlot,
Weight = AdaptiveTextWeight.Lighter,
Size = AdaptiveTextSize.Medium,
Id="taskslot"
}
}

{
new AdaptiveTextBlock()
{
Text = "Here is Your Reservation Details:",
Weight = AdaptiveTextWeight.Bolder,
Size = AdaptiveTextSize.Large,
Id = "taskDetails"
},
new AdaptiveTextBlock()
{
Text = taskDetails.reservationId,
Weight = AdaptiveTextWeight.Lighter,
Size = AdaptiveTextSize.Medium,
Id = "taskTitle"
},
new AdaptiveTextBlock()
{
Text = taskDetails.DeployementTitle,
Weight = AdaptiveTextWeight.Lighter,
Size = AdaptiveTextSize.Medium,
Id = "taskdesc"
},
new AdaptiveTextBlock()
{
Text = taskDetails.currentSlot,
Weight = AdaptiveTextWeight.Lighter,
Size = AdaptiveTextSize.Medium,
Id = "taskslot"
}
}
};


var chatMessage = new ChatMessage
{
Subject = "Reservation Activtity:",
Subject = "Reservation Activity:",
Body = new ItemBody
{
ContentType = BodyType.Html,
Content = "<attachment id=\"74d20c7f34aa4a7fb74e2b30004247c5\"></attachment>"
},
Attachments = new List<ChatMessageAttachment>()
{
new ChatMessageAttachment
{
Id = "74d20c7f34aa4a7fb74e2b30004247c5",
ContentType = "application/vnd.microsoft.card.adaptive",
ContentUrl = null,
Content = JsonConvert.SerializeObject(Card),
Name = null,
ThumbnailUrl = null
}
}
Attachments = new List<ChatMessageAttachment>
Pawank-MSFT marked this conversation as resolved.
Show resolved Hide resolved
{
new ChatMessageAttachment
{
Id = "74d20c7f34aa4a7fb74e2b30004247c5",
ContentType = "application/vnd.microsoft.card.adaptive",
ContentUrl = null,
Content = JsonConvert.SerializeObject(Card),
Name = null,
ThumbnailUrl = null
}
}
};

chatMessage.HostedContents = chatMessageHostedContentsCollectionPage;
var getChannelMessage = await graphClientChat.Teams[taskDetails.teamId].Channels[taskDetails.channelId].Messages
try
{
// First, get the list of channels to find the default channel ID
var channels = await graphClientChat.Teams[taskDetails.teamId].Channels
.Request()
.AddAsync(chatMessage);
return getChannelMessage;
.GetAsync();

// Assuming "General" is the name of the default channel
var defaultChannel = channels.CurrentPage.FirstOrDefault(c => c.DisplayName.Equals("General", StringComparison.OrdinalIgnoreCase));

if (defaultChannel != null)
{
// Add the message to the default channel
var createdMessage = await graphClientChat.Teams[taskDetails.teamId].Channels[defaultChannel.Id].Messages
.Request()
.AddAsync(chatMessage);

// Return the created message
return createdMessage; //

}
}
catch (ServiceException ex)
{
Console.WriteLine($"Error adding message: {ex.Message}");
// You might want to handle the error further here or return null

}
return null;

}

public async Task<ChatMessage> CreatePendingFinanceRequestCard(TaskDetails taskDetails, string accessToken)
public async Task<ChatMessage> CreatePendingFinanceRequestCard(TaskDetails taskDetails, string accessToken)
{
GraphServiceClient graphClientChat= SimpleGraphClient.GetGraphClient(accessToken);
GraphServiceClient graphClientChat = SimpleGraphClient.GetGraphClient(accessToken);
var Card = new AdaptiveCard(new AdaptiveSchemaVersion("1.0"))
{
Body = new List<AdaptiveElement>()
{
new AdaptiveTextBlock()
{
Text="Here is Your Task Details in Teams",
Weight = AdaptiveTextWeight.Bolder,
Size = AdaptiveTextSize.Large,
Id="taskDetails"
},
new AdaptiveTextBlock()
{
Text=taskDetails.title,
Weight = AdaptiveTextWeight.Lighter,
Size = AdaptiveTextSize.Medium,
Id="taskTitle"
},
new AdaptiveTextBlock()
{
Text=taskDetails.description,
Weight = AdaptiveTextWeight.Lighter,
Size = AdaptiveTextSize.Medium,
Id="taskdesc"
},
}

{
Jegadeesh-MSFT marked this conversation as resolved.
Show resolved Hide resolved
new AdaptiveTextBlock()
{
Text = "Here is Your Task Details in Teams",
Weight = AdaptiveTextWeight.Bolder,
Size = AdaptiveTextSize.Large,
Id = "taskDetails"
},
new AdaptiveTextBlock()
{
Text = taskDetails.title,
Weight = AdaptiveTextWeight.Lighter,
Size = AdaptiveTextSize.Medium,
Id = "taskTitle"
},
new AdaptiveTextBlock()
{
Text = taskDetails.description,
Weight = AdaptiveTextWeight.Lighter,
Size = AdaptiveTextSize.Medium,
Id = "taskdesc"
},
}
};


var chatMessage = new ChatMessage
{
Subject = null,
Expand All @@ -162,26 +201,54 @@ public async Task<ChatMessage> CreatePendingFinanceRequestCard(TaskDetails task
Content = "<attachment id=\"74d20c7f34aa4a7fb74e2b30004247c5\"></attachment>"
},
Attachments = new List<ChatMessageAttachment>()
{
new ChatMessageAttachment
{
Id = "74d20c7f34aa4a7fb74e2b30004247c5",
ContentType = "application/vnd.microsoft.card.adaptive",
ContentUrl = null,
Content = JsonConvert.SerializeObject(Card),
Name = null,
ThumbnailUrl = null
}
}
{
Pawank-MSFT marked this conversation as resolved.
Show resolved Hide resolved
new ChatMessageAttachment
{
Id = "74d20c7f34aa4a7fb74e2b30004247c5",
ContentType = "application/vnd.microsoft.card.adaptive",
ContentUrl = null,
Content = JsonConvert.SerializeObject(Card),
Name = null,
ThumbnailUrl = null
}
}
};

chatMessage.HostedContents = chatMessageHostedContentsCollectionPage;
var getChannelMessage = await graphClientChat.Teams[taskDetails.teamId].Channels[taskDetails.channelId].Messages

try
{
// First, get the list of channels to find the default channel ID
var channels = await graphClientChat.Teams[taskDetails.teamId].Channels
.Request()
.AddAsync(chatMessage);
return getChannelMessage;
.GetAsync();

// Assuming "General" is the name of the default channel
var defaultChannel = channels.CurrentPage.FirstOrDefault(c => c.DisplayName.Equals("General", StringComparison.OrdinalIgnoreCase));

if (defaultChannel != null)
{
// Add the message to the default channel
var createdMessage = await graphClientChat.Teams[taskDetails.teamId].Channels[defaultChannel.Id].Messages
.Request()
.AddAsync(chatMessage);

// Return the created message
return createdMessage; //

}
}
catch (ServiceException ex)
{
Console.WriteLine($"Error adding message: {ex.Message}");
// You might want to handle the error further here or return null

}
return null;
//return null; // Ensure a return value is provided here
}


public async Task<ChatMessage> CreateGroupChatMessage(TaskDetails taskDetails, string accessToken)
{
var graphClientChat = SimpleGraphClient.GetGraphClient(accessToken);
Expand Down
Loading
Loading