Adaptive card container create empty div blocks - adaptive-cards

I'm user adaptive card via React framework. I have an array of complex objects (customer.attributes). I want to filter the array's items and diplay the items that respect a condition ("isVisible": "${attributeCode == ##CC3##}"). This works fine, the adaptive card display only the items I want.
However, all the items that don't respect the condition create a empty div. These divs create blank spaces. How can I get rid of them ?
For information, I also tried to use the $when attribut with the same result
I tried to hard code "isVisible": false in the template. The empty divs are still here but have a "display: none" properties in their css. Therefore, they're not visible, and that's perfect. Why isn't it working with the condition ?
Thank you for your help,
Template :
{
"type": "AdaptiveCard",
"body": [
{
"type": "TextBlock",
"text": "${customer.firstName} ${customer.lastName}",
"size": "Large"
},
{
"type": "Container",
"$data": "${customer.attributes}",
"spacing": "medium",
"items": [
{
"type": "TextBlock",
"isSubtle": "true",
"text": "${attributeLabel}",
"isVisible": "${attributeCode == ##CC3##}"
},
{
"type": "TextBlock",
"isVisible": "${attributeCode == ##CC3##}",
"text": "${attributeValue.textValue}",
"weight": "Bolder"
}
]
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.0"
}
Data:
{
"customer": {
"customerId": "id",
"firstName": "David",
"attributes": [
{
"attributeCode": "CC1",
"attributeType": "TEXT",
"attributeLabel": "Texte libre 1",
"attributeValue": "test1"
},
{
"attributeCode": "CC3",
"attributeType": "TEXT",
"attributeLabel": "Texte libre 3",
"attributeValue": "test3"
}
],
"loyaltyEligible": true,
"loyaltyAccounts": []
}
}
Result div :

Related

Is is possible to make any element other than ActionSet clickable in Actionable message

I know in Microsoft's ActionableMessage, one can have ActionSet which is clickable and you can have it open an URL.
But designs I am working with calls for something like this:
| Some Text. [Icon] |
Is there a way I can define AdaptiveColumn/AdaptiveColumnSet clickable UI element, such that one can open url?
I have found a kind of "hackable" way, where I have created a background with just icon.
Then I set the text in a column and set text value as Some Text
That "kind-of" works but now user has to click on that text. Click on the entire element doesn't work!!
There are many elements you can make clickable, check this here as an example:
{
"type": "AdaptiveCard",
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.5",
"body": [
{
"type": "TextBlock",
"text": "Clicking this opens google",
"size": "Medium",
"weight": "Bolder",
"id": "googleButton"
},
{
"type": "Image",
"id": "Image",
"url": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTK2nG24AYDm6FOEC7jIfgubO96GbRso2Xshu1f8abSYQ&s",
"selectAction": {
"type": "Action.OpenUrl",
"url": "https://www.google.de"
}
},
{
"type": "Container",
"selectAction": {
"type": "Action.OpenUrl",
"url": "https://www.google.de"
},
"items": [
{
"type": "TextBlock",
"text": "New TextBlock",
"wrap": true,
"selectAction": {
"type": "Action.OpenUrl",
"url": "https://www.google.de"
}
}
]
}
]}
Many elements such as container, image etc have the "selectAction" property where you can define an onClick action

Adaptive Cards ColumnSets with 2 Input.Text can't set the input to the "id"

I've been working on a chatbot and i'm using the Microsoft Adaptive Cards for my bot ui.
Currently i am im trying to create a a row that contains 2 textblocks and 2 input.text.
But when entering a value into these input.text they don't seem to set the value to the given id.
This does work however when the input.text are not in a coulmn set but instead are stacked on top of each other.I think its the Azure BotService not handling the JSON right.
I've tried using diffrent channels. Web-Chat, Teams-Chat. It does work on the adaptive card designer but not with any other service. Anyone else got this problem?
{
"type": "AdaptiveCard",
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.3",
"body": [
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "New TextBlock",
"wrap": true
},
{
"type": "Input.Text",
"id": "inputOne",
"placeholder": "Placeholder text"
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "New TextBlock",
"wrap": true
},
{
"type": "Input.Text",
"id": "inputTwo",
"placeholder": "Placeholder text"
}
]
}
]
}
]
}
I tried to reproduce the issue and the pattern which was mentioned in the code block is having some blockage due to some input fields calling structure problem. Try to check the below code block for sample and replace with the current requirements.
Data JSON:
{
"title": "Tell us about yourself",
"body": "We just need a few more details to get you booked for the trip of a lifetime!",
"disclaimer": "Don't worry, we'll never share or sell your information.",
"properties": [
{
"id": "myName",
"label": "Your name (Last, First)",
"validation": "^[A-Z][a-z]+, [A-Z][a-z]+$",
"error": "Please enter your name in the specified format"
},
{
"id": "myEmail",
"label": "Your email",
"validation": "^[A-Za-z0-9._%+-]+#[A-Za-z0-9.-]+[.][A-Za-z0-9-]{2,4}$",
"error": "Please enter a valid email address"
},
{
"id": "myTel",
"label": "Phone Number (xxx-xxx-xxxx)",
"validation": "^[0-9]{3}-[0-9]{3}-[0-9]{4}$",
"error": "Invalid phone number. Use the specified format: 3 numbers, hyphen, 3 numbers, hyphen and 4 numbers"
}
],
"thumbnailUrl": "https://upload.wikimedia.org/wikipedia/commons/b/b2/Diver_Silhouette%2C_Great_Barrier_Reef.jpg",
"thumbnailAlt": "Diver in the Great Barrier Reef"
}
Template JSON:
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": 2,
"items": [
{
"type": "TextBlock",
"text": "${title}",
"weight": "bolder",
"size": "medium",
"style": "heading"
},
{
"type": "TextBlock",
"text": "${body}",
"isSubtle": true,
"wrap": true
},
{
"type": "TextBlock",
"text": "${disclaimer}",
"isSubtle": true,
"wrap": true,
"size": "small"
},
{
"type": "Container",
"$data": "${properties}",
"items": [
{
"type": "Input.Text",
"label": "${label}",
"id": "${id}",
"regex": "${validation}",
"errorMessage": "${error}",
"isRequired": true
}
]
}
]
},
{
"type": "Column",
"width": 1,
"items": [
{
"type": "Image",
"url": "${thumbnailUrl}",
"altText": "${thumbnailAlt}",
"size": "auto"
}
]
}
]
}
],
"actions": [
{
"type": "Action.Submit",
"title": "Submit"
}
]
}
The result adaptive card looks like below screen as the sample.

