classMainContext<Conversationdefblocks intent "greeting"do@rsp.quick_reply("Would you like to sign up?",[{title:"Create an Account",payload:"profile/sign_up"}])endendend
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
profile_sign_up intent creation in Wit.ai
profile_sign_up intent training.
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.
class ProfileContext < Conversation
def blocks
postback "sign_up" do
@reply.text "To create a new account please click in the button bellow."
@reply.url(
{
title: "Create a new User",
url: "https://kogno.io/sign_up"
}
)
end
end
end
class ProfileContext < Conversation
def blocks
intent "sign_up" do
@reply.text "To create a new account please click in the button bellow."
@reply.url(
{
title: "Create a new User",
url: "https://kogno.io/sign_up"
}
)
end
end
end
class ProfileContext < Conversation
def blocks
command "sign_up" do
@reply.text "To create a new account please click in the button bellow."
@reply.url(
{
title: "Create a new User",
url: "https://kogno.io/sign_up"
}
)
end
end
end
class ProfileContext < Conversation
def blocks
deep_link do |value|
if value == "sign_up"
@reply.text "To create a new account please click in the button bellow."
@reply.url(
{
title: "Create a new User",
url: "https://kogno.io/sign_up"
}
)
end
end
end
end