How to send Adaptive Cards with CLI Microsoft 365

Published Feb 17 2021 08:38 AM 2,834 Views

 

yulia-matvienko-kgz9vsP5JCU-unsplash.jpg

 

In this blog post I want to explain how you can send an Adaptive Card with CLI Microsoft 365. I will guide you from zero to hero :rocket:, so even if you don't know anything about the CLI Microsoft 365 or about Adaptive cards, don't stop reading, you will be able to do that in a few minutes- I promise!

What is CLI Microsoft 365?

Lets first get us all on the same page and clarify, what CLI Microsoft 365 is and why we should use it: It is a CLI (Command Line Interface) which let's us manage Microsoft 365 from any kind of OS: It doesn't matter if we work on Windows, MacOS or Linux. Previously, some configurations were only possible by PowerShell for Windows, which limited a lot of admins. But even if you work on Windows and are pretty fine with using PowerShell, CLI might be a nice alternative to try out.

How to use CLI Microsoft 365

I will now describe your first steps:

Install Node.js

To use the CLI Microsoft 365, you will need to install Node.js - Please follow these steps:

* go to https://nodejs.org/en/
* download the LTS version of Node.js
* install Node.js

 

If in doubt, if you have the correct version installed or if you need to use different versions of Node.js, please read Use Node Version Manager to develop your SPFx apps by Toni Pohl 

Install CLI Microsoft 365

Now that you have Node.js installed, we can continue with installing the CLI Microsoft 365. You can choose any shell you like: If you want to, you can use PowerShell or PowerShell in the Terminal in Visual Studio Code or whatever makes you happy. I like to use the PowerShell terminal in Visual Studio Code, because links render to be clickable and this saves me copy/pasting links into a new browser tab. But if you like to any other shell, that is perfectly fine as well. To install CLI Microsoft 365, run the command:

 

 

 

npm i -g @pnp/cli-microsoft365

 

 

 

In case you wonder:

* the `i` is an alias for `install`
* the `-g` means that we want to install this package globally
* it will take about 2 minutes

 

Login

Now that we installed CLI Microsoft 365, it's time to actually do something here. But before we can get or post anything, we will need to log into our tenant. Pro Tip: You can use your your Developer tenant for this. If you don't know, what this is, please go read What is a “Dev Tenant” and why would you want one? by Julie Turner

 

Run the following command:

 

 

m365 login

 

 

In response you will be asked to open a web browser and login with a code. If you are using Visual Studio Code, you can click on the link, please copy the code upfront.

 

login.png

After you pasted the code,

* click Next
* pick an account out of the list of accounts

You will be seeing this message and can close this browser tab- we won't need it anymore.
PnPmanagementShellOK.png

Yay! You successfully logged in! You don't believe that? Let's check with CLI Microsoft 365 and run this command to get your status:

 

 

m365 status

 

 

and it will get your status for you:

status.png

If you want some inspiration, what you could do now, run this command:

 

 

m365 help

 

 

 

help.png
which gives you a list of things you can try, these are called command groups, as each of them can contain several commands. When you now choose one of the command groups and run for example this one:

 

 

m365 outlook

 

 

you will get the commands, that are available to you in this command group. Sometimes, you can go several levels deep-Just try them out!

What are Adaptive Cards?

Next thing we need to know is, what are Adaptive Cards and why would we want to use them? When we look at adaptivecards.io we can read the definition Adaptive Cards are platform-agnostic snippets of UI, authored in JSON, that apps and services can openly exchange. When delivered to a specific app, the JSON is transformed into native UI that automatically adapts to its surroundings. It helps design and integrate light-weight UI for all major platforms and frameworks. This means, that we get a nice method to share and display information without needing to know how to use HTML/CSS to render them correctly in different host applications. If you like to know more, please read Get started with Adaptive Cards by Tomasz Poszytek

How do we send an Adaptive Card with CLI Microsoft 365?

Now that we know what is an Adaptive Card, let's have a look on how we get this sent by CLI. The documentation provides us with a sample and this sample needs to have a URL. Where do we get this from? This depends on where you want to send this Adaptive Card to. In this example, I want to use Microsoft Teams as host application and therefore we will need to create an incoming webhook in Teams.

Create the Webhook

