1 | module.exports = {
|
2 | integrations: {
|
3 | /* Uncomment this to enable NLP with Dialogflow
|
4 | dialogflow: {
|
5 | token: "YOUR_DIALOGFLOW_API_TOKEN"
|
6 | }*/
|
7 | },
|
8 | routes: [
|
9 | /* Routes map user inputs to actions (React Components)
|
10 | A user input is an object like this:
|
11 | {
|
12 | type: "text", // Input type, it can be one of text, postback, image, video, audio, document, location
|
13 | data: "Hello!" // Raw text (or attachment URL if it's a media type)
|
14 | payload: "", // This is used when the user has clicked on a button or quick reply
|
15 | intent: "smalltalk.greeting" Intent ID according to the NLP backend
|
16 | }
|
17 |
|
18 | Every route (an entry in this array) is composed by a matching rule and an action.
|
19 | A matching rule looks like this: {attribute: test}, which basically means: "take that
|
20 | attribute from the user input and apply the test" if test passes, the action defined in
|
21 | that route will be triggered.
|
22 |
|
23 | There are 3 types of tests:
|
24 | - String --> Perfect match
|
25 | - Regexp --> Pass the regular expression
|
26 | - Function --> Passes if the funtion returns true
|
27 |
|
28 | The rules will be tested in order so if the 1st rule matches, Botonic won't test
|
29 | other routes and will execute the 1st action.
|
30 | If there are several matching rules in the same route, all of them have to pass
|
31 | to consider a match.
|
32 | */
|
33 |
|
34 | /* The first rule matches if and only if we get the text 'start' and will execute the
|
35 | React component defined in pages/actions/start.js */
|
36 | {text: "start", action: "start"},
|
37 |
|
38 | /* Another text rule (perfect match) to trigger the 'end' action */
|
39 | {text: "end", action: "end"},
|
40 |
|
41 | /* These rules use a case insensitive regexp to match text messages that contain
|
42 | a certain text, for example the 1st one will capture 'BUTTONS', 'Buttons', etc */
|
43 | {text: /^buttons$/i, action: "buttons"},
|
44 | {text: /^quickreply$/i, action: "quickreply"},
|
45 |
|
46 | /* These rules capture different payloads */
|
47 | {payload: "carrousel", action: "carrousel"},
|
48 | {payload: /^(yes|no)$/, action: "quickreply_response"},
|
49 |
|
50 | /* This rule uses a function test to capture any text that starts with 'bye' */
|
51 | {text: (t) => t.startsWith('bye'), action: "bye"},
|
52 |
|
53 | /* Captures any image */
|
54 | {type: "image", action: "media"},
|
55 |
|
56 | /* Captures different intents (enable the Dialogflow integration,
|
57 | see "integrations" section at the top of this file) */
|
58 | {intent: "smalltalk.agent.funny", action: "funny"},
|
59 | {intent: "smalltalk.agent.good", action: "funny"},
|
60 | {intent: "smalltalk.user.likes_agent", action: "funny"},
|
61 |
|
62 | /* There's an implicit rule that captures any other input and maps it to
|
63 | the 404 action, it would be equivalent to:
|
64 | {type: /^.*$/, action: "404"}
|
65 | */
|
66 | ]
|
67 | } |
\ | No newline at end of file |