I have a simple Adaptive Card returning into the Teams chat from a TeamsActivityHandler.onMessageActivity override:
@Override
protected CompletableFuture<Void> onMessageActivity(TurnContext turnContext) {
String text = turnContext.getActivity().getText().trim().toLowerCase();
if(text.contains("calendar")){
File filePath = new File(this.teamsPath, "calCard.json");
try (InputStream inputStream = new FileInputStream(filePath)) {
String result = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
return turnContext.sendActivity( MessageFactory.attachment(adaptiveCardAttachmentFromJson(result)) )
.thenApply(resourceResponse -> null);
} catch (Throwable t) {
throw new CompletionException(t);
}
}else{
return notImplemented();
}
}
private Attachment adaptiveCardAttachmentFromJson(String json) throws IOException {
Attachment attachment = new Attachment();
attachment.setContentType("application/vnd.microsoft.card.adaptive");
attachment.setContent(new ObjectMapper().readValue(json, ObjectNode.class));
return attachment;
}
calCard.json
{
"type": "AdaptiveCard",
"body": [
{
"type": "TextBlock",
"size": "medium",
"weight": "bolder",
"text": "Calendar",
"horizontalAlignment": "center",
"wrap": true,
"style": "heading"
},
{
"type": "Input.Text",
"label": "Matter",
"id": "MATTER_DETAILS",
"isRequired": true,
"errorMessage": "Matter is required",
"placeholder": "Select a Matter",
"inlineAction": {
"type": "Action.Submit",
"title": "submit",
"fetchTask": false,
"data": {
"ade_window": "MATTER_PICK",
"msteams": {
"type": "task/fetch"
}
},
"id": "MATTER_PICK",
"associatedInputs": "none"
}
},
{
"type": "Input.Text",
"label": "Description",
"id": "0",
"name": "CAL_DESC",
"isRequired": true,
"errorMessage": "Name is required",
"placeholder": "Enter a Description"
}
],
"actions": [
{
"type": "Action.Submit",
"title": "Submit"
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.3"
}
The card is successfully produced in the chat, and upon clicking the inlineAction Action.Submit button, my bot receives the onTeamsTaskModuleFetch request and I handle with the following logic:
Note: I can hit the ngrok String url shown here from the browser, and I'm also using composeExtensions with commands using this address where the task module is loaded successfully.
@Override
protected CompletableFuture<TaskModuleResponse> onTeamsTaskModuleFetch(
TurnContext turnContext,
TaskModuleRequest taskModuleRequest
) {
return Async.wrapBlock(() -> {
TaskModuleTaskInfo taskInfo = new TaskModuleTaskInfo();
String url = "https://6303-97-91-136-36.ngrok-free.app/JSP2.5/TeamsStart.jsp?_start_page=Matter%20Detail%20Pick&winTitle=Select%20Matter";
taskInfo.setUrl(url);
taskInfo.setFallbackUrl(url);
taskInfo.setHeight("medium");
taskInfo.setWidth("small");
taskInfo.setTitle("Task Module Test");
return taskInfo;
}).thenApply(TaskModuleResponseFactory::toTaskModuleResponse);
}
The web view fails to load and I'm met with an empty Task Module displaying the text "Unable to reach app. Please try again."
Am I missing something?