The Bixby viv.money
library capsule provides a set of concepts and actions that allow your capsule to handle currency and prices.
This reference lists out several of the models available in this library capsule. Some sections contain tables listing information about those concepts or actions.
The primary models are viv.money.Currency
and viv.money.Price
, which extends Currency
. They are nearly identical structure concepts with two properties:
currencyType
: a structure enum concept, CurrencyType
with a two-property set of enumerated constants:prefixSymbol
: the symbol used for the currency, such as "$" or "€"currencyCode
: the code used for the currency, such as "USD" or "EUR"value
: a decimal primitive, CurrencyValue
The currency value $5
would be represented as a Price
model with the following values:
viv.money.Currency {
value: viv.money.CurrencyValue (5.0)
currencyType: viv.money.CurrencyType {
prefixSymbol: viv.money.PrefixSymbol ($)
currencyCode: viv.money.CurrencyCode (USD)
}
}
The difference between Currency
and Price
is that Price
adds a natural-order
key, which causes Price
instances to be sorted by their value
. If your capsule involves products, services, or other models with pricing, use Price
rather than Currency
.
Products with ranges of prices can take advantage of the PriceRange
model, whose two properties are min
(a MinPrice
concept) and max
(MaxPrice
). MinPrice
and MaxPrice
both extend and have the role-of
the Price
concept.
As with many Bixby library capsules, viv.money
can infer information based on context. For instance, currencyType
will default to the currency of the user's locale.
To tag currency values in utterances, you will typically tag the CurrencyValue
and either the PrefixSymbol
or CurrencyCode
separately, then assign them a role of one of your capsule's models that extends either Currency
or Price
.
For instance, the viv.gratuity
capsule, which computes tips and splits bills, might be trained on the utterance "what is an 18% tip on a $55 tab?" You would tag $
as viv.money.PrefixSymbol:$
and 55
as viv.money.CurrencyValue
, then tag $55
with the role viv.gratuity.ServiceBillTotal
.
The Aligned NL for this query would be:
[g:viv.gratuity.CalculateTip] What is an (18)[v:viv.gratuity.TipPercent:18]%
tip on a {[g:viv.gratuity.ServiceBillTotal]
($)[v:viv.money.PrefixSymbol:$](55)[v:viv.money.CurrencyValue]} tab?
For price ranges, train on MaxPrice
or MinPrice
. For instance, a flower shop capsule might be trained with the utterance "find me roses under $70". In that case, you would tag $
as viv.money.PrefixSymbol:$
and 70
as viv.money.CurrencyValue
, then tag $70
with the role viv.money.MinPrice
.