LoginSignup
4
1

More than 1 year has passed since last update.

Adaptive Card: Teams の Input で Validation が使えるようになりました!

Last updated at Posted at 2021-10-26

背景

Power Automate で Teams に投稿する場合、User からの反応を受け取る場合に入力確認が面倒でしたが、
Adaptive Card 1.3 が対応されたことで、この問題の解決策である Validation が使えるようになりました😁

Adaptive Card Designer も大きく変わって 1.5 まで切り替えて編集できるようになってます。

image.png

Documents

英語版

環境

上記によると、1.4 対応ってなってますが・・
image.png

自分の環境では、1.3 までの対応で、1.4 は以下のようなエラーになります・・

image.png

追記

それはFlowbotの制限じゃなかろうかと〜。Composerで作ったbotをTeamsに配置すれば多分1.4で動くと思います

Hiro さんに教えてもらったので追記。会社で使えそうにないので試してないです・・

Designer における Input の変更点

image.png

変更点について

  • Label
    • Input の説明書きなどを書く為の Property。これまで、Placeholder で代わりにやっていた場合は置き換え推奨。
  • Validation
    • Required
      • 必須かどうか?
    • Error message
      • 検証エラー時のメッセージ
    • Pattern → "regex"
      • 正規表現で記述。ここの Document がまだ見つからないけれど、一般的なので使える感じ。

Validation

Designer が高機能になった!と喜んでたけど、max/min が対応してないとか・・。頑張って書きましょう😅

Input Properties Designer Teams 所感
Date min
max
Number min
max
Text regex "^", "$" は使えなかった・・。Designer ではなぜか "Pattern"・・
maxLength この程度未対応というのが不思議
Time min
max

image.png

利用例

設定例

Pattern・・含まれてればOKになってしまうので、何か方法がありそうではあるが現状不明
^\w+\d{2}$

image.png

動作確認時のAdaptiveCard
{
    "type": "AdaptiveCard",
    "version": "1.3",
    "msteams": {
        "width": "full"
    },
    "body": [
        {
            "type": "Input.Text",
            "label": "ItemName を入れてください",
            "isRequired": true,
            "id": "InputName",
            "placeholder": "Alphabetical12",
            "regex": "^\\w+\\d{2}$",
            "errorMessage": "アルファベット一文字以上に続き二桁の数字を入れてください。",
            "maxLength": "8"
        },
        {
            "type": "Input.Number",
            "placeholder": "25",
            "label": "年齢を入れてください",
            "id": "InputAge",
            "errorMessage": "20-99歳で",
            "isRequired": true,
            "min": "20",
            "max": "99"
        },
        {
            "type": "Input.Date",
            "errorMessage": "2021/11/1 より後で",
            "min": "2021/11/1",
            "max": "2021/12/1",
            "id": "InputDate"
        },
        {
            "type": "Input.Time",
            "errorMessage": "12:00 - 14:00 で",
            "min": "12:00",
            "max": "14:00",
            "id": "InputTime"
        },
        {
            "type": "ActionSet",
            "actions": [
                {
                    "type": "Action.Submit",
                    "title": "Action.Submit"
                }
            ]
        }
    ],
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
}

Designer 上

エラー

image.png

正常

image.png

Teams 上

エラー

maxLength は効かないけど、それ以外はいい感じ
image.png

正常

image.png

4
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1