-
Notifications
You must be signed in to change notification settings - Fork 32
/
conversation.js
94 lines (94 loc) · 2.62 KB
/
conversation.js
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/* The chat const defines the Peekobot conversation.
*
* It should be an object with numerical property names, and each property is an entry
* in the conversation.
*
* A conversation entry should have:
* - A "text" property that is what the chatbot says at this point in the conversation
* - Either:
* - A "next" property, which defines the next chat entry by stating a numerical key
* of the chat object and is used when the chatbot needs to say several things
* without input from the user
* OR
* - An "options" property that defines the choices a user can take this is an
* array of option objects
*
* An options object should have:
* - a "text" property that is the label for the user's choice
* AND EITHER
* - a "next" property that defines the next chat entry by stating a numerical key of
* the chat object and is used when the user selects this option
* OR
* - a "url" property that defines a link for the user to be taken to
*
* A simple example chat object is:
* const chat = {
* 1: {
* text: 'Good morning sir',
* next: 2
* },
* 2: {
* text: 'Would you like tea or coffee with your breakfast?',
* options: [
* {
* text: 'Tea',
* next: 3
* },
* {
* text: 'Coffee',
* next: 4
* }
* ]
* },
* 3: {
* text: 'Splendid - a fine drink if I do say so myself.'
* },
* 4: {
* text: 'As you wish, sir'
* }
* }
*/
const chat = {
1: {
text: 'Hi! Welcome to Peekobot.',
options: [
{
text: '👋',
next: 2
}
]
},
2: {
text: 'Peekobot is a <em>really simple</em>, choice-driven chatbot framework made in <del>less than</del> just over 100 lines of vanilla JavaScript',
next: 3
},
3: {
text: 'But you probably knew that anyway.',
options: [
{
text: "<strong>Yes</strong>, I did!",
next: 4
},
{
text: "<strong>Nope</strong>, this is news.",
next: 5
}
]
},
4: {
text: 'Awesome. This chat is still in development. Happy coding!',
},
5: {
text: 'Aah, you\'re missing out!',
next: 6
},
6: {
text: 'You should check it out on GitHub',
options: [
{
text: "Go to GitHub",
url: "https://github.com/peekobot/peekobot"
}
]
}
};