Skip to content

Instantly share code, notes, and snippets.

@daichan4649
Last active November 27, 2024 03:53
Show Gist options
  • Save daichan4649/18bd961f56d308d05878535f313cfb04 to your computer and use it in GitHub Desktop.
Save daichan4649/18bd961f56d308d05878535f313cfb04 to your computer and use it in GitHub Desktop.
[GAS][line] お店の人呼び出し (sample)
function doGet(e) {
// 画面に表示
const resultText = 'しばらくお待ちください'
return ContentService.createTextOutput(resultText);
}
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