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 Bot-Task-Module Sample Issues #844

Merged
merged 2 commits into from
Jul 3, 2023
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
7 changes: 7 additions & 0 deletions samples/bot-task-module/nodejs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,10 @@ server.post('/api/messages', async (req, res) => {
server.get('/*', restify.plugins.serveStatic({
directory: './pages'
}));

server.get('/getAppConfig', (req, res,next) => {
var responseMessageData = {
MicrosoftAppId: process.env.MicrosoftAppId
}
res.send(responseMessageData);
});
6 changes: 4 additions & 2 deletions samples/bot-task-module/nodejs/pages/CustomForm.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<script src="https://statics.teams.cdn.office.net/sdk/v1.5.2/js/MicrosoftTeams.min.js" asp-append-version="true"></script>
</head>
<body class="theme-light">
<div class="surface">
<div class="surface" style="height:max-content;">
<div class="panel">

<html>
Expand All @@ -27,12 +27,14 @@
<script>
microsoftTeams.initialize();
function validateForm() {
fetch(`${window.location.origin}/getAppConfig`).then(response => response.json()).then(data => {
var customerInfo = {
name: document.forms["customerForm"]["name"].value,
email: document.forms["customerForm"]["email"].value,
favoriteBook: document.forms["customerForm"]["favoriteBook"].value
}
microsoftTeams.tasks.submitTask(customerInfo, "<<YOUR-MICROSOFT-APP-ID>>");
microsoftTeams.tasks.submitTask(customerInfo, data.MicrosoftAppId);
});
return true;
}
</script>
Expand Down
13 changes: 7 additions & 6 deletions samples/bot-task-module/nodejs/pages/TaskModuleTab.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
//- Copyright (c) Microsoft Corporation.
//- All rights reserved.

// microsoftTeams app Initilize
microsoftTeams.app.initialize().then(() => {
microsoftTeams.app.initialize().then(() => {
var taskModuleButtons = document.getElementsByClassName("taskModuleButton");
if (taskModuleButtons.length > 0) {
fetch(`${window.location.origin}/getAppConfig`).then(response => response.json()).then(data => {

//config your appid and baseurl
var config = {
MicrosoftAppID: "<<Microsoft-App-ID>>",
BaseUrl: "<<BaseUrl>>"
MicrosoftAppID: data.MicrosoftAppId,
BaseUrl: `${window.location.origin}`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it work in Desktop and mobile clients? ${window.location.origin}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Harikrishnan-MSFT - Please run build pipeline as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is working in Desktop clients.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

var taskInfo_1 = {
Expand Down Expand Up @@ -221,7 +221,7 @@ microsoftTeams.app.initialize().then(() => {
};

//Allows app to open a url based dialog.
microsoftTeams.dialog.open(taskInfo_1, submitHandler);
microsoftTeams.tasks.startTask(taskInfo_1, submitHandler);
break;

case TaskModuleIds.AdaptiveCard1:
Expand Down Expand Up @@ -249,5 +249,6 @@ microsoftTeams.app.initialize().then(() => {
console.log("URL: " + taskInfo_1.url);
});
}
});
}
});
});
2 changes: 1 addition & 1 deletion samples/bot-task-module/nodejs/pages/taskmodule.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<button class="taskModuleButton button-primary" id="adaptivecard1">Adaptive Card (results &rarr; tab)</button>
<p></p>
<p></p>
<div><a id="deeplink" target="_blank" )>Deep Link</a></div>
<div><a id="deeplink" target="_blank" >Deep Link</a></div>
</div>
</p>

Expand Down