You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+27-7Lines changed: 27 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,6 +42,7 @@ Import ApiAi:
42
42
importApiAifrom"react-native-api-ai";
43
43
```
44
44
45
+
### Configuration
45
46
Set the `clientAccessToken` and the language in your constructor:
46
47
```javascript
47
48
constructor(props) {
@@ -54,6 +55,7 @@ Set the `clientAccessToken` and the language in your constructor:
54
55
55
56
```
56
57
58
+
### Listening
57
59
Start listening with integrated speech recognition:
58
60
```javascript
59
61
<Button onPress={() => {
@@ -72,6 +74,31 @@ ApiAi.finishListening();
72
74
// after this call your callbacks from the startListening will be executed.
73
75
```
74
76
77
+
### Text Request
78
+
For using your own speech recognition:
79
+
```javascript
80
+
<Button onPress={() => {
81
+
ApiAi.requestQuery("Some text for your api-ai agent", result=>console.log(result), error=>console.log(error));
82
+
}}
83
+
/>
84
+
```
85
+
86
+
87
+
### Contexts
88
+
Set contexts (will take affect on next startListening or queryRequest):
89
+
```javascript
90
+
constcontexts= [{
91
+
name:"deals",
92
+
lifespan:1,
93
+
parameters: {
94
+
Shop:"Rewe"
95
+
}
96
+
}];
97
+
98
+
ApiAi.setContexts(contexts);
99
+
```
100
+
101
+
### Events on Android
75
102
Only in Android we have four additional methods: `onListeningStarted`, `onListeningCanceled`, `onListeningFinished` and `onAudioLevel`. In iOS they will be never called:
76
103
```javascript
77
104
<Button onPress={() => {
@@ -103,13 +130,6 @@ Only in Android we have four additional methods: `onListeningStarted`, `onListen
103
130
```
104
131
Note: Make sure you are setting the callbacks before startListening every single time again. Don't set the callbacks in e.g. constructor or componentsDidMount if you are executing startListening more than one times.
105
132
106
-
Using your own speech recognition:
107
-
```javascript
108
-
<Button onPress={() => {
109
-
ApiAi.requestQuery("Some text for your api-ai agent", result=>console.log(result), error=>console.log(error));
0 commit comments