![見出し画像](https://assets.st-note.com/production/uploads/images/95479734/rectangle_large_type_2_1f31e2d2baa23012df6639a04eaf5ff5.jpeg?width=1200)
【コピペ用】お問合せ効率化bot
以下のコードをコード.gs内にコピペしてください。
チャンネルアクセストークンはご自身のものに置き換えてください。
const ACCESS_TOKEN = "チャンネルアクセストークン";
const bot = new LineBotSdk.client(ACCESS_TOKEN);
function doPost(e) { bot.call(e, callback) };
function callback(e) {
if (e.type == 'message') {
const { type, text } = e.message;
if (type == "text") {
if (["サービス内容について", "来店予約について"].includes(text)) sendLastMessage(e);
}
}
if (e.type == "postback") {
const { data } = e.postback;
if (data == "tap_richmenu") questionnaire(e);
}
};
function questionnaire(e) {
let messages = [];
messages.push(bot.textMessage(
`ご連絡ありがとうございます。\nご相談をスムーズに進めるため、ご質問させていただきます。`
));
messages.push(bot.textMessage(`今回はどのようなご相談でしょうか?`));
messages[1]["quickReply"] = {
"items": [
{
"action": {
"type": "message",
"label": "サービス内容について",
"text": "サービス内容について",
}
},
{
"action": {
"type": "message",
"label": "来店予約について",
"text": "来店予約について",
}
},
]
}
bot.replyMessage(e, messages);
}
function sendLastMessage(e) {
let messages = [];
messages.push(bot.textMessage(`ご回答ありがとうございます\n後ほど担当者からご返信させていただきます。`));
bot.replyMessage(e, messages);
}
リッチメニュー.gs という名前で新しいファイルを作成し、
以下のコードをコピペしてください。
const RICHMENU_WIDTH = 1250;
const RICHMENU_HEIGHT = 422;
function createAllProcess() {
const richmenuId = createRichMenu();
uploadRichmenuImage(richmenuId);
bot.setDefaultRichMenu(richmenuId);
}
function createRichMenu() {
let richmenu = bot.richmenu({
"name": "リッチメニューA",
"barText": "メニュー(開く / 閉じる)",
"size": { "width": RICHMENU_WIDTH, "height": RICHMENU_HEIGHT },
"selected": true,
"areas": [
bot.area({ "x": 0, "y": 0, "width": RICHMENU_WIDTH, "height": RICHMENU_HEIGHT,
"action": { "type": "postback", "data": "tap_richmenu", "displayText": "お問い合わせ" } }),
]
})
let res = bot.createRichMenu(richmenu);
return JSON.parse(res).richMenuId;
}
function uploadRichmenuImage(richmenuId) {
const file = DriveApp.getFileById("1KozgQsgD1Bbw9N0G-q0cbyzsnP9n6n1Q");
const blob = Utilities.newBlob(
file.getBlob().getBytes(),
file.getMimeType(),
file.getName()
);
bot.setRichMenuImage(richmenuId, blob);
}
以下は、質問を複数回に増やす応用編です。
ご質問は公式LINEにて受け付けております。
お気軽にご連絡ください。
質問を増やす方法
以下のコードを コード.gs にコピペしてください。
チャンネルアクセストークンはご自身のものに置き換えてください。
ここから先は
1,941字
¥ 350
いただいたサポートは、自己投資と災害復興支援に使わせていただきます。