-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
28 lines (21 loc) · 723 Bytes
/
Copy pathapp.js
File metadata and controls
28 lines (21 loc) · 723 Bytes
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
'use strict'
const http = require('http')
const Bot = require('messenger-bot')
let bot = new Bot({
token: 'EAAaAsPUI8YYBAPfEKDd6HJrrLWhSzZC3YfGD922rZBPkRmx4uLzrwkIR5BoZBljGAaJ5Pf2fYAqLoJXA7r3XYMn0gloeLCjMhyVRp8WOWETUxGTxqwXjSCiorO1rlGoIh1yRFk7GqIXy3tHRxz3M50rkQZDZD',
verify: 'VERIFY_TOKEN'
})
bot.on('error', (err) => {
console.log(err.message)
})
bot.on('message', (payload, reply) => {
let text = payload.message.text
bot.getProfile(payload.sender.id, (err, profile) => {
if (err) throw err
reply({ text }, (err) => {
if (err) throw err
console.log(`Echoed back to ${profile.first_name} ${profile.last_name}: ${text}`)
})
})
})
http.createServer(bot.middleware()).listen(3000)