0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【GAS】Googleフォームの回答を整形してSlack / LINE / Chatworkへ即時通知する方法(Webhook / API対応)

0
Posted at

はじめに
Googleフォームに回答があった際、外部有料SaaSを使わずにGoogle Apps Script(GAS)だけでSlack、LINE、Chatworkへ即座にリッチ通知を送る実装方法を解説します。

処理の全体構成
フォーム送信時イベント(onFormSubmit)で回答内容を取得

質問名と回答テキストを抽出して整形

UrlFetchApp.fetch() を使用して各チャットツールのWebhook / REST APIへPOST送信

コアロジック(Slack Incoming Webhook 送信例)

function onFormSubmit(e) {
const itemResponses = e.response.getItemResponses();
const fields = itemResponses.map(item => {
return {
type: 'mrkdwn',
text: *${item.getItem().getTitle()}:*\n${item.getResponse()}
};
});

const payload = {
blocks: [
{
type: 'header',
text: { type: 'plain_text', text: '📋 新規フォーム回答を受信しました' }
},
{
type: 'section',
fields: fields
}
]
};

UrlFetchApp.fetch('YOUR_SLACK_WEBHOOK_URL', {
method: 'post',
contentType: 'application/json',
payload: JSON.stringify(payload)
});
}

まとめ・LINE / Chatwork対応完全版
Slackのリッチブロック表示、LINE Messaging API、Chatwork info記法に同時対応した完全版コードと詳細な導入手順は note(B2B Tools) にて公開しています。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?