@@ -84,61 +84,61 @@ Another possibility is to send and retrieve [custom entities](https://docs.api.a
84
84
85
85
You can do it along with ** query** request
86
86
``` ruby
87
- client.text_request ' call Mozart' , entities: [
88
- {
89
- name: ' contacts' ,
90
- entries: [
91
- ApiAiRuby ::Entry .new (' Mozart' , %w(Mozart Wolfgang) ),
92
- ApiAiRuby ::Entry .new (' Salieri' , %w(Salieri Antonio) )
93
- ]
94
- }
95
- ]
96
-
97
- # the same without ApiAiRuby::Entry wrapper
98
-
99
- client.text_request ' call Mozart' , entities: [
100
- {
101
- name: ' contacts' ,
102
- entries: [
103
- {value: ' Mozart' , synonyms: %w(Mozart Wolfgang) )},
104
- {value: ' Salieri' , synonyms: %w(Salieri Antonio) )},
105
- ]
106
- }
107
- ]
87
+ client.text_request ' call Mozart' , entities: [
88
+ {
89
+ name: ' contacts' ,
90
+ entries: [
91
+ ApiAiRuby ::Entry .new (' Mozart' , %w(Mozart Wolfgang) ),
92
+ ApiAiRuby ::Entry .new (' Salieri' , %w(Salieri Antonio) )
93
+ ]
94
+ }
95
+ ]
96
+
97
+ # the same without ApiAiRuby::Entry wrapper
98
+
99
+ client.text_request ' call Mozart' , entities: [
100
+ {
101
+ name: ' contacts' ,
102
+ entries: [
103
+ {value: ' Mozart' , synonyms: %w(Mozart Wolfgang) )},
104
+ {value: ' Salieri' , synonyms: %w(Salieri Antonio) )},
105
+ ]
106
+ }
107
+ ]
108
108
109
109
```
110
110
111
111
Or with separate ** user_entities_request** object with full CRUD support:
112
112
113
113
``` ruby
114
114
115
- # preparations
116
- entries_composers = [
117
- ApiAiRuby ::Entry .new (' Mozart' , %w(Mozart Wolfgang) ),
118
- ApiAiRuby ::Entry .new (' Salieri' , %w(Salieri Antonio) )
119
- ]
120
-
121
- entries_unknown = [
122
- ApiAiRuby ::Entry .new (' John Doe' , %w(John Unknown) ),
123
- ApiAiRuby ::Entry .new (' Jane Doe' , %w(Jane) )
124
- ]
125
-
126
- entity_contacts = ApiAiRuby ::Entity .new (' contacts' , [entries_composers])
127
-
128
- # let's go
129
- uer = client.user_entities_request
130
- uer.create(contacts) # or uer.create([entity1, entity2...])
131
-
132
- client.text_request ' call Mozart' # will work
133
-
134
- uer.update(' contacts' , entries_unknown)
135
-
136
- client.text_request ' call Mozart' # will NOT work
137
- client.text_request ' call John' # will work
138
-
139
- uer.retrieve(' contacts' ) # will return current state of user entity
140
- uer.delete(' contacts' ) # will remove user entities for given session
141
-
115
+ # preparations
116
+ entries_composers = [
117
+ ApiAiRuby ::Entry .new (' Mozart' , %w(Mozart Wolfgang) ),
118
+ ApiAiRuby ::Entry .new (' Salieri' , %w(Salieri Antonio) )
119
+ ]
120
+
121
+ entries_unknown = [
122
+ ApiAiRuby ::Entry .new (' John Doe' , %w(John Unknown) ),
123
+ ApiAiRuby ::Entry .new (' Jane Doe' , %w(Jane) )
124
+ ]
125
+
126
+ entity_contacts = ApiAiRuby ::Entity .new (' contacts' , [entries_composers])
127
+
128
+ # let's go
129
+ uer = client.user_entities_request
130
+ uer.create(contacts) # or uer.create([entity1, entity2...])
131
+
132
+ client.text_request ' call Mozart' # will work
133
+
134
+ uer.update(' contacts' , entries_unknown)
135
+
136
+ client.text_request ' call Mozart' # will NOT work
137
+ client.text_request ' call John' # will work
138
+
139
+ uer.retrieve(' contacts' ) # will return current state of user entity
140
+ uer.delete(' contacts' ) # will remove user entities for given session
141
+
142
142
```
143
143
144
144
0 commit comments