0

I'm calling microsoftTeams.tasks.submitTask() with some data from my Embedded Web View Task module like this:

var fsObj = {};
fsObj.name = "give me a file";          
microsoftTeams.tasks.submitTask(fsObj); 

This then arrives at my bot with the data and invokes the onTeamsMessagingExtensionSubmitAction event, which I've handled like this:

@Override
    protected CompletableFuture<MessagingExtensionActionResponse> onTeamsMessagingExtensionSubmitAction(TurnContext turnContext, MessagingExtensionAction action) {
                
        File filePath = new File("files", "10840-002.pdf");
        String filename = filePath.getName();
        long filesize = filePath.length();      
        
        Map<String, String> consentContext = new HashMap<>();
        consentContext.put("filename", filename);

        FileConsentCard fileCard = new FileConsentCard();
        fileCard.setDescription("Here is a file...");
        fileCard.setSizeInBytes(filesize);
        fileCard.setAcceptContext(consentContext);
        fileCard.setDeclineContext(consentContext);             

        MessagingExtensionAttachment asAttachment = new MessagingExtensionAttachment();
        asAttachment.setContent(fileCard);
        asAttachment.setContentType(FileConsentCard.CONTENT_TYPE);
        asAttachment.setName(filename);     
        
        MessagingExtensionResult msgExtRes = new MessagingExtensionResult();
        msgExtRes.setType("result");
        msgExtRes.setAttachmentLayout("list");
        msgExtRes.setAttachment(asAttachment);      
        
        MessagingExtensionActionResponse actionResponse = new MessagingExtensionActionResponse();
        actionResponse.setComposeExtension(msgExtRes);      
        
        return CompletableFuture.completedFuture(actionResponse);           
    }

This code runs, and my embedded web view Task Module then closes, but I do not see the file consent message in the chat.

I have successfully duplicated this File Upload bot example, where I'm able to get a file through when talking directly to my bot.

Is it possible to respond to the submit action invoked in my embedded web view with a FileConsentCard? If so, what am I missing in my response?

lfdevjmp
  • 3
  • 4
  • There doesn't seem to be anything missing from the response. It might not be possible to respond to the submit action invoked in embedded web view with a FileConsentCard – Prasad-MSFT Apr 12 '23 at 05:04
  • Can you suggest an alternative solution? I would like to trigger a file upload into the chat after a selection is made from my embedded web view Task Module. – lfdevjmp Apr 12 '23 at 14:31
  • Did you try using sendActivity method to send the card inside onTeamsTaskModuleSubmit as below? https://github.com/OfficeDev/Microsoft-Teams-Samples/blob/main/samples/bot-task-module/java/src/main/java/com/microsoft/bot/sample/teamstaskmodule/TeamsTaskModuleBot.java – Prasad-MSFT Apr 13 '23 at 07:49
  • Thanks for that. I was able to get a FileConsentCard through the onTeamsMessagingExtensionSubmitAction by modifying that logic. Now I'm having issues uploading a PDF using the UploadInfo UploadUrl. I've posted another question here on SF regarding that issue. Thanks again! – lfdevjmp Apr 14 '23 at 22:35

0 Answers0