Overview
Andi engagements are the output of Andi skills. Engagements communicate desired information to users using field tags, summary tags and chat dialogues. This article will cover how to set up and return these tags.
In this Article
Setting up Field Tags
To return a field tag to the user, we first need to set up a field tag object:
const fieldTag: FieldTag = {
fields: ["fieldName"],
text: "Some message.",
tagType: FieldTagTypes.Info,
key: "uniqueTemplateKey",
loadWhen: [{
query: { name: "getRawAmount", args: [] },
comparator: "==",
value: loanAmount,
type: "number"
}]
};
Properties
-
fields - an array of names that correspond to fields in the application.
-
text - a message to the user.
-
tagType - the category a tag falls under, based on the content of the message. Represented by a specific color. The following are tagType options:
-
Info (Blue)
-
Warning (Orange)
-
ValueToTarget (Green)
-
-
key - a unique string specific to this tag. If a skill returns multiple tags, each key must be unique. If a skill can return different tags based on the outcome of the skill, those tags should be unique as well.
-
loadWhen - a collection of Condition objects that determine if a tag is shown to the user or not.
-
Condition Type
-
query - ContextQuery object that retrieves a value from the application after the tag arrives.
-
comparator - an operation to apply. The following are comparator options:
-
==
-
>=
-
<=
-
>
-
<
-
isDivisibleBy
-
-
value - a static value to compare with the value retrieved from the query
-
type - the type of value. The following are type options:
-
string
-
number
-
boolean
-
-
-
-
onClick - an array of ContextCommand objects that get executed when the tag is clicked by the user.
-
onLoad - an array of ContextCommand objects that get executed when the tag loads (when the loadWhen property evaluates to true).
-
onUnload - an array of ContextCommand objects that get executed when the tag unloads (when the loadWhen property evaluates to false, AFTER it was previously evaluated to true)
-
displayOrder
-
section
Setting up Summary Tags
Summary tags have a similar structure to field tags, except there is no fields property.
const summaryTag: SummaryTag = {
text: "Some message.",
tagType: FieldTagTypes.Info,
key: "uniqueTemplateKey",
loadWhen: [{
query: { name: "getRawAmount", args: [] },
comparator: "==",
value: loanAmount,
type: "number"
}]
};
How to Return Tags
To deliver tags to the user, use the TagPowers.sendTags power. Note: Multiple tags can be returned at once.
return TagPowers.sendTags([fieldTag, summaryTag]);