how do I model a reminder of a future event? - bixby

I am creating a capsule that will remind me and people in my contacts to vote on Election Day 2020. I am working on the models. I believe I need to model the concepts "Reminders" and "WhenPollsAreOpen". I am stuck on Reminders.
It seems to me that I want to create something like .reminder library capsule to handle reminding in general and then a specific model of reminding people to vote in elections.
structure (reminderPreferences) {
description (preferences about a reminder)
property (name) {
type (Name)
min (Required)
}
property (description) {
type (Description)
min (Required)
}
property (isactive) {
type (boolean)
min (Required)
}
I want the model to compile cleanly, but I get multiple "can't find type for property" error messagesenter image description here

Related

Dynamic modeling with Alloy

I'm evaluating a co-worker's pitch using Alloy to model the problem and gain insight into additional questions/constraints that are required to meet the specification.
I believe that Alloy is the right tool for this scope. I also believe I need a dynamic model to illustrate the sequence of actions and identify cases where additional constraints are needed.
Problem: A Member can spend points to purchase Vouchers for an Offer, and redeem or return them. The member cannot net out more points than spent by returning. The member cannot receive more benefits than vouchers.
Model:
open util/ordering[Time]
sig Time {}
// A membership may have a point balance
sig Membership {
vouchers: Voucher
}
sig Voucher {
, voucher_for: one VoucheredOffer
, voucher_from: one PurchasableOffer
}
// Purchasable offers may have some point cost
sig PurchasableOffer {
, grants_for: one VoucheredOffer
}
sig VoucheredOffer {}
// Events
abstract sig Event {
, time: Time
, memberships: Membership
}
one sig init extends Event {} {
first = time
}
// PurchaseVoucher
// A membership receives a voucher
// Additionally, membership may spend points
sig purchaseVoucher extends Event {
, membership: Membership
, offer: PurchasableOffer
, voucher: Voucher
} {
voucher = voucher_from.offer
memberships.vouchers = time.prev.#memberships.vouchers + voucher
}
// ReturnVoucher
// A membership returns a voucher, and if points were spent, the points are returned
// ReserveVoucher
// A membership reserves a voucher
// RedeemVoucher
// Membership redeems a voucher, receiving a benefit.
// Assertions/Invariants/Checks
// A membership's points returned does not exceed points spent.
// A membership does not receive more benefits than total vouchers purchased minus vouchers returned.
I can't figure out how to model purchaseVoucher such that it adds a voucher to the membership's vouchers relation. Or I'm just doing it wrong. I am trying to use signatures to model the events because it presents a better visualization and simpler construction than using predicates. Further, if I am going to use predicates, I would just model this in TLA+.
My book gives examples of how to do this, but the general strategy with events is to make the state signatures time dependent. For example,
vouchers: Voucher
becomes
vouchers: Voucher -> Time
As Peter noted, you can also use Electrum which makes this easier by giving you a keyword for time-varying components.

How to make Bixby ask input without user

I want to make Bixby ask for input values when the user just states what he/she wants to do(without any valuable input given.)
For example,
user: I want to search something
Bixby: What do you want to search?
user: *possible-input-value*
Is this possible? If so, how can I implement this?
That's easy in Bixby. If you make an input to your action required...it will prompt the user for input. Let's say you have an action like this:
action (FindSomething) {
type(Search)
description (Search for something)
collect {
input (search) {
type (Search)
min (Required) max (One) // Force Bixby to prompt for an input.
}
}
output (viv.core.Text) // some result
}
And you have a search concept defined like this:
name (Search) {
description (Search term)
}
You can provide an input view for the user to enter the term (via screen).
input-view {
match: Search(search)
message {
template ("What do you want to search?")
}
render {
form {
elements {
text-input {
id (search)
label (Search Term)
type (Search)
max-length (50)
value ("#{raw(search)}")
}
}
on-submit {
goal: Search
value: viv.core.FormElement(search)
}
}
}
}
In addition to Pete's response, you need to enable this for voice input (UI only input will not pass capsule review for submission to the marketplace). To do so, you need to create natural language training for Search
Since you are asking for input at a prompt, you need to create a training that will be used when prompting for Search
Training source for this would look like:
[g:Search:prompt] (sample search text)[v:Search]
Or in the UI
Definitely check out the sample code at https://github.com/bixbydevelopers for more examples. A simple example of input would be in https://github.com/bixbydevelopers/capsule-sample-fact - note the training that uses tags
In addition to Pete's response, I would recommend taking a look the design principles for Bixby development. These principles will guide you in making a targeted capsule that solves the use case you would like to address.

How to avoid caching of input in JavaScript function in bixby

JavaScript function inputs seem to be caching the arguments if the value is being used earlier.
Example
Use cases
Find students in schools with a name or with their ages or both together.
utterance 1
find students in the school with the name George.
then in it will invoke the function with (name as George and age as null)
utterance 2
find students in the school with ages 10.
then in it will invoke the function with (name as George and age as 10)
How to avoid caching of the variable name as George in the second case?
Solved! issue by adding
features {
transient
}
example of text concept
text (name) {
description (name of the person)
features{
transient
}
}
For DateTimeExpression created CustomDateTimeExpression with role-of viv.time.DateTimeExpression and added transient to features works.
structure (CustomDateTimeExpression) {
role-of (viv.time.DateTimeExpression)
description (wrapper for DateTimeExpression)
features {
transient
}
}
links: https://bixbydevelopers.com/dev/docs/reference/type/text.features

Start playing the audio after selecting card in results view

I'm trying to take the data (concept) from a card a user selects from a results view containing multiple cards and instead of presenting the information from that card in a more detailed view i'm trying to use the properties of the Concept the card displays, ie: Song author, title ... and transform that into a audioPlayer.AudioInfo concept and start playing the audio.
I am familiar with how the audio demo capsule plays audio, where the audioPlayer.AudioInfo is first build, an then passed to the audio player in the same action: https://github.com/bixbydevelopers/capsule-samples-collection/tree/master/audio
action (PlaySessionOfDay) {
type (Search)
collect {
computed-input (sessionToPlay) {
description (Fetch the sessions to be played)
type (audioPlayer.AudioInfo)
min (Required) max (One)
compute {
intent {
goal: BuildSessionOfDayAudioInfo
}
}
hidden
}
computed-input (session) {
description (By passing in the AudioInfo object to the PlayAudio action, we ask the client to play our sound.)
type (audioPlayer.Result)
compute {
intent {
goal: audioPlayer.PlayAudio
value: $expr(sessionToPlay)
}
}
hidden
}
}
output (Result)
}
How an can you use the selected Song card from the list of cards as the input into the PlaySessionOfDay action and then pass it to an action like BuildSessionOfDayAudioInfo, to create an audioPlayer.AudioInfo.
It looks like you can't have compute block
compute {
intent {
goal: BuildSessionOfDayAudioInfo
}
}
unless you are using computed-input (sessionToPlay).
Edit: I think some of the trouble is because by default cards clicked on in a list-of (songs) view invoke a details view. Is there any way to avoid this and use the selected data as the input to an action?
Is there any way to avoid this and use the selected data as the input to an action?
Yes, set has-details (false) in your view model, read more here
You need to add on-click with the intend PlaySessionOfDay
You would also need implement PlaySessionOfDay so it could take an input (I assume you have more than one content to play)

geo.NamedPoint is taking current position if not provided the city name in bixby

My utterance is What is happening in New York. While Training I have set New York as geo.SearchTerm and in action file, i have collected input as cityName and type is geo.NamedPoint. Now if I am asking what is happeningin Birlin, so it is giving me NamedPoint of Birlin but if I am saying "what is happening" without taking the city name so for the first time it is giving me location of Berlin and second time it is giving me the current location. What I wanted that if question is asked with location then give me the location details else no details at all. How to acheive that?
Here is my action file
action (EventSearch) {
type(Search)
collect{
input (dateTimeExpression) {
type (MyDateTimeExpression)
min (Optional)
}
input (cityName) {
type (geo.NamedPoint)
min (Optional) max (One)
default-select {
with-rule {
select-first
}
}
}
}
output (EventConfirmationResult)
}
As you mentioned in your comment to my question, you would indeed need to create a wrapper similar to the DateTimeExpression structure described in the help center article for defining a transient structure.
I've also shown the relevant code below:
structure (CustomDateTimeExpression) {
role-of (time.DateTimeExpression)
description (wrapper for DateTimeExpression)
features {
transient
}
}

Resources