Bixby Developer Center

References

type

optionalvalue optional

Specifies the action type. When choosing an action type, select the narrowest possible value. Certain types are for specific features, so choose the type that best fits your action's purpose. The available types and examples of each are listed below.

Examples

You can specify the following types. Examples are linked in the subsections.

Calculation

Use this type when you want to perform an isolated computation on the inputs that is guaranteed always to return a result. An example of this would be any basic, algorithmic operation, such as a simple sum or calculating the distance between points. No progress dialog is shown for this action.

action (RollDice) {
collect{
input (numDice) {
type (NumDiceConcept)
min (Required)
max (One)
}

input (numSides) {
type (NumSidesConcept)
min (Required)
max (One)
}
}
output (RollResultConcept)
type (Calculation)
}

View master on GitHub

Constructor

Use this type when you want to construct a concept using only the provided inputs. An example of this might be constructing a StreetAddress from a StreetNumber and a StreetName. These action types are often used with evaluate. No progress dialog is shown for this action.

Note

Any concept output by a Constructor action will be prevented from having properties projected off of them through the planning process.

action (GetQuantity) {
type (Constructor)
collect {
input (quantity) {
type(Quantity)
min(Required)
max(One)
plan-behavior (Never)
prompt-behavior (AlwaysElicitation)
}
}
output (PromptedQuantity) {
evaluate { $expr(quantity) }
}
}

View master on GitHub

Fetch

Use this type to retrieve additional data directly related to an input. This action type is limited to lazy-property evaluations. In that context, the action can only take one input, and it must be the same type as the enclosing structure.

action (FetchMovieCredits) {
description ("Fetch movie credits lazily from a secondary endpoint")
type (Fetch)
collect {
input (movie) {
type (Movie)
min (Required)
max (One)
}
}
output (core.Text)
}

View master on GitHub

Search

Use this type to take inputs and return one or more results. There are no general limitations to where it can be used. It should have no side-effects on external systems. This is the default action type if you do not specify one and the most commonly used action type.

action (FindShoe) {
type (Search)
collect {
input (name) {
type (Name)
min (Optional)
}
input (type) {
type (Type)
min (Optional)
}
input (minPrice) {
type (money.MinPrice)
min (Optional)
max (One)
}
input (maxPrice) {
type (money.MaxPrice)
min (Optional)
max (One)
}
}
output (Shoe)
}

View master on GitHub

BeginTransaction

Use this type when you need to start a transactional flow. A common example of this is when creating an order. The output of the action is part of the transaction, so the model that is outputted must have the transaction feature, and must be the input to subsequent transactional action types.

action (CreateOrder) {
type (BeginTransaction)
collect {
input (initialItems) {
type (InitialItems)
min (Required)
max (One)
default-init {
intent: goal: CreateItems
}
}
}
output (Order)
}

View master on GitHub

UpdateTransaction

Use this type when you need to update an existing concept in a transaction. A common example of this is when updating an order. Both the input and output concepts must have the transaction feature.

action (UpdateOrder) {
type (UpdateTransaction)
collect {
//the order that is updated
input (order) {
type (Order)
min (Required)
}
input-group (updates){
requires (OneOrMoreOf)
collect {
input (addedItems) {
type (AddedItems)
min (Optional)
max (One)
}
input (changedItems) {
type (ChangedItems)
min (Optional)
max (One)
}
input (removedItems) {
type (RemovedItems)
min (Optional)
max (One)
}
}
}
}
//returns the updated order
output (Order) {
throws {

error(NoItems) {
on-catch {
halt {
dialog {
macro (NoItemsInCart)
}
}
}
}
}
}
}

View master on GitHub

CancelTransaction

Use this type when you need to abort an existing concept in a transaction. A common example of this is when canceling an order. One of the inputs must be a concept with the transaction feature. There can be only one, unique CancelTransaction action per transaction.

action (CancelOrder) {
type (CancelTransaction)
collect {
input (order) {
type (Order)
min (Optional)
validate {
if (!exists(order)) {
halt {
dialog {
template ("Okay.")
}
}
}
}
}
}
output (Receipt)
}

View master on GitHub

Commit

Use this type when you need to finalize a concept in an existing transactional flow. A common example of this is when completing an order. One of the inputs must be a concept with the transaction feature.

Note

After a Commit action type has completed, all capsule pages leading up to the Commit (and potentially containing stale data) are deleted from the client.

If you need to track the status of your concept after it has been committed, the output of your Commit action should be a concept with the activity feature.

action (CommitOrder) {
type (Commit)
collect {
input (order) {
type (Order)
min (Required)
}
}

confirm {
by (core.Confirmation)
}

output (Receipt)
}

View master on GitHub

RefreshActivity

Use this type when you need to refresh an Activity. A common example of this is when checking the state of an order. One of the inputs must be a concept with the activity feature, which is the output of a Commit action. There can be only one, unique RefreshActivity action per transactional concept type.

action (CheckStatus) {
type (RefreshActivity)
collect {
input (receipt) {
type (Receipt)
min (Required)
default-init {
intent {
goal: FindLastReceipt
}
}
}
}
output (Receipt)
}

View master on GitHub

UpdateActivity

Use this type when you need to update a concept in an activity. A common example of this is when making changes to a committed order. One of the inputs must be a concept with the activity feature, which is the output of a Commit action.

CancelActivity

Use this type when you need to cancel an activity. A common example of this is when canceling a committed order. One of the inputs must be a concept with the activity feature, which is the output of a Commit action.

action (CancelCommittedOrder) {

type (CancelActivity)

confirm {
by (core.Confirmation)
}

collect {
input(receipt){
type(Receipt)
min (Optional)

default-init {
intent {
goal: FindLastReceipt
}
}

validate {
if (!exists(receipt)) {
halt {
dialog {
template("Not sure what to cancel. I didn't find any recent shirt orders.")
}
}
}
if (exists(receipt) && receipt.orderState != 'Ordered') {
halt {
dialog{
template("This order is already #{value (receipt.orderState)}!")
}
}
}
}
}
}

output(Receipt)
}

View master on GitHub

ArchiveLookup

Use this type when you need to look-up an Activity. You use this action type with the Transactions API. A common example of this is when a user wishes to review a past order. It should return a concept with the activity feature.

action (FindLastReceipt) {
output (Receipt)
type (ArchiveLookup)
}

View master on GitHub

Here is the corresponding JavaScript file that uses the transaction API:

import transaction from 'transaction';
// FindLastReceipt
export default function () {
//look up last receipt from viv cloud
return transaction.retrieve('example.shirt.Receipt', 'ALL', 1);
}

View master on GitHub