If you have no clue what is a webhook, no problem, Rabia Williams got you covered with How to configure and use Incoming Webhooks in Microsoft Teams

 

* Open Microsoft Teams
* Click the ellipsis icon on the Teams channel that you want to send the Adaptive Card to
* Click Connectors
* Search for 'webhook'
incoming-webhook.png
* Click Add
* Click Add (yes, yet again)
* Give your webhook a name
* If you like to, you can upload a picture- messages sent via this webhook (our Adaptive Card) will have this image then as Profile Pic - this step is optional.
* Click Create
* Copy the generated URL
* Click Done

 

This URL is the URL we will need in the command later - If you want to, paste it into a notepad or similar.

Author your Card

Now it's time to author your card. You can do this in a lot of editors, I use either the Adaptive Cards Designer or the Adaptive Cards Viewer Extension in Visual Studio Code, but recently also found Adaptive Card Studio. You can also use one of the provided samples and use them as-is or adjust them to your needs.

If you feel like authoring your Card in Designer or Visual Studio Code is fine for you right now, go ahead with this, otherwise you can also use the examples that are provided in the documentation of CLI Microsoft 365. I used the last one, 'Send custom card with card data'.

For everyone not very familiar writing and understanding code: We can make more sense of the snippet by copy/paste this into Visual Studio Code, and then press Alt+z to soft-wrap this and then separate the Adaptive Card from the rest:

 

* Select JSON in Language Mode
* Insert somenew lines right before the first `{`
* Delete the `'` at the beginning and the end of the snippet
* Format with Shift + Alt + f

 

Now go ahead and adjust the sample to work in your environment:

 

* replace the URL in the code with the URL that we copied when we added the webhook connector to Teams
* copy the whole code
* run it

!! Turned out, that there are some differences how to use quotes `'` or `"` - please consider which shell you are using before you copy/paste the code from CLI Microsoft 365 documentation.

 

Congratulations :rocket:- you sent your first adaptive Card with CLI.

## Feedback and what's next?

I hope you liked this little post on how to get started with CLI Microsoft 365 and learning how to send an Adaptive Card with it. I would like to learn, for which use cases you would do this? Please comment below!

 

 

1 Comment
Regular Visitor

You can also send them through PowerShell quite easily! 

 

Using either the more recently released Graph PowerShell SDK and Invoke-MgGraphRequest or more manually through Invoke-WebRequest

 

I did this with the Invoke-MgGraphRequest over here on SysManSquad if anyone wants a walkthrough for how you can do this with unattended scripts in PowerShell 

