Class: ApiAiWrapper::MeaningExtractor

Inherits:
Components::ExtractorComponent show all
Defined in:
lib/api_ai_wrapper/meaning_extractor.rb

Overview

Instance Attribute Summary

Attributes inherited from Components::Component

#engine

Instance Method Summary collapse

Methods inherited from Components::ExtractorComponent

#raise_if_unauthorized, #set_headers

Instance Method Details

#post_query(query, options = {}) ⇒ Object

api.ai/docs/reference/agent/query#post_query Retrieves the meaning of a utterance options can contain (in accordance with API reference) :

  • contexts

  • location

  • timezone

  • lang

  • sessionId



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/api_ai_wrapper/meaning_extractor.rb', line 14

def post_query(query, options = {})
  set_headers
  body = {
    query: query,
    lang: self.engine.locale,
    sessionId: SecureRandom.hex
  }.merge(options)
  endpoint_url = URI.join(self.engine.base_url, "query?v=#{self.engine.version}")

  res = self.post(endpoint_url, body.to_json)
end