MicrosoftDocs / msteams-docs

Source for the Microsoft Teams developer platform documentation.
https://aka.ms/teamsdev
Creative Commons Attribution 4.0 International
288 stars 511 forks source link

Confusion around Task.startTask submitHandler for a tab app #10157

Open eoinobrien opened 10 months ago

eoinobrien commented 10 months ago

I'm looking at the docs and I'm not sure if I am confused or if there is a contradiction.

Near the top of the page it says:

There's no JavaScript submitHandler function to call when the user closes or presses a button on the Adaptive Card. The only way to receive what the user entered is by passing the result to a bot. To use an Adaptive Card task module from a tab, your app must include a bot to get any response from the user.

But towards the bottom there is a section titled "Adaptive Card TaskInfo.card", which has the following code snippet:

submitHandler = (err, result) => { console.log(Submit handler - err: ${err}); alert( "Result = " + JSON.stringify(result) + "\nError = " + JSON.stringify(err) ); }; microsoftTeams.tasks.startTask(taskInfo, submitHandler);

Which seems to indicate that there is a "JavaScript submitHandler function to call when the user closes or presses a button on the Adaptive Card".

Which is correct?

Also I have used this submitHandler before without using a bot so can you explain why the docs say "app must include a bot to get any response from the user" or is that a bug that it is possible in the code.


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

microsoft-github-policy-service[bot] commented 10 months ago

Hi eoinobrien! Thank you for bringing this issue to our attention. We will investigate and if we require further information we will reach out in one business day. Please use this link to escalate if you don't get replies.

Best regards, Teams Platform

ChetanSharma-msft commented 10 months ago

Hello @eoinobrien - Thanks for raising your query. We will look into it and let you know the updates.

ChetanSharma-msft commented 10 months ago

Sorry for delay in response. We are looking into it and let you know the updates.

Update: @eoinobrien - We have investigated your issue and please find below result:

Steps followed: 1) Setup the sample: https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/bot-task-module/nodejs 2) Tested the functionality from Bot and Tab:

3) If we submit the data from Task Module with Adaptive Card via clicking on the submit button, it will call the bot method async handleTeamsTaskModuleSubmit(context, taskModuleRequest) and later it will call the callback to submitHander which is by design behaviour.

Reference doc: https://learn.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/task-modules/task-modules-tabs?tabs=teamsjs1%2Cteamsjs3#adaptive-card-taskinfocard

4) If we submit the data from Task Module with custom form, ideally it should call the submit handler with object or string but it's working only if we are calling microsoftTeams.tasks.submitTask() with empty value. (It should work with object or string as well)

In other cases (Passing object or string) it is actually calling the bot method async handleTeamsTaskModuleSubmit(context, taskModuleRequest) even if we are not passing the botid.

So, looks like bot id is not compulsory to pass but this permits Teams to validate that the app sending the result is same as the invoked task module.

We will check below with engineering team: 1) Why submit handler is not calling for microsoftTeams.tasks.submitTask(customerInfo) where it is currently calling bot method async handleTeamsTaskModuleSubmit(context, taskModuleRequest)

2) Why bot-id is compulsory to handle custom form related submitted data at bot method side, rather than calling submithandler callback.

We will check with engineering team and let you know the updates.

ChetanSharma-msft commented 10 months ago

We have raised the bug for it and informed engineering team. We will let you know the updates if we have any.