共用方式為


AdaptiveCard 元素

備註

你正在建立由 Adaptive Cards 驅動的 Copilot、Teams 或者 Outlook 情境嗎? 造訪 自適應卡檔案中心,這裡是您所有自適應卡需求的一站式服務點! 它擁有你所需的所有資源,包括許多新功能的完整文件,例如響應式版面、圖示徽章旋轉木馬圖表等等!

本頁記錄了 AdaptiveCard 該元素,即自適應卡的根元素。

關於無障礙的重要說明: 在結構的 1.3 版本中,我們在 Inputs 上引入 了標籤 屬性以提升可及性。 如果你目標的 主機應用程式 支援 v1.3,建議使用 label 而非 TextBlock ,如下方範例所示。 當大多數 Host 應用程式更新到最新版本後,我們會相應更新樣本。

調適型卡片

一張自適應卡,包含自由形式的卡牌元素,以及一組可選的行動。

AdaptiveCard 屬性

房產 類型 為必填項目 Description 版本
type "AdaptiveCard" Yes 必須是 "AdaptiveCard" 1.0
version string Yes 這張卡所需的架構版本。 如果客戶端的版本低於此版本,則fallbackText會被渲染。 注意:在Action.ShowCard中的卡片不需要版本資訊。 不過, 這是頂層 卡的必備條件。 1.0
重新整理 Refresh 定義如何透過向目標機器人提出請求來刷新卡片。 1.4
認證 Authentication 定義認證資訊,以實現單點登入或即時 OAuth。 1.4
body Element[] 卡片元素要顯示在主要卡片區域。 1.0
行動 Action[] 卡片動作列中會顯示的動作。 1.0
選擇動作 ISelectAction 當該卡被輕觸或選擇時,會啟動一個行動。 不支援 Action.ShowCard 1.1
備用文字 string 當客戶端不支援指定版本(可能包含 markdown)時顯示的文字。 1.0
背景圖片 BackgroundImageuri 指定卡片的背景圖片。 1.2, 1.0
中繼資料 Metadata 定義了通常不會用於繪製卡片的各種元資料屬性 1.6
最小高度 string 指定卡片的最小高度。 1.2
RTL boolean? 當應該將true這張自適應卡的內容從右到左呈現時。 當自適應卡中的「虛假」內容需要從左到右呈現時。 若未設定,則會依照預設平台行為。 1.5
通話 string 指定這張卡片上應說的內容。 這是簡單的文字或 SSML 片段。 1.0
語言 string 卡片中使用的兩字母 ISO-639-1 語言。 用來本地化任何日期/時間函式。 1.0
垂直內容對齊 VerticalContentAlignment 定義內容在容器內垂直排列的方式。 僅適用於固定高度的卡片,或指定了 minHeight 的卡片。 1.1
$schema uri 自適應卡架構。 1.0

Example

基本 AdaptiveCard 範例(JSON)

{
	"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
	"type": "AdaptiveCard",
	"version": "1.0",
	"body": [
		{
			"type": "Container",
			"items": [
				{
					"type": "TextBlock",
					"text": "Publish Adaptive Card schema",
					"weight": "bolder",
					"size": "medium"
				},
				{
					"type": "ColumnSet",
					"columns": [
						{
							"type": "Column",
							"width": "auto",
							"items": [
								{
									"type": "Image",
									"url": "https://pbs.twimg.com/profile_images/3647943215/d7f12830b3c17a5a9e4afcc370e3a37e_400x400.jpeg",
									"altText": "Matt Hidinger",
									"size": "small",
									"style": "person"
								}
							]
						},
						{
							"type": "Column",
							"width": "stretch",
							"items": [
								{
									"type": "TextBlock",
									"text": "Matt Hidinger",
									"weight": "bolder",
									"wrap": true
								},
								{
									"type": "TextBlock",
									"spacing": "none",
									"text": "Created {{DATE(2017-02-14T06:08:39Z, SHORT)}}",
									"isSubtle": true,
									"wrap": true
								}
							]
						}
					]
				}
			]
		},
		{
			"type": "Container",
			"items": [
				{
					"type": "TextBlock",
					"text": "Now that we have defined the main rules and features of the format, we need to produce a schema and publish it to GitHub. The schema will be the starting point of our reference documentation.",
					"wrap": true
				},
				{
					"type": "FactSet",
					"facts": [
						{
							"title": "Board:",
							"value": "Adaptive Card"
						},
						{
							"title": "List:",
							"value": "Backlog"
						},
						{
							"title": "Assigned to:",
							"value": "Matt Hidinger"
						},
						{
							"title": "Due date:",
							"value": "Not set"
						}
					]
				}
			]
		}
	],
	"actions": [
		{
			"type": "Action.ShowCard",
			"title": "Comment",
			"card": {
				"type": "AdaptiveCard",
				"body": [
					{
						"type": "Input.Text",
						"id": "comment",
						"isMultiline": true,
						"placeholder": "Enter your comment"
					}
				],
				"actions": [
					{
						"type": "Action.Submit",
						"title": "OK"
					}
				]
			}
		},
		{
			"type": "Action.OpenUrl",
			"title": "View",
			"url": "https://adaptivecards.io"
		}
	]
}

