Resolving values
In an Asgard workflow, a setting's value can be resolved three ways: Literal, Expression and Template.
The three ways
Literal
Fixed content.
Example:
Welcome to our service!
Expression
A JavaScript expression, for computation and logic.
Examples:
// read a variable directly
prevMessage
// read with a boolean expression
userName || 'guest'
// call a built-in function and use its return value
history(0, -1)
// call a built-in function and use its return value
urlEncode(searchKeyword)
Template
Rendered with Handlebars syntax.
Example:
What is built in
Built-in variables
- Conversation:
prevMessage,prevBlobs,prevPayload,prevError - Channel:
customChannelId,customMessageId
See Expression variables for the details.
Built-in functions
Eight functions are provided:
- Conversation history:
history(),historySize() - Data handling:
urlEncode(),vecToStr(),xpathExtract() - Date and time:
isoNow(),isoToday()
See Expression built-in functions for the details.
Examples
Expression mode
// using a variable
prevMessage || 'no message'
// a conditional
prevError ? `Error: ${prevError}` : 'processed normally'
// calling a function
`Conversation length: ${historySize()} messages`