Create and send Adaptive Cards to a Microsoft Teams channel.
Setup a Microsoft Teams incoming webhook in a channel, then install the library.
yarn add @reuters-graphics/teams-klaxon
Import and create a new TeamsKlaxon
instance with your webhook URL.
import { TeamsKlaxon } from '@reuters-graphics/teams-klaxon';
// Your incoming webhook
const webhook = 'https://outlook.office.com/webhook/...';
const klaxon = new TeamsKlaxon(webhook);
Use element constructors to create your card's content...
import { Elements } from '@reuters-graphics/teams-klaxon';
const cardContent = [
Elements.TextBox('Hello _world_!', { size: 'Large' }),
];
... or create your card content from scratch.
const cardContent = [
{
type: 'TextBox',
text: 'Hello _world_!',
size: 'Large',
},
];
Then make and post your card.
klaxon.makeCard(cardContent);
const response = await klaxon.postCard();
response.status
// 200
Read the API docs for more info.
Element constructors cover a subset of the available Adaptive Card schema, including:
Elements | |
---|---|
TextBlock | ✅ |
Image | ✅ |
Containers | |
---|---|
ActionSet | ✅ |
Container | ✅ |
ColumnSet | ✅ |
Column | ✅ |
FactSet | ✅ |
Fact | ✅ |
ImageSet | ✅ |
Generated using TypeDoc