Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathindex.js
More file actions
Latest commit
41 lines (32 loc) · 947 Bytes
/
Copy pathindex.js
File metadata and controls
41 lines (32 loc) · 947 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
29
30
31
32
33
34
35
36
37
38
39
40
41
'use strict';
constexpress=require('express');
constbodyParser=require('body-parser');
constapp=express().use(bodyParser.json());// creates http server
consttoken='test';// type here your verification token
app.get('/',(req,res)=>{
// check if verification token is correct
if(req.query.token!==token){
returnres.sendStatus(401);
}
// return challenge
returnres.end(req.query.challenge);
});
app.post('/',(req,res)=>{
// check if verification token is correct
if(req.query.token!==token){
returnres.sendStatus(401);
}
// print request body
console.log(req.body);
// return a text response
constdata={
responses: [
{
type: 'text',
elements: ['Hi','Hello']
}
]
};
res.json(data);
});
app.listen(3000,()=>console.log('[BotEngine] Webhook is listening'));