Routing
Route an incoming message or event to a specific context of the conversation.
It's a very useful feature when it comes to decentralizing the handling of incoming messages or events and thus to achieving a more distributed code.
Postback
A postback payload can contain a path to a context, in addition to the information that the payload normally carries.
Examples
Route only
With params
Usage
The click event on "Create an Account" button will be handled by the ProfileContext
which will receive the payload without the context path information.
Intent
In order to implement this type of routing. In the NLP engine, just create an intent whose name starts with the name of an existing context in the project, followed by an underscore and the intent's own information. For instance: profile_sign_up
, where profile
is the context and sign_up
is the intent.
Intent creation example in Wit.ai
Usage
The profile_sign_up
intent will be handled by the ProfileContext and this will be able to capture the "sign_up"
intent, without path information.
Commands (Telegram)
In order to routing Telegram commands, just edit the config.routes.commands
field in config/platforms/telegram.rb
, adding a line with the format :command => :context_name
for each command that we want to route.
Usage
Commands that have not been configured will be handled by the default context.
Deep Links
A click event on a deep link can contain a path to a context, if the value of the params: ref
(Messenger) or start
(Telegram), starts with the name of an existing context in a given project.
Messenger Example
https://m.me/kogno.io/ref=profile_sign_up
Telegram Example
https://t.me/KognoBot?start=profile_sign_up
In both examples, the click events will be be handled by ProfileContext
and param value will be "sign_up"
, without path information
Last updated