@@ -22,35 +22,14 @@ After that you can send text requests to the https://api.ai with command
22
22
response = client.text_request ' hello!'
23
23
```
24
24
25
- And voice requests with file stream
25
+ Or try to invocate intent via defined ' [ event ] ( https://docs.api.ai/docs/concept-events ) ':
26
26
27
27
``` ruby
28
- file = File .new ' hello.wav'
29
- response = client.voice_request(file)
30
- ```
31
28
32
- Example answer:
33
- ```
34
- {
35
- :id => "6daf5ab7-276c-43ad-a32d-bf6831918492",
36
- :timestamp => "2015-12-22T08:42:15.785Z",
37
- :result => {
38
- :source => "agent",
39
- :resolvedQuery => "Hello",
40
- :speech => "Hi! How are you?",
41
- :action => "greeting",
42
- :parameters => {},
43
- :contexts => [],
44
- :metadata => {
45
- :intentId => "a5d685ab-1f19-46b0-9478-69f794553668",
46
- :intentName => "hello"
47
- }
48
- },
49
- :status => {
50
- :code => 200,
51
- :errorType => "success"
52
- }
53
- }
29
+ response_zero = client.event_request ' MY_CUSTOM_EVENT_NAME' ;
30
+ response_one = client.event_request ' MY_EVENT_WITH_DATA_TO_STORE' , {:param1 => ' value' }
31
+ response_two = client.event_request ' MY_EVENT_WITH_DATA_TO_STORE' , {:some_param => ' some_value' }, :resetContexts => true
32
+
54
33
```
55
34
56
35
** voice_request** and ** text_request** methods returns symbolized https://api.ai response. Structure of response can be found at https://docs.api.ai/docs/query#response .
@@ -73,7 +52,7 @@ And you also can send additional data to server during request, use second param
73
52
74
53
``` ruby
75
54
response = client.text_request ' Hello' , :contexts => [' firstContext' ], :resetContexts => true
76
- response = client.voice_request file, :timezone => " America/New_York"
55
+ response = client.voice_request file, :timezone => ' America/New_York'
77
56
```
78
57
79
58
More information about possible parameters can be found at https://docs.api.ai/docs/query page
@@ -162,6 +141,7 @@ Please see the [httprb wiki on timeouts](https://github.com/httprb/http/wiki/Tim
162
141
163
142
#Changelog
164
143
144
+ * 1.2.3 - events support
165
145
* 1.2.2 - added configurable timeouts for requests (thanks [ bramski] ( https://github.com/bramski ) )
166
146
* 1.2.1 - fixed UTF-8 in text-requests
167
147
* 1.2.0 - added configurable session_id and full userEntities support
0 commit comments