Skip to content

Commit

Permalink
Merge pull request OfficeDev#1182 from OfficeDev/v-pritka/tab-stage-v…
Browse files Browse the repository at this point in the history
…iew-update

added changes for opening stage view through deep link
  • Loading branch information
Prithvi-MSFT authored Apr 16, 2024
2 parents ac2f441 + 3af1b13 commit 44a2ad3
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 9 deletions.
Binary file modified samples/bot-all-cards/csharp/demo-manifest/bot-all-cards.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class ActivityBot : TeamsActivityHandler
{
private readonly string _appId;
private readonly string _applicationBaseURL;
public static string _threadId;

/// <summary>
/// Initializes a new instance of the <see cref="ActivityBot"/> class.
Expand All @@ -45,6 +46,10 @@ public ActivityBot(IConfiguration configuration)
protected override async Task OnMembersAddedAsync(IList<ChannelAccount> membersAdded, ITurnContext<IConversationUpdateActivity> turnContext, CancellationToken cancellationToken)
{
var welcomeText = "Hello and welcome!, Please type any bot command to see the stage view feature";

// Set thread Id
_threadId = turnContext.Activity.Conversation.Id;

foreach (var member in membersAdded)
{
if (member.Id != turnContext.Activity.Recipient.Id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace TabInStageView.Models
{
using Newtonsoft.Json;
using System;

/// <summary>
/// Tab info action model class.
Expand All @@ -22,5 +23,16 @@ public class TabInfoAction
/// </summary>
[JsonProperty("tabInfo")]
public TabInfo TabInfo { get; set; }

/// <summary>
/// Gets or sets tab info.
/// </summary>
[JsonProperty("threadId")]
public string? ThreadId { get; set; } = string.Empty;

Check warning on line 31 in samples/tab-stage-view/csharp/TabInStageView/Models/TabInfoAction.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 31 in samples/tab-stage-view/csharp/TabInStageView/Models/TabInfoAction.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 31 in samples/tab-stage-view/csharp/TabInStageView/Models/TabInfoAction.cs

View workflow job for this annotation

GitHub Actions / Build All "tab-stage-view" csharp

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 31 in samples/tab-stage-view/csharp/TabInStageView/Models/TabInfoAction.cs

View workflow job for this annotation

GitHub Actions / Build All "tab-stage-view" csharp

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

public TabInfoAction()
{
ThreadId = "";
}
}
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,47 @@
<!DOCTYPE html>
@page
@model TabInStageView.Models.TabInfoAction

<!DOCTYPE html>
<html lang="en">

<head>
<script
src="https://res.cdn.office.net/teams-js/2.0.0/js/MicrosoftTeams.min.js"
integrity="sha384-QtTBFeFlfRDZBfwHJHYQp7MdLJ2C3sfAEB1Qpy+YblvjavBye+q87TELpTnvlXw4"
crossorigin="anonymous">
<script src="https://res.cdn.office.net/teams-js/2.8.0/js/MicrosoftTeams.min.js"
integrity="sha384-/DJ9oJEFZSpGiUQx9Na5Yb5svOPPqSb3khKxJ/YgoZ2GtrkzWgSTBpESy3LvMPVk"
crossorigin="anonymous">
</script>
<script>
microsoftTeams.app.initialize().then(() => {
});
// App Initilize
microsoftTeams.app.initialize();
function createLink() {
// Client id
var appId = '@(ViewBag.AppId)';
// Get thread id by this format "19:***********thread.v2";
var threadId = "@TabInStageView.Bots.ActivityBot._threadId";
// Application base url and this redirects to Index view
var contentUrl = window.location.origin;
var context = {
appId: appId,
contentUrl: contentUrl,
websiteUrl: contentUrl,
name: "DemoStageView",
openMode: "popoutWithChat",
threadId:threadId
}
const encodedContext = encodeURIComponent(JSON.stringify(context));
// Passing the values and encoding the url while implementing the deeplink from tab
let url = "https://teams.microsoft.com/l/stage/" + appId + "/0?context={\"contentUrl\":\"" + contentUrl + "\",\"websiteUrl\":\"" + contentUrl +"\",\"name\":\"DemoStageView\"}";
let url = "https://teams.microsoft.com/l/stage/" + appId + "/0?context=" + encodedContext;
console.log("eoncoded URL",url);
microsoftTeams.app.openLink(url);
};
};
</script>
</head>

Expand Down

0 comments on commit 44a2ad3

Please sign in to comment.