Skip to content

Commit ec30b09

Browse files
albertpaulpalfredfrancis
authored andcommitted
Add ruby support in examples/ruby (alfredfrancis#46)
1 parent 0b55e07 commit ec30b09

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

examples/ruby/request.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
require 'net/http'
2+
require 'json'
3+
4+
uri = URI('http://localhost:8001/api/v1')
5+
http = Net::HTTP.new(uri.host, uri.port)
6+
request = Net::HTTP::Post.new(uri.path, 'Content-Type' => 'application/json')
7+
8+
request.body = {
9+
'currentNode': '',
10+
'complete': nil,
11+
'context': {},
12+
'parameters': [],
13+
'extractedParameters': {},
14+
'speechResponse': '',
15+
'intent': {},
16+
'input': 'init_conversation',
17+
'missingParameters': []
18+
}.to_json
19+
20+
while true
21+
response = http.request(request).body
22+
json_response = JSON.load(response)
23+
24+
puts "Iky #{json_response['speechResponse']}"
25+
26+
original_request_body = JSON.load(request.body)
27+
original_request_body['input'] = gets.chomp
28+
request.body = original_request_body.to_json
29+
end

0 commit comments

Comments
 (0)