Skip to content

Commit 4bbdaa1

Browse files
committed
[+] Readme update
1 parent 4b71655 commit 4bbdaa1

File tree

1 file changed

+48
-48
lines changed

1 file changed

+48
-48
lines changed

README.md

+48-48
Original file line numberDiff line numberDiff line change
@@ -84,61 +84,61 @@ Another possibility is to send and retrieve [custom entities](https://docs.api.a
8484

8585
You can do it along with **query** request
8686
```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+
]
108108

109109
```
110110

111111
Or with separate **user_entities_request** object with full CRUD support:
112112

113113
```ruby
114114

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+
142142
```
143143

144144

0 commit comments

Comments
 (0)