Uh oh! We couldn’t find any match.

Please try other search keywords.

Bixby Developer Center

Guides

Open Hours (viv.openHours)

Businesses often need to define the set of hours in which they're open each day. The viv.openHours capsule provides a set of concepts for defining those hours, and actions that allow users to query businesses defined in your capsule (or in viv.business) based on those hours.

Models

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

HoursInformation

This is the primary structure concept in viv.OpenHours, holding all the opening hours information for a place.

PropertyTypeKindNotes
weekWeekOpenHoursstructure
todayOpenHoursTodayOpenHoursstructurerole-of DayOpenHours (1)
isOpenNowIsOpenNowboolean(1)
isOpen24Hrs7DaysIsOpen24Hrs7Daysboolean(1)
nowOpenHoursNowOpenHoursstructurerole-of time.TimeInterval (2)
isClosedPermanentlyIsClosedPermanentlyboolean(3)
  1. This is automatically calculated for you based on the current time and date and the information in WeekOpenHours.
  2. See viv.time for details.
  3. If this flag is set to true, none of the hours defined will apply. All actions involving hours for a business that isClosedPermanently will indicate the business is not open.

WeekOpenHours

This contains all the open hours for a business; it has seven properties for the seven days of the week. Each property is assigned a role-of DayOpenHours. All of these properties have a cardinality of min (Required) max (One).

PropertyTypeKindNotes
mondaysMondayOpenHoursstructure
tuesdaysTuesdayOpenHoursstructure
wednesdaysWednesdayOpenHoursstructure
thursdaysThursdayOpenHoursstructure
fridaysFridayOpenHoursstructure
saturdaysSaturdayOpenHoursstructure
sundaysSundayOpenHoursstructure 

DayOpenHours

This structure is generally not accessed directly, but is instead accessed through the properties of WeekOpenHours as an instance of MondayOpenHours, TuesdayOpenHours, etc.

PropertyTypeKindNotes
openHoursOpenHoursstructuremax (Many), role-of time.TimeInterval (1)
dayOpenDayOpenenumRequired (2)
  1. See viv.time for details.
  2. When accessed through MondayOpenHours, TuesdayOpenHours, etc., this enum will be set to to one of Mondays, Tuesdays, Wednesdays, etc., via bind.

IntervalOpen

This is an enum that will resolve to either the symbol Weekends or Weekdays. It can be used for training purposes, for utterances such as "Is Sprouts open on weekends?"

OpenHoursJudgementQuestion

This is designed for training yes or no questions about whether a business is open at a specific time, such as "Is Safeway open right now?"

OpenHoursConstraint

This is a training goal similar to OpenHoursJudgementQuestion, but rather than a "Yes" or "No" answer, use it to train open hours search constraints, such as "Find Thai restaurants open right now."

OpenHoursWHQuestion

This is designed for training questions whose answers are specific open hours, such as "When does Safeway open tomorrow?"

Usage

Opening hours should be added as a property of your business structure, typically containing the HoursInformation concept. (If you use viv.business, it is included as the property hoursInformation.) If your business requires an extra API call to fetch hours, use lazy-source to fetch it asynchronously when the property is referenced:

structure (Business) {
...
property (hoursInformation) {
type (openHours.HoursInformation)
lazy-source (business.GetHoursInformation)
}
}

Training

Open hours can be accessed as property projections. You should train both on hoursInformation and on its properties, such as todayOpenHours. Here are some good training examples, represented as aligned NL:

[g:business.Business.hoursInformation] What are the opening hours of
(Sprouts)[v:business.BusinessName]?

[g:business.Business.hoursInformation.week.sundays] What are the Sunday hours
for the (library)[v:business.BusinessCategory:Library] in
(Dublin)[v:geo.LocalityName] (CA)[v:geo.ISOSubdivisionCode]?

[g:business.Business.hoursInformation.todayOpenHours] What are today's hours for
(First Third Bank)[v:business.BusinessCategory:Bank]?

Finding Businesses by Open Hours

You can add an input to your FindBusiness action (e.g., whatever action in your capsule finds businesses based on search inputs) to accept an open hours constraint:

action (business.FindBusiness) {
type (Search)
...
input (openHoursConstraint) {
type (openHours.OpenHoursConstraint)
min (Optional) max (One)
}
output (business.Business)
}

Then, train within your capsule:

[g:business.Business] Find a (bank)[v:business.BusinessCategory:Bank]
{[g:openHours.OpenHoursConstraint] (open)[v:openHours.OpenHoursDescriptor:OpenAt]
on (weekends)[v:openHours.IntervalOpen:Weekends]}

Answering Open Hours Questions

You cannot set training goals of OpenHoursJudgement and OpenHoursWHAnswer directly, because goals for training must belong to your capsule. To use them, define primitive concepts in your capsule that have a role-of the appropriate concept:

primitive (business.OpenHoursJudgement) {
role-of (openHours.OpenHoursJudgement)
type (Enum)
symbol (Yes)
symbol (No)
symbol (Unknwon)
}

primitive (business.OpenHoursWHAnswer) {
role-of (openHours.OpenHoursWHAnswer)
}

Then, you can train with those goals:

[g:business.OpenHoursJudgement] Can you tell me if
(Walgreens)[v:business.BusinessName] is {[g:openHours.OpenHoursJudgementQuestion]
(open)[v:openHours.OpenHoursDescriptor:OpenAt] (right now)[v:time.DateTime]}?

[g:business.OpenHoursWHAnswer] What time does (Walgreens)[v:business.BusinessName]
{[g:openHours.OpenHoursWHQuestion] (open)[v:openHours.OpenHoursDescriptor:OpenAt]
on (April 2nd)[v:time.Date]}?