Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Tomokatsu-Sakamoto/aeb8c911e787714a86d1ede9e4526798 to your computer and use it in GitHub Desktop.
Save Tomokatsu-Sakamoto/aeb8c911e787714a86d1ede9e4526798 to your computer and use it in GitHub Desktop.
//chatにメッセージを送信する
function sendChatMessage() {
const sheet = SpreadsheetApp.getActiveSheet(); // アクティブなシートを取得
//投稿先指定
const url = sheet.getRange("B1").getValue();
//送信内容作成
let message =
{
'text': sheet.getRange("B2").getValue()
};
let params = {
'method': 'POST',
'muteHttpExceptions' : true,
'headers': {
'Content-Type': 'application/json; charset=UTF-8'
},
'payload': JSON.stringify(message)
};
//送信
try {
let result = UrlFetchApp.fetch(url, params);
Logger.log(result);
sheet.getRange("B3").setValue(result);
}
catch (e) {
Logger.log(e);
sheet.getRange("B3").setValue(e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment