go-adaptivecards

module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2026 License: MIT

README

go-adaptivecards README header

go-adaptivecards

Experimental Go library for building and validating Microsoft Adaptive Cards.

Important Status

This project is experimental and not production-ready.

  • API and behavior can change without notice.
  • Breaking changes are expected.
  • The implementation is not at 100% Microsoft Adaptive Cards feature parity.
  • Use with caution, especially in production systems.

Scope

This repository provides:

  • Strongly typed Go models for selected Adaptive Card features
  • Builder-style APIs for composing cards
  • Logical validation and JSON Schema validation support against schema versions 1.5.0
  • JSON factory-based decoding for interface fields (Element, Action)
  • Optional webhook posting helper for Teams/workflow endpoints

Install

go get github.com/untcha/go-adaptivecards

Quick Example

Quick "Hello, World!" example (from examples/simple/main.go):

package main

import (
	"context"
	"fmt"
	"os"

	"github.com/untcha/go-adaptivecards/adaptivecards/card"
	"github.com/untcha/go-adaptivecards/adaptivecards/elements"
	"github.com/untcha/go-adaptivecards/adaptivecards/webhook"
)

func main() {
	// Webhook URL
	url := os.Getenv("TEAMS_TEST_WORKFLOW_URL")

	textblock := elements.NewTextBlock("Hello, World!")

	card, err := card.NewCard().
		AddElement(textblock).
		Build()

	if err != nil {
		panic(err)
	}

	json, _ := card.MarshalJSON()
	fmt.Println(string(json))

	// Post to Teams webhook if URL is provided
	if url != "" {
		if err := webhook.PostToWorkflowRaw(context.Background(), url, card); err != nil {
			panic(err)
		}
	}
}

Feature Matrix (Current State)

Legend:

  • [x] Type/feature exists in this repo
  • [ ] Not implemented yet
  • Checked items can still be partial vs full official schema behavior
AdaptiveCard Root
  • AdaptiveCard
  • body
  • actions
  • selectAction
  • backgroundImage
  • minHeight
  • rtl
  • lang
  • speak
  • fallbackText
  • verticalContentAlignment
  • refresh (placeholder only)
  • authentication (placeholder only)
  • metadata (placeholder only)
Actions
  • Action.OpenUrl
  • Action.Submit
  • Action.ToggleVisibility
  • Action.ShowCard
  • Action.Execute
Elements
  • TextBlock
  • RichTextBlock
  • TextRun
  • Image
  • Media
Containers
  • Container
  • Column
  • ColumnSet
  • ActionSet
  • FactSet
  • ImageSet
  • Table (including TableRow, TableCell, TableColumnDefinition)
Inputs
  • Input.Text
  • Input.Number
  • Input.Date
  • Input.Time
  • Input.ChoiceSet
  • Input.Toggle
Tooling / Validation
  • Logical validation methods on card/types
  • JSON factory decode for action/element interfaces
  • Embedded Adaptive Card schema validation support
  • Webhook helper (webhook.PostToWorkflowRaw)

Package Layout

  • adaptivecards/card: AdaptiveCard root model and card-level builders/validation
  • adaptivecards/actions: action types and action factory
  • adaptivecards/elements: leaf elements and element validation
  • adaptivecards/containers: container-style elements, including Table
  • adaptivecards/inputs: input elements and validation
  • adaptivecards/core/model: shared enums, value objects, low-level validation
  • adaptivecards/core/element: element interfaces, fallback model, element factory
  • adaptivecards/schema: schema validation integration
  • adaptivecards/webhook: helpers to send card JSON to webhook endpoints

Development

Common commands:

task test
task lint
task check
task update:schema

License

This project is licensed under the MIT License - see the LICENSE file for details.

Directories

Path Synopsis
Package adaptivecards is the repository root namespace.
Package adaptivecards is the repository root namespace.
actions
Package actions provides Adaptive Card action models, validation, and polymorphic JSON decoding helpers.
Package actions provides Adaptive Card action models, validation, and polymorphic JSON decoding helpers.
card
Package card contains the AdaptiveCard root type, card-level builders, and card-level validation/JSON behavior.
Package card contains the AdaptiveCard root type, card-level builders, and card-level validation/JSON behavior.
containers
Package containers provides container-style Adaptive Card elements.
Package containers provides container-style Adaptive Card elements.
core/element
Package element defines the shared Element interface and related infrastructure for polymorphic element handling.
Package element defines the shared Element interface and related infrastructure for polymorphic element handling.
core/model
Package model contains shared core types used across the library.
Package model contains shared core types used across the library.
elements
Package elements provides leaf Adaptive Card elements and their fluent APIs.
Package elements provides leaf Adaptive Card elements and their fluent APIs.
inputs
Package inputs provides Adaptive Card input elements and related validation.
Package inputs provides Adaptive Card input elements and related validation.
schema
Package schema provides JSON Schema validation integration for Adaptive Card payloads against the embedded official schema.
Package schema provides JSON Schema validation integration for Adaptive Card payloads against the embedded official schema.
webhook
Package webhook provides helpers to send Adaptive Card payloads to workflow/webhook endpoints (for example Microsoft Teams workflows).
Package webhook provides helpers to send Adaptive Card payloads to workflow/webhook endpoints (for example Microsoft Teams workflows).
examples
full_width command
simple command
simple_table command
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL