Uh oh! We couldn’t find any match.

Please try other search keywords.

Bixby Developer Center

Guides

Profile (viv.self)

The viv.self capsule provides access to information in the user's profile, such as given names, phone numbers, and addresses. In certain respects, it functions as a special case of viv.contact.

Models

Types are always in the viv.\* namespace, and in the viv.self.\* namespace unless another namespace is specified (e.g., viv.geo.\*). All properties have a cardinality of min (Optional), max (One) unless otherwise specified.

Self

The Self structure concept simply extends viv.contact.ContactInfo. You can use Self any place ContactInfo is required.

The following types all exist in the viv.contact.\* namespace, not \viv.self.\*. (Note that viv.self imports viv.contact as contact, so your capsule does not need to import viv.contact.)

PropertyTypeKindNotes
contactIdcontact.ContactIdintegerIdentifier from device
nameInfocontact.NameInfostructure
addressInfoscontact.AddressInfostructuremax (Many)
phoneInfoscontact.PhoneInfostructuremax (Many)
emailInfoscontact.EmailInfostructuremax (Many)
relationshipInfoscontact.RelationshipInfostructuremax (Many)
photoInfocontact.PhotoInfostructure
isFavoritecontact.IsFavoriteboolean
workInfocontact.WorkInfostructure
birthdayInfocontact.BirthdayInfostructure 

AddressType

This is a primitive that extends contact.AddressType, primarily intended for training use.

The possible symbols for AddressType are Home, Work, and Other.

EmailType

This is a primitive that extends contact.EmailType, primarily intended for training use.

The possible symbols for EmailType are Home, Work, Other, and Custom.

PhoneType

This is a primitive that extends contact.PhoneType, primarily intended for training use.

The possible symbols for PhoneType are Mobile, Home, Work, WorkFax, HomeFax, Pager, Callback, CustomType, and Other.

Actions

As with other library capsules, most actions are selected by Bixby when it builds the execution graph, rather than needing to be chosen explicitly.

Passing Self to Your Action

To use Self as an input to one of your capsule's actions, define a constructor action that returns a capsule-specific concept that includes the fields you need. For a simple example, consider simply returning the user's name. Define a Name concept in your capsule:

text (Name) {
extends (contact.StructuredName)
}

Then, create an action that constructs Name from Self:

action (ShowMyName) {
type (Constructor)
collect {
input (self) {
min (Required)
type (self.Self)
}
}
output (Name) {
evaluate {
$expr(self.nameInfo.structuredName)
}
}
}

Now, ShowMyName could be used as a goal in training:

[g:ShowMyName] What is my name?

Now a more complex example. A shopping capsule might have a Buyer structure concept:

structure (Buyer) {
property (firstName) {
type (contact.FirstName)
min (Required) max (One)
}

property (lastName) {
type (contact.LastName)
min (Required) max (One)
}

property (phoneNumber) {
type (contact.PhoneNumber)
min (Required) max (One)
}

property (emailAddress) {
type (contact.EmailAddress)
min (Required) max (One)
}
}

Your capsule can then construct Buyer from Self:

action (ConstructBuyerFromSelf) {
type (Constructor)
collect {
input (self) {
type (self.Self)
min (Required)
max (One)
}

computed-input (buyer) {
type (Buyer)
min (Required)
max (One)
// check if all required fields are present
compute {
if (exists(self.nameInfo) && exists(self.nameInfo.firstName) &&
exists(self.nameInfo.lastName) && size(self.emailInfos) > 0 &&
exists(self.emailInfos[0].address) && size(self.phoneInfos) > 0 &&
exists(self.phoneInfos[0].number)) {
intent {
goal: ExtractBuyerFromSelf
value: $expr(self)
}
} else {
// If any of the fields we need in this capsule are missing from
// self, prompt with a single input-view form for Self
// (pre-populated with the fields that do already exist) so that
// users can edit everything at once
intent {
goal { @prompt-behavior(AlwaysElicitation) Buyer}
}
}
}
}

}

output (Buyer) {
evaluate {
$expr(buyer)
}
}
}

This action uses a separate action to extract Buyer from Self:

action (ExtractBuyerFromSelf) {
description (Extract a Buyer from a self that has all the required fields)
type (Constructor)
collect {
input (self) {
type (self.Self)
min (Required) max (One)
}
}
// You can improve this by implementing a JavaScript function which
// extracts the primary number and primary email, rather than picking the
// first item in the list.
output (Buyer) {
evaluate {
Buyer {
firstName: $expr(self.nameInfo.firstName)
lastName: $expr(self.nameInfo.lastName)
phoneNumber: $expr(self.phoneInfos[0].number)
emailAddress: $expr(self.emailInfos[0].address)
}
}
}
}

Now, you can use Buyer as an input to your capsule's actions.

action (BuyProduct) {
type (Commit)

collect {
input (buyer) {
type (Buyer) // buyer is self
min (Required)
default-init {
intent {
goal: ConstructBuyerFromSelf
}
}
}
input (product) {
type (Product)
min (Required)
}
}
output (Receipt)
}

Constructing a NamedPoint

A useful provided action is ConstructNamedPointFromSelf, which converts a physical address in the user's profile to a Named Point. This action might be used, for example, by a ride sharing app to find a destination in the user's profile.

action (FindProfileDestination) {
type (Search)
collect {
// addressType is passed in from training
input (addressType) {
type (self.AddressType)
min (Required) max (One)
}
// self can be computed rather than explicitly passed
computed-input (self) {
type (self.Self)
min (Optional) max (One)
compute {
intent {
goal: self.Self
route: self.GetSelf
}
}
}
// DestinationPoint is a capsule-specific extension of geo.NamedPoint.
// We compute it wiht a subplan that uses ConstructNamedPointFromSelf
computed-input (namedPoint) {
type (DestionationPoint)
min (Optional) max (One)
compute {
intent {
goal: DestinationPoint
subplan {
goal: self.ConstructNamedPointFromSelf
subplan {
goal: self.FindAddress
value: $expr(addressType)
value: $expr($self)
}
}
}
}
}
}

output (DestinationPoint) {
...
}
}

This uses several actions within viv.Self. Both ConstructNamedPointFromSelf and FindAddress have the same inputs:

InputTypeNotes
addressTypeAddressType
selfSelf 

The GetSelf action has no inputs, and simply returns the Self concept.

Training

Most commonly, your capsules will need to be trained on the AddressType, EmailType, and PhoneType enums, to handle utterances such as "call my office" or "book me a car to go home". A ride sharing capsule might have training such as:

[g:viv.rideshare.RideShare#book] I want a car to go (home)[v:viv.self.AddressType:home]

[g:viv.rideshare.RideShare#book] Book a ride to the (office)[v:viv.self.AddressType:work]