Adaptive Card - Dynamically Generated Choices V1.5

I have the following old Adaptive card from a Playbook which I need to update to v1.5. But I stumble upon a problem with the choices which are dynamically generated from a logic app body. I have made the part of the code bold. There is a value that is not JSON proof so it should be required to convert it to JSON that way.
{
"type": "Input.ChoiceSet",
"choices": #{body('LogicApp_-_Get_tagged_playbooks')}, #THIS IS THE LINE THAT NEEDS TO BE CHANGED
"placeholder": "IP Playbooks",
"isMultiSelect": true,
"style": "expanded",
"id": "playbooks"
}
Full Code:
{
"msTeams": {
"width": "full"
},
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.2",
"body": [
{
"type": "TextBlock",
"size": "large",
"color": "accent",
"text": "**Microsoft Sentinel Alert - **#{triggerBody()?['object']?['properties']?['incidentNumber']} - #{triggerBody()?['object']?['properties']?['title']}",
"wrap": true
},
{
"type": "TextBlock",
"text": "Please Select the playbooks to run for the incident:",
"weight": "Bolder"
},
{
"type": "TextBlock",
"text": "Available tagged Logic App playbooks",
"wrap": true,
"weight": "Bolder",
"color": "Accent"
},
{
"type": "Input.ChoiceSet",
"choices": #{body('LogicApp_-_Get_tagged_playbooks')},
"placeholder": "IP Playbooks",
"isMultiSelect": true,
"style": "expanded",
"id": "playbooks"
}
],
"actions": [
{
"type": "Action.Submit",
"title": "Submit"
}
]
}
Could someone help me converting only that part of the choices to v1.5 so I can properly generate the choices myself? Or do I need to make my card legacy supported and drop it back to v1.2? I really want to use the card designer so I can make it easier.
Thanks in advance.

Adaptive Card vertical scrollbar with HTML body in Outlook 365 on the desktop

