var LINE_ACCESS_TOKEN = "JUcAiDYEDrl7z88nr8mCaaqYwzVPSRNJb9OwPI+10gMRvUfIBcIEKLyMc2JS5BfNFVPwpyJ8txjus+KGh7pE4dtYbnJKhZ4bEd/4t1MqQGtg0MmU2RRlyXUI3aK6GhJMgU/9UH5bGJY7OcMBOG8bXQdB04t89/1O/w1cDnyilFU=";

var ss = SpreadsheetApp.openByUrl("https://[Log in to view URL]");

var sh = ss.getSheetByName("ซีต1");

function doPost(e) {
    if (typeof e === "undefined") {

        return;
    } else {

        var json = JSON.parse(e.postData.contents);

        replyFromSheet(json)
    }
}

function replyFromSheet(data) {
    var replyUrl = "https://[Log in to view URL]";

    var lastRow = sh.getLastRow();

    var wordList = sh.getRange(1, 1, lastRow, 2).getValues();

    var reply_token = data.events[0].replyToken;
    var text = data.events[0].message.text;

    var replyTextList = [];

    for (var i = 1; i < wordList.length; i++) {
        if (wordList[i][0] == text) {
            replyTextList.push(wordList[i][1]);
        }
    }

    if (replyTextList.length < 1) {
        return;

    } else if (replyTextList.length > 5) {
        var messageLength = 5;
    } else {
        var messageLength = replyTextList.length;
    }


    var messageArray = [];


    for (var j = 0; j < messageLength; j++) {
        messageArray.push({
            "type": "text",
            "text": replyTextList[j]
        });
    }

    var headers = {
        "Content-Type": "application/json; charset=UTF-8",
        "Authorization": "Bearer " + LINE_ACCESS_TOKEN,
    };

    var postData = {
        "replyToken": reply_token,
        "messages": messageArray
    };

    var options = {
        "method": "post",
        "headers": headers,
        "payload": JSON.stringify(postData)
    };

    UrlFetchApp.fetch(replyUrl, options);
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: