Class: ChatbaseAPIClient
- Inherits:
-
Object
- Object
- ChatbaseAPIClient
- Includes:
- HTTParty
- Defined in:
- lib/chatbase_api_client.rb
Overview
Client used to send metrics to Chatbase, when ENV var present
Constant Summary collapse
- BASE_PATH =
'https://chatbase.com/api/facebook'
Instance Attribute Summary collapse
-
#intent ⇒ Object
Returns the value of attribute intent.
-
#not_handled ⇒ Object
Returns the value of attribute not_handled.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
- #initialize(params = {}) ⇒ ChatbaseAPIClient constructor
-
#send_bot_message(message, response)
Sends message sent by bot to Chatbase.
-
#send_user_message(message)
Sends message sent by user to Chatbase.
-
#set_chatbase_fields(intent, text, not_handled)
Method to set chatbase client fields.
Constructor Details
#initialize(params = {}) ⇒ ChatbaseAPIClient
11 12 13 14 15 |
# File 'lib/chatbase_api_client.rb', line 11 def initialize(params = {}) @intent = params.fetch(:intent, nil) @text = params.fetch(:text, nil) @not_handled = params.fetch(:not_handled, false) end |
Instance Attribute Details
#intent ⇒ Object
Returns the value of attribute intent.
8 9 10 |
# File 'lib/chatbase_api_client.rb', line 8 def intent @intent end |
#not_handled ⇒ Object
Returns the value of attribute not_handled.
8 9 10 |
# File 'lib/chatbase_api_client.rb', line 8 def not_handled @not_handled end |
#text ⇒ Object
Returns the value of attribute text.
8 9 10 |
# File 'lib/chatbase_api_client.rb', line 8 def text @text end |
Instance Method Details
#send_bot_message(message, response)
This method returns an undefined value.
Sends message sent by bot to Chatbase
40 41 42 43 44 45 46 47 |
# File 'lib/chatbase_api_client.rb', line 40 def (, response) # Format for Chatbase Facebook API = (, response) # Post to Chatbase catch_errors{ self.class.post("#{BASE_PATH}/send_message?api_key=#{ENV['CHATBASE_API_KEY']}", json_body()) } end |
#send_user_message(message)
This method returns an undefined value.
Sends message sent by user to Chatbase
23 24 25 26 27 28 29 30 |
# File 'lib/chatbase_api_client.rb', line 23 def () # Format for Chatbase Facebook API = () # Post to Chatbase catch_errors{ self.class.post("#{BASE_PATH}/message_received?api_key=#{ENV['CHATBASE_API_KEY']}", json_body()) } end |
#set_chatbase_fields(intent, text, not_handled)
This method returns an undefined value.
Method to set chatbase client fields
59 60 61 62 63 |
# File 'lib/chatbase_api_client.rb', line 59 def set_chatbase_fields(intent, text, not_handled) @intent = intent @text = text @not_handled = not_handled end |