Tips and tricks to create stunning Adaptive Cards (Updated Mar ’22)

A simple Adaptive Card for your business takes less than 10 minutes to make. But as you start to make more sophisticated layouts you will usually run into common issues where the data you want to show in your Card maybe isn’t 100% what you need it to be, or is just too much to comfortably fit into your layout.

In this post I listed examples of cool little hacks that we’ve accumulated over time that helped push the envelope on what an Adaptive Card can do. Some of these use Adaptive Expressions, but others are just thinking outside the box a little.

Trim to first name

Let say you have an API that gives you the user’s name as “John Hancock” but you want to address the user as just “John” in your Card.

Turn timestamps into “x hours ago”

Most APIs send timestamps in UNIX format, like 2021-09-17T00:00:33.25. But most users prefer relative timestamps to be a little easier to read than that.

Ordinarily you need a library like moment.js that does this kind of transformation. But, in a pinch, you can get very close to this using the following Adaptive expression.

Assemble email addresses

If you want to show a user’s email address, but your API isn’t providing it, then maybe you can “build” the email using their name and company name.

Make tabs

Tab interfaces are popular, but not supported in Adaptive Cards. Or are they?

With this trick you can create a Card that has at least two tabs – although be warned that the widths need tinkering with to display this properly on small screens.

Include icons in the Card

Adaptive Cards can’t host their own images or icons, so you will usually need a URL and capacity to host these yourself elsewhere (for example through a CMS). However, there is one hack to get around this that works at least for icons. You can base64 them, for example with a tool like Elmah.

This makes the Card’s payload quite large so use it with caution and remember that some host apps might have size restrictions that you could run into using this.

Conditional highlighting

If you want text to be either green or red depending on a value, you can conditionally highlight text, or, even switch out arrow symbols to show an upwards or downwards trend. In our example below this is the values we used:

"change": "2.5",
"yesterday": "7"

Create fallback text

Sometimes the data you get from APIs is not as uniform as we want. Let’s say you want to make a Card that shows peoples’ job titles beneath their name. Until one record doesn’t contain the job title, causing an awkward change in height.

Wouldn’t it be cool to have a fallback of some kind, say to show the email address when there isn’t a job title?

Create a mini timeline

Whether your showing customer activity or progress of a process, a vertical timeline could be a quirky little addition to your Adaptive Card design. Here’s how to do it:

Use backgrounds for stunning designs

Whether it’s a welcome message, or some digital signage you want to place on the corporate intranet, Adaptive Cards can show background images which make them ideal for your great designs.

Expanding line items

In order to declutter an Adaptive Card, it might be useful to offload some details into a little section that expands and collapses. This is a relatively simple way to get there:

Accordion

Building on top of the expand/collapse function, you could also get whole accordion style sections. Whenever you click on a headline, the respective section opens or closes.

Pseudo active state

Let’s say you want to offer a Like button. On Facebook you press it, it turns bright blue, you know it’s pressed. Adaptive Cards’ buttons don’t offer a similar activated state, but you can get there by using the Action.ToggleVisibility button.

Filtered lists

You know the problem: you get a JSON file that has 25 items but you only want to show the ones that are, say, green. With an Adaptive Expression you can filter items from your array based on a matching attribute.

Turn an integer into a string

Let’s say your JSON has a count of the number of outages your system has. But you can’t show this count inside of your Adaptive Card because it’s just an integer, and Adaptive Cards can only bind to strings wrapped in "".

Rescue has arrived. There is an Adaptive Expression you can inside of your Card that turns your integer into a string.

Count items in an array

Let’s say you have a list but you want to get a count of how many of them are red items, versus other colors. You can wrap this into two Adaptive Expressions, the first count is responsible to output you a number, and the inner function where filters the output for the attribute(s) you specify.

Empty state for a list

If you have an Adaptive Card list but the array is empty, the list just unceremoniously vanishes. This could make you or your users question if the Card could be broken, when it’s just hasn’t anything to show you. To avoid that, empty states are a popular way to signpost a list is deliberately empty.

In this below example, if there are no 🟡 items in our list, we display the empty state container.

~~~

Did you find these hacks useful? If so, you might also be interested in ready-to-use business templates for Adaptive Cards.

Related Posts
Read More

Say goodbye to scheduling chaos: shift planning dashboard in SharePoint

Imagine you’re in IT at a busy hospital, juggling on-call schedules for the ER, ICU and general ward—all tracked in separate spreadsheets, emails and siloed apps. Someone misses an update, a shift overlap goes unnoticed, and frustration mounts. What if all those rotas lived in one place—your SharePoint intranet—refreshing in real time from MS Teams Shifts (or any rota software you choose)? By dedicating a single page to staff schedules, you create instant visibility and cut down on “where’s my rota?” tickets. Users land on a “Staff rotas” page and immediately see who’s on duty today, who’s taking leave tomorrow…
Read More

Build an AI chatbot for your team in 10 steps

Building a chatbot has become relatively easy with many dedicated tools, but to make an internal chatbot for work can be a tall order. Of course it needs to be 'smart' and personalized, but crucially it must overall become a tool that employees prefer to use over the 'old' way to get a task done.
Read More

Digital Assistant for Internal Comms

It’s tough times for internal comms folks. More and more tools have gone into the Cloud, making it harder to get through to the user with a single, consistent voice. Tool hopping has been rampant in recent years, making it ever harder for internal comms to reach the third of the workforce that’s disengaged. As a vendor, we have heard you, internal comms! Here is what we fix: 1. Lack of employee engagement There isn’t one single feature that can magically create employee engagement. Rather, Digital Assistant as a wholistic platform is part of a new breed of software that’s…
Read More

The adenin 2023 Spring Release: New features for SharePoint users and new apps

With SharePoint and Viva Connections driving a new wave of improving the employee’s intranet experience, we’ve been hard at work to further improve the Adenin platform integration with those two products. Introducing App Connections for Viva and SharePoint This is a new web part that automatically (or as we call it, automagically) creates lists from the over 100 apps in our App Directory, such as ServiceNow, Hubspot, Workday, and many more. With App Connections users can: To start simply head over to Microsoft App Source and install the app to your SharePoint & Viva Connections. New app adding experience It…