Watson Assistant: Context variable in slot is not being updated - ibm-cloud

I'm currently working with some required slots in Watson Assistant, but I have a problem that I don't understand.
When the user enters the node with the slot the first time, the variable is updated with the corresponding value, but the second time I try to enter the node (without entering the entity), it ignores the slot as if the entity had been entered.
I know that the context variable is keeping the original value, but should not verify that the entity exists instead of the variable?. Are there some best practices to clean this kind of context variables (either in the UI tool or the backend)?

A context variable can be used to store values across dialog steps. You determine when it is set and when it is cleared. You can clear the context variable by either
setting its value to null or
removing the variable.
Usage depends on your design and flow.

Related

Reset TFDMemTable to default (no field definitions) at Runtime

I have a raw TFDMemTable at design time. I only activate the same at runtime and simultaneously display data through a grid component. The fields will be defined at runtime depending of its source (API REST) and user case.
At runtime, I need to reset the TFDMemTable to its default. Meaning, remove all the fields definition and accept another fresh data and field definitions.
Currently, the fields set by the first ran during runtime was fixed and it is not accepting any new field definitions. I am contemplating on creating TFDMemTable at runtime but I still have to figure out. I am hoping there is a better way..
Real quick question: How can I reset the TFDMemTable to its default at runtime (no fields definition)?
UPDATE 1:
TFDMemTable will receive JSON data from API. This API throws data with unknown number of columns/fields. Meaning, it can only determine the fields upon received of JSON data. Hence, I'd like that each time I called API, the TFDMemTable should redefine all the fields to be able to capture the API fields.
So, from my understanding, if I could be able to reset the TFDMemTable I could avoid this issue.
You can use TFDMemTable.ClearFields to remove all of the existing field definitions.

Which are the default attributes of an agent in Anylogic? What is the proper way to copy an agent?

I am trying to figure out which are the main default attributes of agents in Anylogic, e.g., the Id, the position and the index. So far I haven't found them in the help or at stackoverflow.
1) Do you know where this can be found or can you summarize the main you know? For instance the id used as unique identifier or the index used as the position inside of the population.
2) Are there any attributes regarding the agent history? For example time stamps as the creation time or the blocks it has passed through?
3) Is it possible to change the default id attribute of an agent? Can two agents have the same id?
4) As the split block doesn't copy any of the parameters or variables values to the copy, what is the proper way to copy an agent? I noticed in other publication Benjamin mentioned using agent.set_MyParam(original.MyParam). What would be "MyParam" in this code? Would this copy the value of parameters, variables and the current state in the statechart? Is it possible to make a copy and initialize its current state in the statechart as the original agent's current state?
Thank you for your help.
There are many things that are generated when you generate an agent... the best you can do is to check the api for the agent here: agent api
You can only see these things on the log if you activate it, but not from the API
the id is a unique identifier and i've never been in a situation where i need to change it,but if you want to change it, you can use the setId method, in which case, 2 or more agents may have the same id.
you can only use set_MyParam if the MyParam is a parameter, you can't do the same with variables. Nevertheless, if you want to copy an agent, you need to do it variable by variable, state by state, everything from scratch. There's no magical way to copy the exact same agent with all its current values and states and connections etc

Watson Assistant Chatbot saving user inputs in Slots

I'm using Watson Assistant Chatbot..I want to save a variable from the user input by enabling Slots and system entities like #sys-number.. I can save number by choosing check for #sys-number, or saving date by choosing check for #sys-date... But for text/characters I can't find something like #sys-text or #sys-char..
I tried to save text while check for #sys-number, but the answer is not saved into the variable and the question keep repeating in th chatbot console.
So, how can I use Slots to save text from user input, I mean what should I put in "check for", please?
Thanks,
Numbers are always numbers, no matter your language and context. Dates are always dates as well.
However, "texts" can mean many different things, and they depend on context. That's why you need to create a separate entity for each meaning in your context.
For IBM Watson Assistant, there is no reason to detect "any text" unless that text means something in your context.
Supposing you want to detect the word "smartphone". For Assistant, there is no reason to detect this word if it doesn't relate to any entity.
So, you need to create an entity (e.g. "#Product") and then give it a value named "smartphone". Then, whenever a user types "smartphone" in your Chatbot, Assistant will be able to recognize "#Product:smartphone".
In your Slots, in the "Check for" field, you can put "#Product". It means that if Chatbot doesn't detect any #Product (e.g. "smartphone"), it should repeat the question until it finds a valid product.

