Templates
It calls a template with extension ".erb" and executes it. There may be just one or a serie of replies.
template(route=String, params=Hash)
template(route=String, params=Hash)
Usage
File Location
Templates are found in sub-directories under bot/templates/
and each sub-directory within has the same name as an existing context in a given project.
For example: bot/templates/
context_name
/
template_name
.erb
.
File Content
The code in the template must be written between the chars <% %>
.
params
argument
params
argumentThe params argument can contain various elements which are accessed as a local variable within the template. In the example above: title
.
Arguments
route
String
Required.
The template route.
Formats:
"context_name/template_name"
"
template_name"
(If the template is in the same context from where this method was been called)
params
Hash
Optional. Parameters that are passed to the template as local variables.
Template reuse example
In the example below, the "main/menu" template will be called in 3 different situations in the conversation:
When the user sends a greeting..
When the user thanks..
When the app cannot understand what the user has said.
Last updated