
อยากให้ระบบ มีการแจ้งเตือนไปยัง line เมื่อมี event สำคัญๆ เกิดขึ้นในระบบ เช่น มี order เข้ามา หรือมีการจอง line notify ช่วยได้ครับ
1. Login https://notify-bot.line.me/en/
2. เลือกเมนู หน้าของฉัน
3.กดปุ้ม ออก token
4.ระบุชื่อเวลาแจ้งเตือน เช่น ชื่อร้านอาหาร ในที่นี้ใช้ irestbox
จากนั้นเลือกส่งไลน์หาตัวเอง หรือกลุ่มที่ต้องการ กดปุ่ม ออก Token
5. จะได่ Token ดังรูป ให้ copy ไว้ใช้งานต่อไป
6.ฝั่ง node ผมทำ api ไว้ ส่ง token กับ message มาจากฝั่ง client (web หรือ app)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
var express = require('express'); var request = require('request'); var router = express.Router(); router.post('/', function(req, res, next) { var token = req.body.token; var message = req.body.message; request({ method: 'POST', uri: 'https://notify-api.line.me/api/notify', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, auth: { 'bearer': token }, form: { message: message } }, (err, httpResponse, body) => { if(err){ console.log(err); } else { res.json({ httpResponse: httpResponse, body: body }); } }); }); module.exports = router; |
ตัวที่ทำไว้ส่งแค่ข้อความนะครับ
อยากส่ง advance กว่านี้ image sticker ศึกษาได้ที่ https://notify-bot.line.me/doc/en/
จบแล้วครับ