-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdialogflow.js
64 lines (61 loc) · 1.4 KB
/
dialogflow.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
import Dialogflow from "react-native-dialogflow"
constructor(props)
{
super(props);
Dialogflow.setConfiguration(
"4xxxxxxxe90xxxxxxxxc372", Dialogflow.LANG_ENGLISH
);
}
<Button onPress={() => {
Dialogflow.startListening(result=>{
console.log(result);
}, error=>{
console.log(error);
});
}}
/>
// only for iOS
Dialogflow.finishListening();
// after this call your callbacks from the startListening will be executed.
<Button onPress={() => {
Dialogflow.requestQuery("Some text for your Dialogflow agent", result=>console.log(result), error=>console.log(error));
}}
/>
Dialogflow.requestEvent(
"WELCOME",
{param1: "yo mr. white!"},
result=>{console.log(result);},
error=>{console.log(error);}
);
const contexts = [{
name: "deals",
lifespan: 1,
parameters: {
Shop: "Rewe"
}
}];
Dialogflow.setContexts(contexts);
Dialogflow.resetContexts(result=>{
console.log(result);
}, error=>{
console.log(error);
});
const permanentContexts = [{
name: "Auth",
// lifespan 1 is set automatically, but it's overrideable
parameters: {
AccessToken: "1234yo1234"
}
}];
Dialogflow.setPermanentContexts(permanentContexts);
const entities = [{
"name":"shop",
"extend":true,
"entries":[
{
"value":"Media Markt",
"synonyms":["Media Markt"]
}
]
}];
Dialogflow.setEntities(entities);