Skip to content

Commit

Permalink
Add ruby support in examples/ruby (alfredfrancis#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
albertpaulp authored and alfredfrancis committed Nov 25, 2017
1 parent 0b55e07 commit ec30b09
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions examples/ruby/request.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require 'net/http'
require 'json'

uri = URI('http://localhost:8001/api/v1')
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Post.new(uri.path, 'Content-Type' => 'application/json')

request.body = {
'currentNode': '',
'complete': nil,
'context': {},
'parameters': [],
'extractedParameters': {},
'speechResponse': '',
'intent': {},
'input': 'init_conversation',
'missingParameters': []
}.to_json

while true
response = http.request(request).body
json_response = JSON.load(response)

puts "Iky #{json_response['speechResponse']}"

original_request_body = JSON.load(request.body)
original_request_body['input'] = gets.chomp
request.body = original_request_body.to_json
end

0 comments on commit ec30b09

Please sign in to comment.