Hello guys. Welcome to the 36th session of using Microsoft both framework Luis and cognitive services tutorials for beginners. In this session we will learn how to manage state in boats. The boat builder framework enables you both to store and retrieve state data that is associated with a user a conversation or a specific user within the context of a specific conversation, we can use state to determine where the prior conversation left off. You can store a user's preferences in the state to use that information to customize the conversation the next time you check. In this session, I'm going to use in memory to store state data.
But in a production environment, you need to use Azure table or Cosmos dB. Here are some common methods for add, remove or retrieving data from state those methods are basically divided into three parts. That is user data conversation data and private conversation data. Set user data for saving state data for the user on the specified channel. Get user data for getting state data that has previously been saved for the user on the specified channel. Delete state for user for deleting state data for the user that has previously been stored by using either the set user data method or the set private conversation data method.
That conversation data for saving state data for the conversation on the specified channel. Get conversation data for getting state data that has previously been saved for the conversation on this specified channel. Set private conversation data for saving state data for the user within the conversation on the specified channel. Get private conversation data, forgetting state data that has been previously saved for the user within the conversation on the specified session. In this session, I will create a boat in which opting vary from a user and give a link to the user for search. This question could be from Bing, Google, Yahoo, or DuckDuckGo.
Which search engines link will be given in depends on the state, the user can configure value. Here is a class that I have created. This is a key that will be used to store and retrieve data from this state. This dictionary contains links to those popular search engines and call message received a sync method from start acing method and obtain the message that the user typed here, the user can type change to change The first search engine, there is add data in private conversation data and when user type default, it will display current data from both conversation data and private conversation data. In satisficing method, I'm going to add being in conversation data for that. Context conversation data dot set value, state underscore key and bring in message received a sync, we need to check whether the user type of change.
Then it will display prompt dialog. With title select default search engine. After selection, it will resume to resume after changing search engine and option will be keys of our dictionary Right return to stop for the execution. Let's create a smarter optimum value from the result. And use context that private conversation they cannot set value to add these private data and display a message that your default search engine is changed to this. After this we need to return to this message received a sync back and now we need to check when message Texas default.
In this case, create a string variable for user default and conversation default. Right context conversation they cannot get value to obtain value and pass the key for which unique value By using context private conversation data does try get value method. Obtain value in user default as our parameter. If we got value, then the split both have default values. Otherwise, it will display only conversations data. If the user writes any other text, then we need to generate links based on the query and surcharging means storing state.
For that often default search from private conversation data. If we got none then we will return the value from conversation data And written message which contains two parts first will be search engines URL and another will be query that user type is encoded. Let us say we can create a new conversation. Let us send Hello. Here we got the link of being. Let us click on it.
Here mean was open with query Hello. That is right default to see current configurations. We got only been in conversations default. Right change because trunk for changing search engine, I'm going to use that code Right good. We got the link of the code which query string node. And let us check default search engines.
We got being in conversations default, and that going users default configuration. Let us see what we have learned in this session. We can store and retrieve some kind of information to manage state inputs. We can store the time user conversation and private conversation context. In this example, when a user logs change, it will display to change default configuration. When writing default, it will display values from conversation and private conversation.
Otherwise, the data query and return it. When a user selects any value from out, we will add it in private conversation data. Thanks for watching this video. If you haven't doubt, feel free to contact me Have a nice day.