Conversation Class
The Conversation
class is located at app/conversation.rb
file.
Every message that arrives and every reply sent can be handled and accessed via callbacks defined here and all the Contexts should inherit this class.
For those who are familiar with Ruby on Rails, this class is the equivalent to ApplicationController
.
Callback | Description |
---|---|
before_blocks | This callback will be executed before the |
after_blocks | This callback will be executed after the |
before_exit | This callback will be executed before the conversation context is changed.
Specifically in the call of methods In this callback, the method |
Accessible Instances and methods
These instances and methods are accessible from the Conversation
class and also from any Context
class defined in a project.
@user
@user
It is an instance of the User
model (ActiveRecord::Base
) that corresponds to the user who sent the incoming message.
Usage
@message
@message
It is the instance of the user's incoming message.
Usage
To see the message content:
@message.text
Catch a button click event:
@message.postback_payload
and if includes parameters@message.postback_params
. Read more about postbacks.Check if the message is empty:
@message.empty?
See the full list of methods here.
@reply
@reply
It is an instance of the Kogno::Notification
class, which contains a wide variety of reply messages like text, button, url, carousel, etc. Full list here.
In Kogno, we try to unify almost all reply types for all supported platforms, so that a single code can be written for all of them.
Usage
For more information and examples, check the Replies section.
Methods
Also methods like change_to()
, delegate_to()
and halt()
.
Last updated