Bluemix Conversation, advancing the conversation

I have two conversation nodes defined. The first is triggered on conversation_start and asks the users's name. The second stores the user name from input.text in a context variable and asks if the user wants to take a brief survey or do something else. The second one never executes. What should the trigger be on the second one in order to advance the conversation? There is no intent or condition set yet. Basically, I just want to follow a string-of-pearls pattern where every question gets asked and let the user opt out of some of the questions.
there are two main ways to achieve this. The one I recommend is to create an intent for each possible way. For example, you could create an intent called #affirmative, with values like "Yes", "Yeah", "Sure", "Ok", etc. All you have to do is to create the intent and then use it in the condition field.
But you can also check the user's input directly, using input.text. For example, you could use input.text.toLowerCase() == 'yes' as the condition. Have in mind that this should only be used if you are controlling the input and only allowing a few possible values. If not, use an intent and let Watson Conversation handle the input parsing for you.
Another really cool feature that Watson Conversation provides that can benefit is you is to have a node with a condition like intents[0].confidence < 0.6 and a response like "Sorry, I didn't get that". That way you make sure your flow will only trigger a condition with a high confidence for the intent.
Hope it helps!
You can use the jump to function to route the system to arbitrary dialog_node - this is great for creating directed dialogs. So whenever you want to continue with the next question (user answered the previous question), you can use jump to from the node processing the answer to the previous question to ask the user another question (jump to the body part of the next dialog node asking new question).
Now for "get name" use case you want the second node gathering the name from the user input hanging off the conversation_start node. If the conversation encounters a node that has children, the processing of the next dialog round will start at the first child of this dialog node - this way the contextual dialogs are defined in the conversation.
Bluemix Conversation can be thought of as a state machine. Each transition is diagrammed in the tooling, but each node can only be triggered by a condition. So that if you're on a node asking a question, and the answer that comes back does not trigger one of the child nodes, the state will not transition to a child. Answers entered into a node are processed by Watson, who provides "intents", which are essentially keywords found in the sentence he just analyzed. So one way to advance the conversation is to match named "intents" using the # prefix to the trigger of in a child node. Another way it to match named "entities" using the # prefex, although it is less clear how Watson builds entities. The third way is to match context variables using the $ prefix and simple conditional operators such as ==. Context variables are entirely managed by you, the developer. You are allowed to set one context variable at each node. And then you can use it to trigger a child node. This appears to be a good approach to managing the type of conversation I want to implement. The fourth way is to use the previous parent node's input value using along with simple conditional operators.

How to make an InArgument's value dependant upon the value of another InArgument at design time

I have a requirement to allow a user to specify the value of an InArgument / property from a list of valid values (e.g. a combobox). The list of valid values is determined by the value of another InArgument (the value of which will be set by an expression).
For instance, at design time:
User enters a file path into workflow variable FilePath
The DependedUpon InArgument is set to the value of FilePath
The file is queried and a list of valid values is displayed to the user to select the appropriate value (presumably via a custom PropertyValueEditor).
Is this possible?
Considering this is being done at design time, I'd strongly suggest you provide for all this logic within the designer, rather than in the Activity itself.
Design-time logic shouldn't be contained within your Activity. Your Activity should be able to run independent of any designer. Think about it this way...
You sit down and design your workflow using Activities and their designers. Once done, you install/xcopy the workflows to a server somewhere else. When the server loads that Activity prior to executing it, what happens when your design logic executes in CacheMetadata? Either it is skipped using some heuristic to determine that you are not running in design time, or you include extra logic to skip this code when it is unable to locate that file. Either way, why is a server executing this design time code? The answer is that it shouldn't be executing it; that code belongs with the designers.
This is why, if you look at the framework, you'll see that Activities and their designers exist in different assemblies. Your code should be the same way--design-centric code should be delivered in separate assemblies from your Activities, so that you may deliver both to designers, and only the Activity assemblies to your application servers.
When do you want to validate this, at design time or run time?
Design time is limited because the user can use an expression that depends on another variable and you can't read the value from there at design time. You can however look at the expression and possibly deduce an invalid combination that way. In this case you need to add code to the CacheMetadata function.
At run time you can get the actual values and validate them in the Execute function.