Message Posting with LINE Notify
Post message through LINE Notify
Posts a message to a LINE group through LINE Notify. Please obtain a personal access token in advance. The recipient of the message will be selected at the time of acquiring the token, either the user acquiring the token themself or a group in which that person participates.
Configs for this Auto Step
- conf_OAuth2
- C1: OAuth2 Setting *
- conf_Message
- C2. Text Message(Within 1000 characters) *#{EL}
- conf_log
- X: Access Log (update)
Script (click to open)
// Post message to LINE via LINE Notify (ver. 202304)
// OAuth2 config sample at [OAuth 2.0 Setting]
// - Authorization Endpoint URL: https://notify-bot.line.me/oauth/authorize
// - Token Endpoint URL: https://notify-bot.line.me/oauth/token
// - Scope: notify
// - Consumer Key: (Get by LINE Notify)
// - Consumer Secret: (Get by LINE Notify)
main();
function main(){
//// == Config Retrieving / 工程コンフィグの参照 ==
const oauth2 = configs.get( "conf_OAuth2" ) + "";
const message = configs.get( "conf_Message" ) + "";
const dataId_log = configs.get( "conf_log" );
//// == 演算 / Calculating ==
let accessLog = "";
//check length of message
messageCheck(message);
//send message to LINE Notify API
let response = httpClient.begin()
.authSetting( oauth2 )
.multipart("message", message)
.post('https://notify-api.line.me/api/notify');
accessLog += "---POST request--- " + response.getStatusCode() + "\n";
accessLog += response.getResponseAsString() + "\n";
engine.log("res:" + response.getResponseAsString());
const status = response.getStatusCode();
if( status >= 300 ){
engine.log(accessLog);
throw `Failed in POST request. status: ${status}`;
}
//// == ワークフローデータへの代入 / Data Updating ==
if ( dataId_log !== "" ) {
engine.setDataByNumber( dataId_log, accessLog );
}
}
function messageCheck(message) {
if (message == null) {
throw "Message is empty."
} else if (message.length > 1000) {
throw("Message Length over 1000");
}
}
Download
- Line-pushNotify-202304.xml
- 2023-04-05 (C) Questetra, Inc. (MIT License)
(Installation of add-on automated processes is only available in Professional edition)
Notes
- How to register an application on the LINE side
- Log in to LINE Notify (https://notify-bot.line.me/en/) with your LINE account
- Open “Registration Service Management”
- Enter “Service Name” and other information from “Register Service”.
※ Any content other than “CallbackURL” is acceptable
※ Specify “CallbackURL” : https://s.questetra.net/oauth2callback
- How to Setup HTTP Authentication on Questetra side
※ Reference page: Understanding HTTP Authorization Settings (https://support.questetra.com/developer-blog/http-auth-setting/)- Select “OAuth2”
- Name: : LINE Notify (any name is acceptable as long as it matches the “OAuth2 settings” in the add-on XML on the workflow application side)
- Authorized Endpoint URL: https://notify-bot.line.me/oauth/authorize
- Token endpoint URL: https://notify-bot.line.me/oauth/token
- Scope: notify
- Client ID: (Specify the one obtained from the settings on the LINE side)
- Client Secret: (Specify the one obtained from the settings on the LINE side)
Capture