I have a payload in a script tag inside the head tag of an html page which is sent by C# using SMTP client. It works just fine, I see the card in Outlook 365 on the desktop but the problem is the height of the card is predefined based on the content thus when people have small screen, there's a vertical scrollbar for the card. Additionally, the html in the body of the page has also a vertical scrollbar. I tried with Outlook.com and it doesn't exhibit this behavior
These scrollbars are not desirable. What would be the correct way to ensure that both the card AND the html doesn't have vertical scrollbar and let Outlook have it's own one so we can scroll using Outlook scrollbar not the card or the HTML
Here's the payload :
<div>
<script type="application/adaptivecard+json">
{
"type": "AdaptiveCard",
"body": [
{
"type": "Container",
"items": [
{
"type": "Image",
"url": "#LOGO",
"size": "Large"
},
{
"type": "TextBlock",
"size": "Medium",
"weight": "Bolder",
"text": "#ADAPTIVE_CARD_TITLE"
},
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"items": [
{
"type": "TextBlock",
"weight": "Bolder",
"text": "#SERVICE_TITLE",
"wrap": true
},
{
"type": "TextBlock",
"spacing": "None",
"text": "#SERVICE_DATE",
"isSubtle": true,
"wrap": true
}
],
"width": "stretch"
}
]
}
]
},
{
"type": "Container",
"items": [
{
"type": "TextBlock",
"spacing": "None",
"text": "#REVIEW_TITLE",
"wrap": true
},
{
"type": "ColumnSet",
"separator": true,
"columns": [
{
"type": "Column",
"separator": true,
"items": [
{
"type": "TextBlock",
"text": "#EMPLOYEE_TITLE"
}
],
"width": "stretch"
},
{
"type": "Column",
"separator": true,
"items": [
{
"type": "TextBlock",
"text": "#EMPLOYEE_VALUE"
}
],
"width": "stretch"
}
]
},
{
"type": "ColumnSet",
"spacing": "None",
"separator": true,
"columns": [
{
"type": "Column",
"separator": true,
"items": [
{
"type": "TextBlock",
"text": "#ACCOUNT_DATE_TITLE"
}
],
"width": "stretch"
},
{
"type": "Column",
"separator": true,
"items": [
{
"type": "TextBlock",
"text": "#ACCOUNT_DATE_VALUE"
}
],
"width": "stretch"
}
]
}
]
}
],
"actions": [
{
"type": "Action.OpenUrl",
"title": "#APPROVE_TITLE",
"url": "#APPROVE_URL"
},
{
"type": "Action.ShowCard",
"title": "#REJECT_TITLE",
"card": {
"type": "AdaptiveCard",
"body": [
{
"type": "Input.Text",
"id": "comment",
"placeholder": "#COMMENT_PLACE_HOLDER",
"isMultiline": true
}
],
"actions": [
{
"type": "Action.OpenUrl",
"title": "#SEND_REASON_TITLE",
"url": "#SEND_REASON_URL"
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
}
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.0"
}
</script>
<br />
#BODY
</div>
I would comment, but I don't have the rep yet.
I am unable to replicate your issue. I tested with a long card I made in the designer (just added a bunch of text blocks), and viewed it in OWA (Outlook Web App), and there was only one scroll bar. I am not on the monthly release channel for the desktop client, so I can't test that (only compatible for monthly release channel.
Which version of Outlook is rendering the card?
Maybe try putting #BODY inside of head below the script tag? It might remove one of the scrollbars.

Adaptive cards are converted to image in Facebook Messenger

I tried following example card picked up from Microsoft's website adaptivecards.io
var msg = new builder.Message(session)
.addAttachment({
contentType: "application/vnd.microsoft.card.adaptive",
content: {
type: "AdaptiveCard",
speak: "<s>Your meeting about \"Adaptive Card design session\"<break strength='weak'/> is starting at 12:30pm</s><s>Do you want to snooze <break strength='weak'/> or do you want to send a late notification to the attendees?</s>",
            "body": [
{
"type": "Container",
"items": [
{
"type": "TextBlock",
"text": "Publish Adaptive Card schema",
"weight": "bolder",
"size": "medium"
},
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "auto",
"items": [
{
"type": "Image",
"url": "https://pbs.twimg.com/profile_images/3647943215/d7f12830b3c17a5a9e4afcc370e3a37e_400x400.jpeg",
"size": "small",
"style": "person"
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "Matt Hidinger",
"weight": "bolder",
"wrap": true
},
{
"type": "TextBlock",
"spacing": "none",
"text": "Created {{DATE(2017-02-14T06:08:39Z,SHORT)}}",
"isSubtle": true,
"wrap": true
}
]
}
]
}
]
},
{
"type": "Container",
"items": [
{
"type": "TextBlock",
"text": "Now that we have defined the main rules and features of the format, we need to produce a schema and publish it to GitHub. The schema will be the starting point of our reference documentation.",
"wrap": true
},
{
"type": "FactSet",
"facts": [
{
"title": "Board:",
"value": "Adaptive Card"
},
{
"title": "List:",
"value": "Backlog"
},
{
"title": "Assigned to:",
"value": "Matt Hidinger"
},
{
"title": "Due date:",
"value": "Not set"
}
]
}
]
}
],
"actions": [
{
"type": "Action.ShowCard",
"title": "Set due date",
"card": {
"type": "AdaptiveCard",
"body": [
{
"type": "Input.Date",
"id": "dueDate",
"title": "Select due date"
}
],
"actions": [
{
"type": "Action.Submit",
"title": "OK"
}
]
}
},
{
"type": "Action.ShowCard",
"title": "Comment",
"card": {
"type": "AdaptiveCard",
"body": [
{
"type": "Input.Text",
"id": "comment",
"isMultiline": true,
"placeholder": "Enter your comment"
}
],
"actions": [
{
"type": "Action.Submit",
"title": "OK"
}
]
}
},
{
"type": "Action.OpenUrl",
"title": "View",
"url": "http://adaptivecards.io"
}
]
}
});
session.send("This is an adaptive card");
session.send(msg);
to see how it appears in Facebook and WebChat.
In WebChat emulator it renderes fine with options to interact with choices.
However, same thing renders as an image in Facebook Messenger, with one separate messsage to view options, which redirects to the website.
Should we assume that adaptive cards will not work on Facebook messenger? Or am I missing something basic here.
Unless Messenger natively supports adaptive cards, the best we can do is render to an image and attempt to map Actions to Messenger buttons. For example, an Action.OpenUrl should render as a button on Messenger. But more advanced scenarios, like input fields, etc, will get dropped as there is no way to express those as Messenger templates today.
This documentation lists the channels and their current support:
https://learn.microsoft.com/en-us/adaptive-cards/get-started/bots#channel-status