@reuters-graphics/teams-klaxon
    Preparing search index...

    @reuters-graphics/teams-klaxon

    npm version Reuters open source software

    Create and send Adaptive Cards to a Microsoft Teams channel.

    Create an incoming webhook with Workflows for Microsoft Teams:

    1. In your Teams channel, click the ... menu and select Workflows
    2. Search for "Post to a channel when a webhook request is received"
    3. Configure the workflow to post to your desired channel and copy the webhook URL
    pnpm add @reuters-graphics/teams-klaxon
    

    Import and create a new TeamsKlaxon instance with your webhook URL.

    import { TeamsKlaxon } from '@reuters-graphics/teams-klaxon';

    // Your Teams Workflow webhook URL
    const webhook = 'https://...';

    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;
    // 202

    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