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
Related
i try to this code β
result-view.view.bxb
conversation-drivers {
if (size(arrayItem) > 0) { //arrayItem : item1, item2, item3
conversation-driver {
template-macro (arrayItemTempl){
param (arrayItem){
expression (arrayItem)
}
}
}
}
}
arrayItemTempl.dialog.bxb
template-macro-def (arrayItemTempl) {
params {
param (arrayItem) {
type (ArrayItem)
min (Optional) max (Many)
}
}
content {
template ("#{value(arrayItem)}")
}
}
result
enter image description here
for each error, list of error... how to loop in conversation-drivers and template-macro-def
I want each item to be separate.
[item1, item2, item3] ---> [item1] [item2] [item3]
Unfortunately this is not possible. You will have to define a conversation-driver manually per item.
conversation-drivers {
conversation-driver {
...
}
conversation-driver {
...
}
conversation-driver {
...
}
}
Remember that the user will need to scroll to see all the conversation drivers if they are too many. Consider not having too many conversation drivers.
It is not possible to display a variable-sized array of conversation drivers and this behavior is intended as per Bixby's Design Principles.
Conversation drivers are meant to show reasonable next steps to a user. In a properly scoped capsule, users should rarely have more that 2-3 next steps to choose between. As a rule of thumb, I would recommend no more than 4 conversation drivers without good reason.
Additionally, large numbers of conversation drivers may result in issues with the capsule approval process which reviews all capsules intended for the Marketplace for their user experience.
I would recommend exploring the Design Guides available in the developer documentation. The Designing Conversations and Designing With Bixby Views guides will be especially useful for your use case.
I have text output that contains "--John Doe" to indicate that the source of the quotation is John Doe. Bixby is reading it as "minus John Doe". I want to read it as "pause John Doe".
I have enclosed the speech() in tags.
dialog (Result) {
match: Content (text)
if ($handsFree) {
template ("\n\n") {
speech ("<speak>#{value(text)}</speak>")
}
} else {
}
}
Conversation pane in debug:
Dialog/<speak>I claim to be an average man of less than average ability. I have not the shadow of a doubt that any man or woman can achieve what I have, if he or she would make the same effort and cultivate the same hope and faith. --Mohandas Karamchand Gandhi</speak>
Template
<speak>#{value(text)}</speak>
It pronounces the -- as "minus". I want it to be a pause.
Bixby supports limited SSML and I don't think the <break/> tag is supported yet (you could give it a try), but that is the tag you would want. Inside this tag, you can specify how long you want to break for, e.g. <break time="1s"/> or <break time="500ms"/>. So applying this to your example:
<speak>I claim to be an average man of less than average ability. I have not the shadow of a doubt that any man or woman can achieve what I have, if he or she would make the same effort and cultivate the same hope and faith. <break time="1s"/> Mohandas Karamchand Gandhi</speak>
In your action JS, you would need to have something like
let quote = 'I claim to be an average man of less than average ability. I have not the shadow of a doubt that any man or woman can achieve what I have, if he or she would make the same effort and cultivate the same hope and faith. --Mohandas Karamchand Gandhi';
quote = quote.replace('--', '<break time="1s"/>');
To replace the -- with the appropriate SSML tag.
The documentation doesn't say Bixby supports this tag yet. About a month ago, some of the Bixby staff said in Slack that more SSML support is "coming very soon", but I don't think it has arrived yet.
User error. π Replace the two "minuses" with β (em-dash). Maybe that'll help?
There is no quick way, nor SSML would help in this case. You should use different content for display and speech.
define a structure with display and speech property. TextDisplay and TextSpeech are just Text primitive concept.
structure (MyStruct) {
property (display) {
type (TextDisplay) min (Required) max (One)
}
property (speech) {
type (TextSpeech) min (Required) max (One)
}
}
When creating such concept, make sure do the the replacement in your JS script so that myStruct.display = "xyz -- John"; and myStruct.speech = "xyz .. John";
define view file, the trick is that each dot in speech will create a little pause. You can control the length of pause by adding more dots.
result-view {
match: MyStruct(this)
message {
template ("#{value(this.display)}") {
speech ("#{value(this.speech)}")
}
}
}
If you use γ, reading it to be paused
like this:
template ("Hello #{value(text)}") {
speech ("Helloγ #{value(text)}")
}
and
quote.replace() is not good,
Try to add source (property) to your Content structure.
Content.model.bxb
Structure (Content) {
property (quote) {
type (viv.core.Text)
min (Require)
}
property (source) {
type (viv.core.Text)
min (Require)
}
}
and your dialog
dialog (Result) {
match: Content (content)
if ($handsFree) {
template("#{value(content.quote)} -- #{value(content.source)}") {
speech("#{value(content.quote)} γγ #{value(content.source)}")
}
}
}
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
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
}
}
I have a product entity and it has an images field that store the images names from the product but the images names depends of a part_number field that is unique, so if the user make a mistake in the part number and he wants to edit it then I also have to change the images names
I tried this but it does not works:
// class ProductsAdmin extends Admin
public function preUpdate($product) {
$old_product = $this->getSubject();
if ($old_product->getPartNumber() != $product->getPartNumber)
{
// change file names
}
$this->saveFile($product);
}
How I get the original row in preUpdate() function?
According to the topic taken from the official SonataAdmin google forum:
https://groups.google.com/forum/#!topic/sonata-devs/0zML6N13i3U
you need to make use of the class UnitOfWork:
http://www.doctrine-project.org/api/orm/2.3/class-Doctrine.ORM.UnitOfWork.html
Do this way:
public function preUpdate($object)
{
$em = $this->getModelManager()->getEntityManager($this->getClass());
$original = $em->getUnitOfWork()->getOriginalDocumentData($object);
}
Thus you get an array of values of your database entity.
E.g: to get access to the value password of your entity do:
$password = $original['password'];
That's all.
Enjoy :)
If you just do a doctrine query in the preUpdate function to get the product from the database you'll have the old object. Then do the comparison and you're good to go.