 Welcome back to another microsoft bytes. I'm Stratus I'm Gez. I love that clip Today we're gonna be continuing on our series on having mycroft gather information from the user after something has happened So we're going to be using ask. Yes. No today. It's a relatively simple in terms of the input output that we feed it and Because of that, we're not actually going to show it in action because it's very similar to get response So instead we're just kind of kind of walk through the additions of code that we have to our ice cream skill so that you can kind of see how we built it But there's not really much value in showing you, you know, mycroft in action on this So with that, I think we're going to jump over into an IDE instead of a terminal today and just kind of walk through the code Awesome. Let's do it So here we have the still that we've been been working on for a number of weeks the ice cream shop skill and We want to add this ask. Yes. No method. So to do that. We're going to Process the payment for the ice cream that these people are buying and then ask whether they would like to provide a tip With that payment or not we've done most of this already So we'll just just walk through it a little bit after we've spoken the dialogue and and provided the ice cream back to the Customer will add a method to process the payment and then start to build that out So to keep this symbol, we're just going to have a fixed cost of five dollars I'm going to tell the customer what the total bill is and then we're going to ask them Whether they would like to provide a tip. So for this, you know, it's very similar to the get response method And the other methods that we've looked at do self don't ask. Yes. No And provide a dialogue file and then a data object if we want to inject any Dynamic data into that dialogue Just like the get response. It's going to return a string and it's going to return one of four things So if there's an affirmative response, it's going to reply with yes. It's going to return. Yes this is Not only if the user responds with yes, it's going to do any kind of affirmative response So yes, sure, you know, all those sorts of things which to a human mean yes But not just returning if the string equals YES. It's it's for any type of affirmative response In that case, we can we can add a tip in thank the customer and move on But if they say no or you know a negative type response, then it will return the string and no And so we can check for that. The third one is is it can return none so if we ask this question and The customer doesn't respond at all. They're sitting on their phone. Whatever. It's going to return none So that that tells us that no response No utterance from the user was received so then we can do what we like there and Then finally if the user responds with something, but it's neither an affirmative nor a negative response So they might say bananas For whatever reason and that will return the full utterance and so We often get questions about you know, why is this the case like it seems quite weird if we're if we're asking a yes No question. We should only really care if they say yes or no And people people don't often expect, you know, none or the full utterance the times where this might be useful, you know, imagine imagine the user Wants to add something else to their order. And so they reply with oh, actually I'd like another ice cream, please. Well, you know something like that Maybe they want to provide a custom tip amount. Who knows there could be could be incidences where You want to know What the user said Given that microf doesn't believe that it was a yes or a no answer and so you can use that there or you can not you can just say If they didn't say yes, I don't care about anything else So, you know delete all this that's fine, too. Great. So now we have we have the tip amounts that we've calculated for each You know each response type we can add that to the to the cost to get a total and then we'll probably report that back to the user When we were kind of chatting about this one of the things that I I kind of questioned was why are we using the ask yes No Rapper around get response when you could just simply use get response and do the checking because if you saw above We had an if statement if it was yes or if it was no or if it was none So that seems to me to be No added value in having an ask yes. No Method so I wondered if like maybe you can explain a little bit why we don't just do this ourselves Yeah, it's a question we get pretty regularly and and as I said like it really is a Rapper around get response the magic the magic really comes when you hit these vocab match methods And so now you can you can implement this in your own skill if you wanted to as well But what we've seen is that generally people start with something really simple like get the response and then check if the Response is the string yes, then do something or even if this if yes is in The response then then do something but the the limitations of this is that it's only going to work in English And it's only going to match if the response actually contains the letters way Yes, and so it will actually match if someone says something like yesterday That will also return as if it was an affirmative response, which probably shouldn't be the case And so what Vok match does is it it uses the vocab file for yes If there's one in the skill it will use that vocab file But otherwise it's going to use the one from my crop call which has a whole range of vocab in A number of languages that indicate an affirmative response So it might be yes, it might be sure it might be Yeah, it might be the tool for Indonesian I don't I don't think that was actually in my crop call yet but you know it can work for a range of Affirmative responses across languages depending on what language the the user's system is set to and So it's just a much more robust way of checking Whether things are affirmative or negative, you know rather than using these direct sort of string comparisons Which can work in a limited range of circumstances, but you'll find you run into all sorts of Issues when once you actually start using that in the wild and and that's how this method has come about is you know We've seen a number of skills try and do this in a range of ways And this is the way that we recommend that people do it And so that's why we made it a method available on the skill class so that it really just makes it easier for you to do a Very common thing and do it in a way that's consistent So that the users get a very consistent experience as well Make sense. So yeah, yeah, it's a great question and As I said, you know one that we get all the time. So good to cover That was ask-as-no and as we showed you it was built on top of git response But in a very standardized way that the mycroft team recommends that you handle these sort of approaches Really the big takeaway for me was the ask-as-no deals with the translation for you and that is really helpful when you're thinking about pushing out your skills to a wider audience Is there anything else that you want to talk about with ask-as-no? No, I think, you know, there's some other ones coming along the pipeline where we're looking at potentially having an even simpler ask-confirm method that only returns yes-no Potentially, so if you think that would be useful then we came to hear about it in the comments, you know, we always want to Make things simpler for for mycroft developers, but we also don't want to add things just for the sake of adding them So let us know what you think is going to be helpful and keep telling us Yeah, what what other videos you think would be helpful to to help you get across concepts? We've received a few suggestions at the moment and and we're looking at those for future videos. So yeah, keep it up Thanks, and I guess with that I will wrap this this episode up and we'll say until next time Until next time