Flow Advanced: String templates
Within text replies, you can use params that are matched by the AI or collected using Triggers: Any Text.
If you have trained the AI to match entities, they can be used with a template syntax.
For example, if you trained the AI with an entity named "country", you will be able use it like so:
I am going to check the weather for {{country}}
This would result in a response like:
I am going to check the weather for France.
Param value
Entity search matches can be fuzzy. By default, string templates print the value of a matched parameter.
You can also access the match by using {{param.match}}
You can use string templates in several different replies:
- Text replies
- Titles and subtitles of a card
- Button labels
Param selection
Within string templates, Matched params with the same name are appended and multiple params render as a list.
You have the option to select the elements that will be rendered. For example, to access the last element of the list , use param.last.match:
The first element of the list can be accessed by param.first.match or param.0.match.
It also works with the following:
value: param.first.value, param.last.value, param.any_digit.value.
Filters
String templates also support advanced formatting filters. Supported filters include:
Category | Filter |
---|---|
Math | plus, minus, modulo, times, floor, ceil, round, divided_by, abs |
String | append, prepend, capitalize, upcase, downcase, strip,lstrip, rstrip, strip_newlines, split, replace, replace_first, remove, remove_first, truncate, truncatewords |
Date | format like strftime |
For example, you can render a date in different formats:
Updated about 1 year ago