概要
外部システムで任意のイベントが発生した際に、Google Chatの任意のルームにAPI経由で自動投稿する方法について解説していきます。
やり方
①投稿したいルームの「Webhookを管理」をクリック

②着信Webhookを作成する

③生成された「着信WebhookURL」をコピー(※エンドポイントとAPIトークンとAPIキーが合体したものというイメージ)

④POSTリクエストを組む
- エンドポイントURLとして先ほどの「着信WebhookURL」を指定
- ヘッダのContent-Typeで「application/json; charset=UTF-8」を指定
- BODYとして、keyがtextのbodyをセット
☆ヘッダの例
{'Content-Type': 'application/json; charset=UTF-8'}
☆Bodyの例
{'text' : 'Hello World!'}

⑤POSTリクエストを送信する
結果
