Skip to content

Commit

Permalink
Merge pull request #1488 from OfficeDev/v-mfurquan/Ajay-Sample-Fixes
Browse files Browse the repository at this point in the history
Ajay's Sample Health Check-Up And Fixes
  • Loading branch information
Pawank-MSFT authored Jan 4, 2025
2 parents 67be144 + bff99c2 commit 24473bb
Show file tree
Hide file tree
Showing 25 changed files with 139 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,20 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<script>
microsoftTeams.app.initialize().then(() => {
function ssoLogin(){
microsoftTeams.authentication.notifySuccess('sso');
}
function facebookLogin() {
microsoftTeams.authentication.notifySuccess('facebooklogin');
}
function usingCredentialsLogin() {
microsoftTeams.authentication.notifySuccess('usercredentials');
}
});
function ssoLogin(){
microsoftTeams.authentication.notifySuccess('sso');
}
function facebookLogin() {
microsoftTeams.authentication.notifySuccess('facebooklogin');
}
function usingCredentialsLogin() {
microsoftTeams.authentication.notifySuccess('usercredentials');
}
</script>

<style>
Expand Down
10 changes: 10 additions & 0 deletions samples/app-complete-auth/nodejs/bots/teamsBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,16 @@ class TeamsBot extends DialogBot {
type: 'AdaptiveCard',
version: '1.4'
});

async handleTeamsSigninVerifyState(context, query) {
console.log('Running dialog with signin/verifystate from an Invoke Activity.');
await this.dialog.run(context, this.dialogState);
}

async handleTeamsSigninTokenExchange(context, query) {
console.log('Running dialog with signin/tokenExchange from an Invoke Activity.');
await this.dialog.run(context, this.dialogState);
}
}

module.exports.TeamsBot = TeamsBot;
7 changes: 5 additions & 2 deletions samples/app-complete-auth/nodejs/views/config.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<script>
microsoftTeams.app.initialize().then(() => {
microsoftTeams.app.initialize().then(() => {
});
function ssoLogin(){
microsoftTeams.authentication.notifySuccess('sso');
}
Expand All @@ -17,7 +20,7 @@
function usingCredentialsLogin() {
microsoftTeams.authentication.notifySuccess('usercredentials');
}
});
</script>