屬性

版本

這張卡所需的架構版本。 如果客戶端的版本低於此版本,fallbackText將會呈現。 注意:在 Action.ShowCard 內的卡片不需要版本版本。 不過, 這是頂層 卡的必備條件。

  • 類型string
  • 必要條件:不

重新整理

定義如何透過向目標機器人提出請求來刷新卡片。

  • 類型Refresh
  • 版本:1.4
  • 必要條件:不
  • 允許的值
    • Refresh

刷新範例(JSON)

{
	"type": "AdaptiveCard",
	"version": "1.3",
	"refresh": {
		"action": {
			"type": "Action.Execute",
			"verb": "refreshCard"
		},
		"userIds": [
			"user1",
			"user2"
		]
	},
	"body": [
		{
			"type": "TextBlock",
			"text": "This is a card that will be refreshed."
		}
	]
}

認證

定義認證資訊,以實現單點登入或即時 OAuth。

  • 類型Authentication
  • 版本:1.4
  • 必要條件:不
  • 允許的值
    • Authentication

認證範例(JSON)

{
	"type": "AdaptiveCard",
	"version": "1.4",
	"authentication": {
		"connectionName": "myConnection",
		"text": "Please Authenticate your account",
		"tokenExchangeResource": {
			"id": "myTokenId",
			"providerId": "myProviderId",
			"uri": "https: //mytoken.exchange/resource"
		},
		"buttons": [
			{
				"type": "signin",
				"title": "Click here to Sign In!"
			}
		]
	},
	"body": [
		{
			"type": "TextBlock",
			"text": "This is a card that has authentication"
		}
	]
}

body

卡片元素要顯示在主要卡片區域。

  • 類型Element[]
  • 必要條件:不
  • 允許的值
    • ActionSet
    • ColumnSet
    • Container
    • FactSet
    • Image
    • ImageSet
    • Input.ChoiceSet
    • Input.Date
    • Input.Number
    • Input.Text
    • Input.Time
    • Input.Toggle
    • Media
    • RichTextBlock
    • Table
    • TextBlock

行為

操作會顯示在卡片的操作欄中。

  • 類型Action[]
  • 必要條件:不
  • 允許的值
    • Action.Execute
    • Action.OpenUrl
    • Action.ShowCard
    • Action.Submit
    • Action.ToggleVisibility

選擇動作

當該卡被輕觸或選擇時,會啟動一個行動。 不支援 Action.ShowCard

  • 類型ISelectAction
  • 版本:1.1
  • 必要條件:不
  • 允許的值
    • Action.Execute
    • Action.OpenUrl
    • Action.Submit
    • Action.ToggleVisibility

備援文字

當客戶端不支援指定版本(可能包含 markdown)時顯示的文字。

  • 類型string
  • 必要條件:不

背景圖片

指定卡片的背景圖片。

  • 類型BackgroundImageuri
  • 版本:1.2、1.0
  • 必要條件:不
  • 允許的值
    • BackgroundImage
    • uri

中繼資料

定義了通常不會用於繪製卡片的各種元資料屬性

  • 類型Metadata
  • 版本:1.6
  • 必要條件:不
  • 允許的值
    • Metadata

最小高度

指定卡片的最小高度。

  • 類型string
  • 版本:1.2
  • 必要條件:不

minHeight 範例(JSON)

{
	"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
	"type": "AdaptiveCard",
	"version": "1.2",
	"minHeight": "100px",
	"body": [
		{
			"type": "TextBlock",
			"wrap": true,
			"text": "This card has a minHeight of 100px"
		}
	]
}

轉接

true 這張自適應卡的內容應該從右到左呈現時。 當自適應卡中的虛假內容需要從左到右呈現時。 若未設定,則會依照預設平台行為。

  • 類型boolean?
  • 版本:1.5
  • 必要條件:不

rtl 範例 (JSON)

{
  "type": "AdaptiveCard",
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "version": "1.5",
  "rtl": true,
  "body": [
    {
      "type": "TextBlock",
      "text": "هذه كتلة نص",
      "wrap": true
    },
    {
      "type": "TextBlock",
      "text": "זהו בלוק טקסט",
      "wrap": true
    },
    {
      "type": "TextBlock",
      "text": "This is a text block",
      "wrap": true
    }
  ]
}

語音

明確規定整張卡應該說什麼。 這是簡單的文字或 SSML 片段。

  • 類型string
  • 必要條件:不

lang

卡片中使用的兩字母 ISO-639-1 語言。 用來本地化任何日期/時間函式。

  • 類型string
  • 必要條件:不

垂直內容對齊

定義內容在容器內垂直排列的方式。 僅適用於固定高度的卡牌,或是指定了 minHeight 的卡牌。

  • 類型VerticalContentAlignment
  • 版本:1.1
  • 必要條件:不
  • 允許的值
    • "top"
    • "center"
    • "bottom"

$schema

自適應卡架構。

  • 類型uri
  • 必要條件:不