Effect that re-plans to a new intent, after an optional dialog event.
When purchasing tickets to a show, we would like to not only fetch the user's email address, but also save it to their profile. We can do this when validating the incoming profile email using replan:
input (self) {
type (profile.Self)
min (Required)
default-init {
intent {
goal: profile.GetSelf
}
}
validate {
if ("!(exists(self) && exists(self.emailAddresses))") {
replan {
intent {
subplan {
value { $expr(self.emailAddresses) }
goal { @prompt-behavior(AlwaysElicitation) contact.EmailInfo }
}
goal { profile.UpdateSelf }
}
}
}
}
}
We can use the replan effect to redirect the user when we catch a checked error from the action implementation. Here we redirect the user to the select payments screen upon detecting invalid payment information:
error (InvalidPayment) {
on-catch {
replan {
dialog {
template ("We couldn’t process the payment on your card. Please double check the details or try a different card")
}
intent {
goal: ticketmaster.BuyTickets
value: $expr(cart)
}
}
}
}
Copyright 2024 Samsung All rights reserved