-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
61 lines (59 loc) · 1.13 KB
/
index.js
File metadata and controls
61 lines (59 loc) · 1.13 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const axios = require('axios');
const { v4: uuidv4 } = require('uuid');
const flow = `
start:
if (!myvar) remember myvar = 0
say "Hello {{myvar}}"
remember myvar = myvar + 1
goto end
`
axios({
"method": "POST",
"url": "http://localhost:5000/run",
"headers": {
"Content-Type": "application/json"
},
"data": {
"bot": {
"default_flow": "Default",
"id": "mybot",
"flows": [
{
"id": "e0a13373-2037-4590-8018-ab14e74b27a1",
"content": flow,
"commands": [
"/default"
],
"name": "Default",
"description": "Default custom flow"
}
],
"updated_at": "2020-05-28T17:57:20.725Z",
"name": "MySuperBot"
},
"event": {
"metadata": {
"some": "info",
"about": "the current user"
},
"payload": {
"content": {
"text": "Hi there"
},
"content_type": "text"
},
"request_id": uuidv4(),
"client": {
"user_id": "myuser",
"channel_id": "mychan",
"bot_id": "mybot"
}
}
}
})
.then(res => {
console.log(JSON.stringify(res.data, null, 2));
})
.catch(err => {
console.error(new Error(`${err.response.status}: ${err.response.statusText}`));
});