Last active
November 27, 2024 03:53
-
-
Save daichan4649/18bd961f56d308d05878535f313cfb04 to your computer and use it in GitHub Desktop.
[GAS][line] お店の人呼び出し (sample)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function doGet(e) { | |
// 画面に表示 | |
const resultText = 'しばらくお待ちください' | |
return ContentService.createTextOutput(resultText); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function doGet(e) { | |
// アクセストークン取得 | |
const properties = PropertiesService.getScriptProperties(); | |
const accessToken = properties.getProperty("ACCESS_TOKEN"); | |
// ブロードキャストメッセージ送信 | |
const message = "お客さまがお呼びです"; | |
sendBroadcastMessage(accessToken, message); | |
// 画面に表示 | |
const resultText = 'しばらくお待ちください' | |
return ContentService.createTextOutput(resultText); | |
} | |
// ブロードキャストメッセージ送信 | |
// https://developers.line.biz/ja/reference/messaging-api/#send-broadcast-message | |
function sendBroadcastMessage(accessToken, message) { | |
const url = "https://api.line.me/v2/bot/message/broadcast"; | |
const headers = { | |
"Content-Type": "application/json", | |
"Authorization": `Bearer ${accessToken}` | |
}; | |
const payload = { | |
"messages": [{ | |
"type": "text", | |
"text": message | |
}] | |
}; | |
const options = { | |
"method": "post", | |
"headers": headers, | |
"payload": JSON.stringify(payload) | |
}; | |
UrlFetchApp.fetch(url, options); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment