初めて 作成してみて困ったのでまとめです。
コネクタの作成
送信したいチャネルの ・・・ を選択して、コネクタを選択します。
Incoming Webhookを選択します。
必要な設定をして作成します。
作成後、変更が必要な場合は 構成済みを選択すると出てきます。
コネクタの作成は完了です。
Perlのソース作成
test.cgi
use utf8;
use Time::Local;
use Encode qw/encode decode/;
use LWP::UserAgent;
# アドレス
my $url = 'https://'; # コネクタ作成で取得したアドレス。
#-------------------------------------------
# 送信用JSONヘッダ
#-------------------------------------------
my $poststr = '{';
$poststr = $poststr . ' "type":"message",';
$poststr = $poststr . ' "attachments":[';
$poststr = $poststr . ' {';
$poststr = $poststr . ' "contentType":"application/vnd.microsoft.card.adaptive",';
$poststr = $poststr . ' "contentUrl":null,';
$poststr = $poststr . ' "content":{'; # ここから
$poststr = $poststr . ' "type": "AdaptiveCard",';
$poststr = $poststr . ' "version": "1.2",';
$poststr = $poststr . ' "body": [';
$poststr = $poststr . ' {';
$poststr = $poststr . ' "type": "TextBlock",';
$poststr = $poststr . ' "size": "Large",';
$poststr = $poststr . ' "weight": "Bolder",';
$poststr = $poststr . ' "text": "今日の予定"';
$poststr = $poststr . ' },';
$poststr = $poststr . ' ]';
$poststr = $poststr . '}';
$poststr = $poststr . '';
$poststr = $poststr . ' }'; # ここまで
$poststr = $poststr . ' ]';
$poststr = $poststr . '}';
$poststrB = encode('UTF-8', $poststr);
my $ua = LWP::UserAgent->new;
$ua->default_header('Content-Type' => 'application/json; charset=utf-8 ');
my $res = $ua->post(
$url,
Content => $poststrB
);
Perlがよくわかってないので この段階に来るのにしばらくかかりました。
デザイン
デザインするのには
https://adaptivecards.io/designer/
が いいかと思います。
変更する場合、ソース中の # ここから # ここまで の中を変更する感じになります。