Home>

I'm trying to make a LINE bot.
bot and send a message LINE code written in GAS is executed, to create a bot that will be the answer as "Hello" is the first goal.

Error message When you send a message to
bot, it is in a state where it has only been read and there is no response.
Applicable source code
function doPost (e) {
  var replyToken = JSON.parse (e.postData.contents) .events [0] .replyToken;
  if (typeof replyToken === 'undefined') {
    return;
  }
  var url = 'https://api.line.me/v2/bot/message/reply';
  var channelToken = 'Paste the access token (long term) here';
  var messages = [{
    'type': 'text',
    'Text': 'Hello',
  }];
  UrlFetchApp.fetch (url, {
    'headers': {
      'Content-Type': 'application/json;charset = UTF-8',
      'Authorization': 'Bearer' + channelToken,
    },
    'method': 'post',
    'payload': JSON.stringify ({
      'replyToken': replyToken,
      'messages': messages,
    }),
  });
  return ContentService.createTextOutput (JSON.stringify ({'content': 'post ok'})). setMimeType (ContentService.MimeType.JSON);
}
Supplemental information (FW/tool version etc.)

Refer to the following site and made it as written here.

  • Answer # 1

    It was because the version was not set to New when releasing the GAS source.

  • Answer # 2

    Have you forgotten the settings for the webhook and auto-response message in "Registering Linkage Information to LINE Account" on the reference site?

Related articles