Skip to content

Commit

Permalink
Merge pull request #844 from OfficeDev/v-harikrishnan/bot-task-module
Browse files Browse the repository at this point in the history
Fixed Bot-Task-Module Sample Issues
  • Loading branch information
Prithvi-MSFT authored Jul 3, 2023
2 parents 859cc9c + 3e01334 commit 1227bf2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
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}`
}

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

0 comments on commit 1227bf2

Please sign in to comment.