<style>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,11 @@
"type": "Scope"
},
{
"id": "AccessReview.ReadWrite.All",
"id": "TeamsAppInstallation.ReadWriteAndConsentForTeam",
"type": "Scope"
},
{
"id": "Mail.Read",
"type": "Scope"
},
{
"id": "Mail.Send",
"type": "Scope"
},
{
"id": "openid",
"type": "Scope"
},
{
"id": "profile",
"type": "Scope"
},
{
"id": "User.ReadBasic.All",
"id": "TeamsAppInstallation.ReadWriteAndConsentSelfForTeam",
"type": "Scope"
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class ActivityBot : TeamsActivityHandler
public ActivityBot(IConfiguration configuration)
{
_applicationBaseUrl = configuration["ApplicationBaseUrl"] ?? throw new NullReferenceException("ApplicationBaseUrl");
_microsoftAppId= configuration["MicrosoftAppId"] ?? throw new NullReferenceException("MicrosoftAppId");
_microsoftAppId= configuration["TeamsAppId"] ?? throw new NullReferenceException("TeamsAppId");
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"MicrosoftAppId": "<<Microsoft-App-Id>>",
"MicrosoftAppPassword": "<<Microsoft-App-Password>>",
"ApplicationBaseUrl": "<<Application-Base-Url>>"
"MicrosoftAppId": "",
"MicrosoftAppPassword": "",
"ApplicationBaseUrl": "",
"TeamsAppId": ""
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ provision:
MicrosoftAppId: ${{AAD_APP_CLIENT_ID}}
MicrosoftAppPassword: ${{SECRET_AAD_APP_CLIENT_SECRET}}
ApplicationBaseUrl: ${{BOT_ENDPOINT}}
TeamsAppId: ${{TEAMS_APP_ID}}

- uses: arm/deploy # Deploy given ARM templates parallelly.
with:
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ async def _mention_adaptive_card_activity(self, turn_context: TurnContext):
for e in template_json["msteams"]["entities"]:
e["text"] = e["text"].replace("${userName}", member.name)
e["mentioned"]["id"] = e["mentioned"]["id"].replace("${userUPN}", member.user_principal_name)
e["mentioned"]["id"] = e["mentioned"]["id"].replace("${userAAD}", member.additional_properties["aadObjectId"])
e["mentioned"]["id"] = e["mentioned"]["id"].replace("${userAAD}", member.aad_object_id)
e["mentioned"]["name"] = e["mentioned"]["name"].replace("${userName}", member.name)

adaptive_card_attachment = Activity(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"type": "AdaptiveCard",
"$schema": "https://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.5",
"body": [
{
"size": "ExtraLarge",
"text": "Country Picker",
"weight": "Bolder",
"wrap": true,
"type": "TextBlock"
},
{
"id": "choiceSelect",
"type": "Input.ChoiceSet",
"label": "Select a country or region:",
"choices": [
{
"title": "USA",
"value": "usa"
},
{
"title": "France",
"value": "france"
},
{
"title": "India",
"value": "india"
}
],
"valueChangedAction": {
"type": "Action.ResetInputs",
"targetInputIds": [
"city"
]
},
"isRequired": true,
"errorMessage": "Please select a country or region"
},
{
"style": "filtered",
"choices.data": {
"type": "Data.Query",
"dataset": "cities",
"associatedInputs": "auto"
},
"id": "city",
"type": "Input.ChoiceSet",
"label": "Select a city:",
"placeholder": "Type to search for a city in the selected country",
"isRequired": true,
"errorMessage": "Please select a city"
}
],
"actions": [
{
"title": "Submit",
"type": "Action.Submit"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class AppCatalogHelper {
return new Promise(async (resolve) => {

// read a zip file
let response = fs.readFile("Manifest/manifest.zip", async (err, data) => {
let response = fs.readFile("appManifest/build/appManifest.local.zip", async (err, data) => {
if (err) throw err;
await JSZip.loadAsync(data).then(async (zip) => {
if (headerType == 'publish') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ export class ReviewInMeeting extends Component {
this.initiateSSO = this.initiateSSO.bind(this);
}

componentDidMount() {
// Initialize teams library and set context.
this.initialize();
componentDidMount() {
// Initialize teams library and set context.
microsoftTeams.initialize();
microsoftTeams.getContext((context, error) => {
this.setState({ context: context });
});
microsoftTeams.appInitialization.notifySuccess();

// SSO.
this.initiateSSO();
Expand Down Expand Up @@ -63,19 +67,6 @@ export class ReviewInMeeting extends Component {
);
}

initialize() {
// Initialize the Microsoft Teams SDK
microsoftTeams.initialize(() => {
// Get the user context from Teams and set it in the state
microsoftTeams.getContext((context, error) => {
this.setState({ context: context });
});

// Notify sucess.
microsoftTeams.appInitialization.notifySuccess();
});
}

initiateSSO() {
// Get SSO token.
let authTokenRequestOptions = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@
]
}
],
"identifierUris":[
"api://botid-${{AAD_APP_CLIENT_ID}}"
],
"identifierUris": [
"api://${{BOT_DOMAIN}}/${{AAD_APP_CLIENT_ID}}"
],
"replyUrlsWithType": [
{
"url": "https://${{BOT_DOMAIN}}/auth-end",
Expand Down
10 changes: 5 additions & 5 deletions samples/tab-deeplink/csharp/DeepLinkBot/Bots/DeepLinkBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ public Attachment AdaptiveDeepLinkCard(string userName, ITurnContext turnContext
}
else
{
tabUrlTask1 = deeplinkHelper.GetDeepLinkToTabTask(teamsUrl, _configuration["ManifestAppId"], _configuration["TabEntityId"], "topic1");
tabUrlTask2 = deeplinkHelper.GetDeepLinkToTabTask(teamsUrl, _configuration["ManifestAppId"], _configuration["TabEntityId"], "topic2");
tabUrlTask3 = deeplinkHelper.GetDeepLinkToTabTask(teamsUrl, _configuration["ManifestAppId"], _configuration["TabEntityId"], "topic3");
extendedDeepLink = deeplinkHelper.GetDeepLinkToTabTask(teamsUrl, _configuration["ManifestAppId"], _configuration["TabEntityId"], "");
sidePanelLink = deeplinkHelper.GetDeepLinkToMeetingSidePanel(teamsUrl, _configuration["MicrosoftAppId"], _configuration["BaseURL"], _configuration["ChannelEntityId"], turnContext.Activity.Conversation.Id, "chat");
tabUrlTask1 = deeplinkHelper.GetDeepLinkToTabTask(teamsUrl, _configuration["TeamsAppId"], _configuration["TabEntityId"], "topic1");
tabUrlTask2 = deeplinkHelper.GetDeepLinkToTabTask(teamsUrl, _configuration["TeamsAppId"], _configuration["TabEntityId"], "topic2");
tabUrlTask3 = deeplinkHelper.GetDeepLinkToTabTask(teamsUrl, _configuration["TeamsAppId"], _configuration["TabEntityId"], "topic3");
extendedDeepLink = deeplinkHelper.GetDeepLinkToTabTask(teamsUrl, _configuration["TeamsAppId"], _configuration["TabEntityId"], "");
sidePanelLink = deeplinkHelper.GetDeepLinkToMeetingSidePanel(teamsUrl, _configuration["TeamsAppId"], _configuration["BaseURL"], _configuration["ChannelEntityId"], turnContext.Activity.Conversation.Id, "chat");
}

var DeepLinkCard = new AdaptiveCard(new AdaptiveSchemaVersion("1.0"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public ActionResult DeepLinkChannel()
channelDeeplinks.Add(task2ChannelLink);
channelDeeplinks.Add(task3ChannelLink);
}
ViewBag.AppId = _configuration["MicrosoftAppId"];
ViewBag.AppId = _configuration["TeamsAppId"];
return View(channelDeeplinks);
}

Expand Down
13 changes: 7 additions & 6 deletions samples/tab-deeplink/csharp/DeepLinkBot/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"MicrosoftAppId": "<<YOUR-MICROSOFT-APP-ID>>",
"MicrosoftAppPassword": "<<YOUR-MICROSOFT-APP-PASSWORD>>",
"BaseURL": "YOUR-BASE-URL",
"ChannelEntityId": "DeepLinkApp",
"TabEntityId": "com.contoso.DeeplLinkBot.help",
"ManifestAppId":"Your-ManifestAppID"
"TeamsAppId": "",
"MicrosoftAppId": "",
"MicrosoftAppPassword": "",
"BaseURL": "",
"ChannelEntityId": "DeepLinkApp",
"TabEntityId": "com.contoso.DeeplLinkBot.help",
"ManifestAppId": ""
}
1 change: 1 addition & 0 deletions samples/tab-deeplink/csharp/TeamsApp/teamsapp.local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ provision:
with:
target: ../DeepLinkBot/appsettings.json
content:
TeamsAppId: ${{TEAMS_APP_ID}}
MicrosoftAppId: ${{AAD_APP_CLIENT_ID}}
MicrosoftAppPassword: ${{SECRET_AAD_APP_CLIENT_SECRET}}
BaseURL: ${{BOT_DOMAIN}}
Expand Down
18 changes: 9 additions & 9 deletions samples/tab-deeplink/nodejs/Bots/DeepLinkTabsnode.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ class DeepLinkTabsnode extends TeamsActivityHandler {
let sidePanelLink = "";

if (context.activity.conversation.conversationType === "channel") {
var BotsDeepLink = DeepLinkTabHelper.GetDeepLinkTabChannel("topic1", 1, "Bots", context.activity.channelData.teamsChannelId, process.env.MicrosoftAppId, process.env.Channel_Entity_Id);
var MessagingDeepLink = DeepLinkTabHelper.GetDeepLinkTabChannel("topic2", 2, "Messaging Extension", context.activity.channelData.teamsChannelId, process.env.MicrosoftAppId, process.env.Channel_Entity_Id);
var AdaptiveCardDeepLink = DeepLinkTabHelper.GetDeepLinkTabChannel("topic3", 3, "Adaptive Card", context.activity.channelData.teamsChannelId, process.env.MicrosoftAppId, process.env.Channel_Entity_Id);
ExtendedDeepLink = DeepLinkTabHelper.GetDeepLinkTabChannel("", 4, "Extended Deeplink features", context.activity.channelData.teamsChannelId, process.env.MicrosoftAppId, process.env.Channel_Entity_Id);
var BotsDeepLink = DeepLinkTabHelper.GetDeepLinkTabChannel("topic1", 1, "Bots", context.activity.channelData.teamsChannelId, process.env.TeamsAppId, process.env.Channel_Entity_Id);
var MessagingDeepLink = DeepLinkTabHelper.GetDeepLinkTabChannel("topic2", 2, "Messaging Extension", context.activity.channelData.teamsChannelId, process.env.TeamsAppId, process.env.Channel_Entity_Id);
var AdaptiveCardDeepLink = DeepLinkTabHelper.GetDeepLinkTabChannel("topic3", 3, "Adaptive Card", context.activity.channelData.teamsChannelId, process.env.TeamsAppId, process.env.Channel_Entity_Id);
ExtendedDeepLink = DeepLinkTabHelper.GetDeepLinkTabChannel("", 4, "Extended Deeplink features", context.activity.channelData.teamsChannelId, process.env.TeamsAppId, process.env.Channel_Entity_Id);
}
else {
var BotsDeepLink = DeepLinkTabHelper.GetDeepLinkTabStatic("topic1", 1, "Bots", process.env.MicrosoftAppId);
var MessagingDeepLink = DeepLinkTabHelper.GetDeepLinkTabStatic("topic2", 2, "Messaging Extension", process.env.MicrosoftAppId);
var AdaptiveCardDeepLink = DeepLinkTabHelper.GetDeepLinkTabStatic("topic3", 3, "Adaptive Card", process.env.MicrosoftAppId);
ExtendedDeepLink = DeepLinkTabHelper.GetDeepLinkTabStatic("", 4, "Extended Deeplink features", process.env.MicrosoftAppId);
sidePanelLink = DeepLinkTabHelper.GetDeepLinkToMeetingSidePanel(5,"Side pannel Deeplink",process.env.MicrosoftAppId, process.env.Base_URL, context.activity.conversation.id, "chat");
var BotsDeepLink = DeepLinkTabHelper.GetDeepLinkTabStatic("topic1", 1, "Bots", process.env.TeamsAppId);
var MessagingDeepLink = DeepLinkTabHelper.GetDeepLinkTabStatic("topic2", 2, "Messaging Extension", process.env.TeamsAppId);
var AdaptiveCardDeepLink = DeepLinkTabHelper.GetDeepLinkTabStatic("topic3", 3, "Adaptive Card", process.env.TeamsAppId);
ExtendedDeepLink = DeepLinkTabHelper.GetDeepLinkTabStatic("", 4, "Extended Deeplink features", process.env.TeamsAppId);
sidePanelLink = DeepLinkTabHelper.GetDeepLinkToMeetingSidePanel(5,"Side pannel Deeplink",process.env.TeamsAppId, process.env.Base_URL, context.activity.conversation.id, "chat");
}

await context.sendActivity({ attachments: [this.createAdaptiveCard(conversationType, BotsDeepLink, MessagingDeepLink, AdaptiveCardDeepLink, ExtendedDeepLink, sidePanelLink)] });
Expand Down
1 change: 1 addition & 0 deletions samples/tab-deeplink/nodejs/teamsapp.local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ deploy:
with:
target: ./.env
envs:
TeamsAppId: ${{TEAMS_APP_ID}}
MicrosoftAppId: ${{AAD_APP_CLIENT_ID}}
MicrosoftAppPassword: ${{SECRET_AAD_APP_CLIENT_SECRET}}
Base_URL: ${{BOT_ENDPOINT}}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class ActivityBot : TeamsActivityHandler
/// <param name="configuration">configuration of application.</param>
public ActivityBot(IConfiguration configuration)
{
_appId = configuration["MicrosoftAppId"] ?? throw new NullReferenceException("MicrosoftAppId");
_appId = configuration["TeamsAppId"] ?? throw new NullReferenceException("MicrosoftAppId");
_applicationBaseURL = configuration["ApplicationBaseURL"] ?? throw new NullReferenceException("ApplicationBaseURL");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class HomeController : Controller
/// <param name="configuration">configuration of application.</param>
public HomeController(IConfiguration configuration)
{
_appId = configuration["MicrosoftAppId"] ?? throw new NullReferenceException("MicrosoftAppId");
_appId = configuration["TeamsAppId"] ?? throw new NullReferenceException("TeamsAppId");
}

[Route("")]
Expand Down
1 change: 1 addition & 0 deletions samples/tab-stage-view/csharp/TeamsApp/teamsapp.local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ provision:
MicrosoftAppId: ${{AAD_APP_CLIENT_ID}}
MicrosoftAppPassword: ${{SECRET_AAD_APP_CLIENT_SECRET}}
ApplicationBaseURL: ${{BOT_ENDPOINT}}
TeamsAppId: ${{TEAMS_APP_ID}}

- uses: arm/deploy # Deploy given ARM templates parallelly.
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const adaptiveCardForTabStageView = (baseUrlForOpenUrl) => ({
{
type: "Action.OpenUrl",
title: "View via Deep Link",
url: "https://teams.microsoft.com/l/stage/"+process.env.MicrosoftAppId+"/0?context=%7B%22contentUrl%22%3A%22https%3A%2F%2F"+baseUrlForOpenUrl+"%2Fcontent%22%2C%22websiteUrl%22%3A%22https%3A%2F%2F"+baseUrlForOpenUrl+"%2Fcontent%22%2C%22name%22%3A%22DemoStageView%22%7D"
url: "https://teams.microsoft.com/l/stage/"+process.env.TeamsAppId+"/0?context=%7B%22contentUrl%22%3A%22https%3A%2F%2F"+baseUrlForOpenUrl+"%2Fcontent%22%2C%22websiteUrl%22%3A%22https%3A%2F%2F"+baseUrlForOpenUrl+"%2Fcontent%22%2C%22name%22%3A%22DemoStageView%22%7D"
}
]
}
Expand Down
3 changes: 1 addition & 2 deletions samples/tab-stage-view/nodejs/server/views/sampleTab.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
microsoftTeams.app.initialize().then(() => {
});
function createLink() {
var appId = "<%-microsoftAppId%>";
var appId = "<%-teamsAppId%>";
var baseUrl = "<%-baseUrl%>";
// 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\":\""+baseUrl+"/content\",\"websiteUrl\":\""+baseUrl+"/content\",\"name\":\"DemoStageView\"}";
alert("URL - " + url);
microsoftTeams.app.openLink(url);
};
</script>
Expand Down
Loading

0 comments on commit 24473bb

Please sign in to comment.