%3CLINGO-SUB%20id%3D%22lingo-sub-2143466%22%20slang%3D%22en-US%22%3EHow%20to%20send%20Adaptive%20Cards%20with%20CLI%20Microsoft%20365%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2143466%22%20slang%3D%22en-US%22%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22yulia-matvienko-kgz9vsP5JCU-unsplash.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F255537iE7E220C802294F64%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22yulia-matvienko-kgz9vsP5JCU-unsplash.jpg%22%20alt%3D%22yulia-matvienko-kgz9vsP5JCU-unsplash.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20this%20blog%20post%20I%20want%20to%20explain%20how%20you%20can%20send%20an%20Adaptive%20Card%20with%20CLI%20Microsoft%20365.%20I%20will%20guide%20you%20from%20zero%20to%20hero%20%3Arocket%3A%2C%20so%20even%20if%20you%20don't%20know%20anything%20about%20the%20CLI%20Microsoft%20365%20or%20about%20Adaptive%20cards%2C%20don't%20stop%20reading%2C%20you%20will%20be%20able%20to%20do%20that%20in%20a%20few%20minutes-%20I%20promise!%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--525175150%22%20id%3D%22toc-hId--525175150%22%20id%3D%22toc-hId--525175150%22%20id%3D%22toc-hId--525175210%22%3EWhat%20is%20CLI%20Microsoft%20365%3F%3C%2FH2%3E%0A%3CP%3ELets%20first%20get%20us%20all%20on%20the%20same%20page%20and%20clarify%2C%20what%20CLI%20Microsoft%20365%20is%20and%20why%20we%20should%20use%20it%3A%20It%20is%20a%20CLI%20(Command%20Line%20Interface)%20which%20let's%20us%20manage%20Microsoft%20365%20from%20any%20kind%20of%20OS%3A%20It%20doesn't%20matter%20if%20we%20work%20on%20Windows%2C%20MacOS%20or%20Linux.%20Previously%2C%20some%20configurations%20were%20only%20possible%20by%20PowerShell%20for%20Windows%2C%20which%20limited%20a%20lot%20of%20admins.%20But%20even%20if%20you%20work%20on%20Windows%20and%20are%20pretty%20fine%20with%20using%20PowerShell%2C%20CLI%20might%20be%20a%20nice%20alternative%20to%20try%20out.%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-165386324%22%20id%3D%22toc-hId-165386324%22%20id%3D%22toc-hId-165386324%22%20id%3D%22toc-hId-165386264%22%3EHow%20to%20use%20CLI%20Microsoft%20365%3C%2FH3%3E%0A%3CP%3EI%20will%20now%20describe%20your%20first%20steps%3A%3C%2FP%3E%0A%3CH4%20id%3D%22toc-hId-855947798%22%20id%3D%22toc-hId-855947798%22%20id%3D%22toc-hId-855947798%22%20id%3D%22toc-hId-855947738%22%3EInstall%20Node.js%3C%2FH4%3E%0A%3CP%3ETo%20use%20the%20CLI%20Microsoft%20365%2C%20you%20will%20need%20to%20install%20Node.js%20-%20Please%20follow%20these%20steps%3A%3C%2FP%3E%0A%3CP%3E*%20go%20to%20%3CA%20href%3D%22https%3A%2F%2Fnodejs.org%2Fen%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Fnodejs.org%2Fen%2F%3C%2FA%3E%3CBR%20%2F%3E*%20download%20the%20LTS%20version%20of%20Node.js%3CBR%20%2F%3E*%20install%20Node.js%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20in%20doubt%2C%20if%20you%20have%20the%20correct%20version%20installed%20or%20if%20you%20need%20to%20use%20different%20versions%20of%20Node.js%2C%20please%20read%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fmicrosoft-365-pnp-blog%2Fuse-node-version-manager-to-develop-your-spfx-apps%2Fba-p%2F2128393%22%20target%3D%22_blank%22%3EUse%20Node%20Version%20Manager%20to%20develop%20your%20SPFx%20apps%3C%2FA%3E%26nbsp%3Bby%20%3CA%20href%3D%22https%3A%2F%2Ftwitter.com%2Fatwork%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EToni%20Pohl%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22toc-hId--951506665%22%20id%3D%22toc-hId--951506665%22%20id%3D%22toc-hId--951506665%22%20id%3D%22toc-hId--951506725%22%3EInstall%20CLI%20Microsoft%20365%3C%2FH4%3E%0A%3CP%3ENow%20that%20you%20have%20Node.js%20installed%2C%20we%20can%20continue%20with%20installing%20the%20CLI%20Microsoft%20365.%20You%20can%20choose%20any%20shell%20you%20like%3A%20If%20you%20want%20to%2C%20you%20can%20use%20PowerShell%20or%20PowerShell%20in%20the%20Terminal%20in%20Visual%20Studio%20Code%20or%20whatever%20makes%20you%20happy.%20I%20like%20to%20use%20the%20PowerShell%20terminal%20in%20Visual%20Studio%20Code%2C%20because%20links%20render%20to%20be%20clickable%20and%20this%20saves%20me%20copy%2Fpasting%20links%20into%20a%20new%20browser%20tab.%20But%20if%20you%20like%20to%20any%20other%20shell%2C%20that%20is%20perfectly%20fine%20as%20well.%20To%20install%20CLI%20Microsoft%20365%2C%20run%20the%20command%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3Enpm%20i%20-g%20%40pnp%2Fcli-microsoft365%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20case%20you%20wonder%3A%3C%2FP%3E%0A%3CP%3E*%20the%20%60i%60%20is%20an%20alias%20for%20%60install%60%3CBR%20%2F%3E*%20the%20%60-g%60%20means%20that%20we%20want%20to%20install%20this%20package%20globally%3CBR%20%2F%3E*%20it%20will%20take%20about%202%20minutes%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22toc-hId-1536006168%22%20id%3D%22toc-hId-1536006168%22%20id%3D%22toc-hId-1536006168%22%20id%3D%22toc-hId-1536006108%22%3ELogin%3C%2FH4%3E%0A%3CP%3ENow%20that%20we%20installed%20CLI%20Microsoft%20365%2C%20it's%20time%20to%20actually%20do%20something%20here.%20But%20before%20we%20can%20get%20or%20post%20anything%2C%20we%20will%20need%20to%20log%20into%20our%20tenant.%20Pro%20Tip%3A%20You%20can%20use%20your%20your%20Developer%20tenant%20for%20this.%20If%20you%20don't%20know%2C%20what%20this%20is%2C%20please%20go%20read%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fmicrosoft-365-pnp-blog%2Fwhat-is-a-dev-tenant-and-why-would-you-want-one%2Fba-p%2F2036610%22%20target%3D%22_blank%22%3EWhat%20is%20a%20%E2%80%9CDev%20Tenant%E2%80%9D%20and%20why%20would%20you%20want%20one%3C%2FA%3E%3F%20by%20%3CA%20href%3D%22https%3A%2F%2Ftwitter.com%2Fjfj1997%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EJulie%20Turner%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ERun%20the%20following%20command%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3Em365%20login%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20response%20you%20will%20be%20asked%20to%20open%20a%20web%20browser%20and%20login%20with%20a%20code.%20If%20you%20are%20using%20Visual%20Studio%20Code%2C%20you%20can%20click%20on%20the%20link%2C%20please%20copy%20the%20code%20upfront.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22login.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F255531iCE46A917703E8E72%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22login.png%22%20alt%3D%22login.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EAfter%20you%20pasted%20the%20code%2C%3C%2FP%3E%0A%3CP%3E*%20click%20%3CSTRONG%3ENext%3C%2FSTRONG%3E%3CBR%20%2F%3E*%20pick%20an%20account%20out%20of%20the%20list%20of%20accounts%3C%2FP%3E%0A%3CP%3EYou%20will%20be%20seeing%20this%20message%20and%20can%20close%20this%20browser%20tab-%20we%20won't%20need%20it%20anymore.%20%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22PnPmanagementShellOK.png%22%20style%3D%22width%3A%20338px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F255532iD2B4C761C74D27F1%2Fimage-dimensions%2F338x260%3Fv%3D1.0%22%20width%3D%22338%22%20height%3D%22260%22%20role%3D%22button%22%20title%3D%22PnPmanagementShellOK.png%22%20alt%3D%22PnPmanagementShellOK.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EYay!%20You%20successfully%20logged%20in!%20You%20don't%20believe%20that%3F%20Let's%20check%20with%20CLI%20Microsoft%20365%20and%20run%20this%20command%20to%20get%20your%20status%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3Em365%20status%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Eand%20it%20will%20get%20your%20status%20for%20you%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22status.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F255533i203A2ADB780C3374%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22status.png%22%20alt%3D%22status.png%22%20%2F%3E%3C%2FSPAN%3E%3CBR%20%2F%3E%3CBR%20%2F%3EIf%20you%20want%20some%20inspiration%2C%20what%20you%20could%20do%20now%2C%20run%20this%20command%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3Em365%20help%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22help.png%22%20style%3D%22width%3A%20339px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F255534i3AC5189FE02CAF7C%2Fimage-dimensions%2F339x356%3Fv%3D1.0%22%20width%3D%22339%22%20height%3D%22356%22%20role%3D%22button%22%20title%3D%22help.png%22%20alt%3D%22help.png%22%20%2F%3E%3C%2FSPAN%3E%3CBR%20%2F%3Ewhich%20gives%20you%20a%20list%20of%20things%20you%20can%20try%2C%20these%20are%20called%20command%20groups%2C%20as%20each%20of%20them%20can%20contain%20several%20commands.%20When%20you%20now%20choose%20one%20of%20the%20command%20groups%20and%20run%20for%20example%20this%20one%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3Em365%20outlook%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Eyou%20will%20get%20the%20commands%2C%20that%20are%20available%20to%20you%20in%20this%20command%20group.%20Sometimes%2C%20you%20can%20go%20several%20levels%20deep-Just%20try%20them%20out!%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--972512873%22%20id%3D%22toc-hId--972512873%22%20id%3D%22toc-hId--972512873%22%20id%3D%22toc-hId--972512933%22%3EWhat%20are%20Adaptive%20Cards%3F%3C%2FH2%3E%0A%3CP%3ENext%20thing%20we%20need%20to%20know%20is%2C%20what%20are%20Adaptive%20Cards%20and%20why%20would%20we%20want%20to%20use%20them%3F%20When%20we%20look%20at%20%3CA%20href%3D%22https%3A%2F%2Fadaptivecards.io%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Eadaptivecards.io%26nbsp%3B%3C%2FA%3Ewe%20can%20read%20the%20definition%20%3CEM%3EAdaptive%20Cards%20are%20platform-agnostic%20snippets%20of%20UI%2C%20authored%20in%20JSON%2C%20that%20apps%20and%20services%20can%20openly%20exchange.%20When%20delivered%20to%20a%20specific%20app%2C%20the%20JSON%20is%20transformed%20into%20native%20UI%20that%20automatically%20adapts%20to%20its%20surroundings.%20It%20helps%20design%20and%20integrate%20light-weight%20UI%20for%20all%20major%20platforms%20and%20frameworks%3C%2FEM%3E.%20This%20means%2C%20that%20we%20get%20a%20nice%20method%20to%20share%20and%20display%20information%20without%20needing%20to%20know%20how%20to%20use%20HTML%2FCSS%20to%20render%20them%20correctly%20in%20different%20host%20applications.%20If%20you%20like%20to%20know%20more%2C%20please%20read%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fmicrosoft-365-pnp-blog%2Fget-started-with-adaptive-cards%2Fba-p%2F2048786%22%20target%3D%22_blank%22%3EGet%20started%20with%20Adaptive%20Cards%3C%2FA%3E%26nbsp%3Bby%20%3CA%20href%3D%22https%3A%2F%2Ftwitter.com%2Ftomaszposzytek%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3ETomasz%20Poszytek%3C%2FA%3E%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1514999960%22%20id%3D%22toc-hId-1514999960%22%20id%3D%22toc-hId-1514999960%22%20id%3D%22toc-hId-1514999900%22%3EHow%20do%20we%20send%20an%20Adaptive%20Card%20with%20CLI%20Microsoft%20365%3F%3C%2FH2%3E%0A%3CP%3ENow%20that%20we%20know%20what%20is%20an%20Adaptive%20Card%2C%20let's%20have%20a%20look%20on%20how%20we%20get%20this%20sent%20by%20CLI.%20The%20%3CA%20href%3D%22https%3A%2F%2Fpnp.github.io%2Fcli-microsoft365%2Fcmd%2Fadaptivecard%2Fadaptivecard-send%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Edocumentation%3C%2FA%3E%26nbsp%3Bprovides%20us%20with%20a%20sample%20and%20this%20sample%20needs%20to%20have%20a%20URL.%20Where%20do%20we%20get%20this%20from%3F%20This%20depends%20on%20where%20you%20want%20to%20send%20this%20Adaptive%20Card%20to.%20In%20this%20example%2C%20I%20want%20to%20use%20Microsoft%20Teams%20as%20host%20application%20and%20therefore%20we%20will%20need%20to%20create%20an%20incoming%20webhook%20in%20Teams.%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--2089405862%22%20id%3D%22toc-hId--2089405862%22%20id%3D%22toc-hId--2089405862%22%20id%3D%22toc-hId--2089405922%22%3ECreate%20the%20Webhook%3C%2FH3%3E%0A%3CP%3EIf%20you%20have%20no%20clue%20what%20is%20a%20webhook%2C%20no%20problem%2C%20%3CA%20href%3D%22https%3A%2F%2Fwww.twitter.com%2Fwilliamsrabia%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3ERabia%20Williams%3C%2FA%3E%20got%20you%20covered%20with%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fmicrosoft-365-pnp-blog%2Fhow-to-configure-and-use-incoming-webhooks-in-microsoft-teams%2Fba-p%2F2051118%22%20target%3D%22_blank%22%3EHow%20to%20configure%20and%20use%20Incoming%20Webhooks%20in%20Microsoft%20Teams%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E*%20Open%20Microsoft%20Teams%20%3CBR%20%2F%3E*%20Click%20the%20ellipsis%20icon%20on%20the%20Teams%20channel%20that%20you%20want%20to%20send%20the%20Adaptive%20Card%20to%3CBR%20%2F%3E*%20Click%20%3CSTRONG%3EConnectors%3C%2FSTRONG%3E%3CBR%20%2F%3E*%20Search%20for%20'webhook'%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22incoming-webhook.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F255536iB8D608100CF495A5%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22incoming-webhook.png%22%20alt%3D%22incoming-webhook.png%22%20%2F%3E%3C%2FSPAN%3E%3CBR%20%2F%3E*%20Click%20%3CSTRONG%3EAdd%3C%2FSTRONG%3E%3CBR%20%2F%3E*%20Click%20%3CSTRONG%3EAdd%3C%2FSTRONG%3E%20(yes%2C%20yet%20again)%3CBR%20%2F%3E*%20Give%20your%20webhook%20a%20name%3CBR%20%2F%3E*%20If%20you%20like%20to%2C%20you%20can%20upload%20a%20picture-%20messages%20sent%20via%20this%20webhook%20(our%20Adaptive%20Card)%20will%20have%20this%20image%20then%20as%20Profile%20Pic%20-%20this%20step%20is%20optional.%20%3CBR%20%2F%3E*%20Click%20%3CSTRONG%3ECreate%3C%2FSTRONG%3E%3CBR%20%2F%3E*%20Copy%20the%20generated%20URL%3CBR%20%2F%3E*%20Click%20%3CSTRONG%3EDone%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20URL%20is%20the%20URL%20we%20will%20need%20in%20the%20command%20later%20-%20If%20you%20want%20to%2C%20paste%20it%20into%20a%20notepad%20or%20similar.%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-398106971%22%20id%3D%22toc-hId-398106971%22%20id%3D%22toc-hId-398106971%22%20id%3D%22toc-hId-398106911%22%3EAuthor%20your%20Card%3C%2FH3%3E%0A%3CP%3ENow%20it's%20time%20to%20author%20your%20card.%20You%20can%20do%20this%20in%20a%20lot%20of%20editors%2C%20I%20use%20either%20the%20%3CA%20href%3D%22https%3A%2F%2Fadaptivecards.io%2Fdesigner%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EAdaptive%20Cards%20Designer%3C%2FA%3E%20or%20the%20%3CA%20href%3D%22https%3A%2F%2Fmarketplace.visualstudio.com%2Fitems%3FitemName%3Dtomlm.vscode-adaptivecards%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAdaptive%20Cards%20Viewer%20Extension%20in%20Visual%20Studio%20Code%3C%2FA%3E%2C%20but%20recently%20also%20found%20%3CA%20href%3D%22https%3A%2F%2Fmarketplace.visualstudio.com%2Fitems%3FitemName%3Dmadewithcardsio.adaptivecardsstudiobeta%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAdaptive%20Card%20Studio%3C%2FA%3E.%20You%20can%20also%20use%20one%20of%20the%20%3CA%20href%3D%22https%3A%2F%2Fadaptivecards.io%2Fsamples%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Eprovided%20samples%3C%2FA%3E%20and%20use%20them%20as-is%20or%20adjust%20them%20to%20your%20needs.%3C%2FP%3E%0A%3CP%3EIf%20you%20feel%20like%20authoring%20your%20Card%20in%20Designer%20or%20Visual%20Studio%20Code%20is%20fine%20for%20you%20right%20now%2C%20go%20ahead%20with%20this%2C%20otherwise%20you%20can%20also%20use%20the%20examples%20that%20are%20provided%20in%20the%20%3CA%20href%3D%22https%3A%2F%2Fpnp.github.io%2Fcli-microsoft365%2Fcmd%2Fadaptivecard%2Fadaptivecard-send%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Edocumentation%20of%20CLI%20Microsoft%20365%3C%2FA%3E.%20I%20used%20the%20last%20one%2C%20'Send%20custom%20card%20with%20card%20data'.%3C%2FP%3E%0A%3CP%3EFor%20everyone%20not%20very%20familiar%20writing%20and%20understanding%20code%3A%20We%20can%20make%20more%20sense%20of%20the%20snippet%20by%20copy%2Fpaste%20this%20into%20Visual%20Studio%20Code%2C%20and%20then%20press%20Alt%2Bz%20to%20soft-wrap%20this%20and%20then%20separate%20the%20Adaptive%20Card%20from%20the%20rest%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E*%20Select%20JSON%20in%20Language%20Mode%3CBR%20%2F%3E*%20Insert%20somenew%20lines%20right%20before%20the%20first%20%60%7B%60%3CBR%20%2F%3E*%20Delete%20the%20%60'%60%20at%20the%20beginning%20and%20the%20end%20of%20the%20snippet%3CBR%20%2F%3E*%20Format%20with%20Shift%20%2B%20Alt%20%2B%20f%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENow%20go%20ahead%20and%20adjust%20the%20sample%20to%20work%20in%20your%20environment%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E*%20replace%20the%20URL%20in%20the%20code%20with%20the%20URL%20that%20we%20copied%20when%20we%20added%20the%20webhook%20connector%20to%20Teams%3CBR%20%2F%3E*%20copy%20the%20whole%20code%3CBR%20%2F%3E*%20run%20it%3C%2FP%3E%0A%3CP%3E!!%20Turned%20out%2C%20that%20there%20are%20some%20differences%20how%20to%20use%20quotes%20%60'%60%20or%20%60%22%60%20-%20please%20consider%20which%20shell%20you%20are%20using%20before%20you%20copy%2Fpaste%20the%20code%20from%20%3CA%20href%3D%22https%3A%2F%2Fpnp.github.io%2Fcli-microsoft365%2Fcmd%2Fadaptivecard%2Fadaptivecard-send%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3ECLI%20Microsoft%20365%20documentation%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECongratulations%20%3Arocket%3A-%20you%20sent%20your%20first%20adaptive%20Card%20with%20CLI.%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-387603867%22%20id%3D%22toc-hId-387603867%22%20id%3D%22toc-hId-387603867%22%20id%3D%22toc-hId-387603807%22%3E%23%23%20Feedback%20and%20what's%20next%3F%3C%2FH2%3E%0A%3CP%3EI%20hope%20you%20liked%20this%20little%20post%20on%20how%20to%20get%20started%20with%20CLI%20Microsoft%20365%20and%20learning%20how%20to%20send%20an%20Adaptive%20Card%20with%20it.%20I%20would%20like%20to%20learn%2C%20for%20which%20use%20cases%20you%20would%20do%20this%3F%20Please%20comment%20below!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2143466%22%20slang%3D%22en-US%22%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20this%20blog%20post%20I%20want%20to%20explain%20how%20you%20can%20send%20an%20Adaptive%20Card%20with%20CLI%20Microsoft%20365.%20I%20will%20guide%20you%20from%20zero%20to%20hero%20%3Arocket%3A%2C%20so%20even%20if%20you%20don't%20know%20anything%20about%20the%20CLI%20Microsoft%20365%20or%20about%20Adaptive%20Cards%2C%20don't%20stop%20reading%2C%20you%20will%20be%20able%20to%20do%20that%20in%20a%20few%20minutes-%20I%20promise!%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2143685%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20send%20Adaptive%20Cards%20with%20CLI%20Microsoft%20365%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2143685%22%20slang%3D%22en-US%22%3E%3CP%3EYou%20can%20also%20send%20them%20through%20PowerShell%20quite%20easily!%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EUsing%20either%20the%20more%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fvideo-hub%2Fmicrosoft-graph-powershell-sdk-ga-foundations-for-the-future%2Fm-p%2F1698629%23M420%22%20target%3D%22_self%22%3Erecently%20released%3C%2FA%3E%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fgraph%2Fpowershell%2Fget-started%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EGraph%20PowerShell%20SDK%3C%2FA%3E%26nbsp%3Band%20Invoke-MgGraphRequest%20or%20more%20manually%20through%20Invoke-WebRequest%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20did%20this%20with%20the%20Invoke-MgGraphRequest%26nbsp%3B%3CA%20title%3D%22Automating%20Out%20of%20Hours%20Responses%22%20href%3D%22https%3A%2F%2Fsysmansquad.com%2F2020%2F12%2F30%2Fautomating-changing-out-of-business-hours-responses%2F%23assembling-our-update-script%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Eover%20here%20on%20SysManSquad%3C%2FA%3E%20if%20anyone%20wants%20a%20walkthrough%20for%20how%20you%20can%20do%20this%20with%20unattended%20scripts%20in%20PowerShell%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Co-Authors
Version history
Last update:
‎Feb 17 2021 08:45 AM
Updated by: