 Hello everyone. Welcome to this morning's show, Does What. I'm Tom Slough. I'm coming from Croatia. I'm not sure if you know where is Croatia, but this is a really small country in the middle of Europe. Actually, it has only two and a half million citizens there. But we have great, really great coasts and really great soccer players. Anyway, today I will speak about chatbot development. I'm not sure if you are familiar with chatbot development at all or cool. Okay, we will go through the whole process from the beginning. Okay, so the name Does What actually mean nothing. So there was an early 80s in Europe was Techno or Euro Dance Mania. I'm not sure if you are aware of that. But during these days, there was many, many popular techno projects there in Europe. So one, it was U96 or Uzex 19 from Germany. They had two great hits, number one is during these days. One was Does What, and second one was I Want to Be a Kennedy. You probably don't know any about that. But during these days, there was really great hits. So there was a wide US name, Does What. Okay, before we start with chat development, I'd like to just put you in the context to better understand what I want to show you actually today. I will show you one chatbot, which kind, let's say, we will try to build during this session today. There in Croatia, I'm working for several companies. I'm working for my own company, a software development company, for a five agency, which is one of, let's say, top number one mobile development company in Croatia, which has the main office in New York City. I work for Top Tel, and I work also as a lecturer on the University College Algebra in Zagreb. So it's a really small university, but for us it's important because we are private university and now, which is not very common actually in Croatia, only few private universities are there, and we are top number one actually IT university there. Right now we have more than 1,300 active students there, which is not something for you in the States, but there in Croatia, who has actually 3.5 million citizens there, it is really something. But what the problem is with every new student, we have actually the more problems with the student service like any other university. So we need somehow to solve that issue. A possible solution is not to hire more staff to the student service. So other thing that we could do is, let's say, re-engineer our processes, internal processes, and make it more faster and more fluent, and then what we do, we actually discovered, I mean discovered, during our research we discovered that more than almost 80% of top students' issues would be easily solved actually to some existing services, which is not connected anyhow. So the solution for their issues actually exists somewhere inside Algebra, even on the web page, social networks, internal internet or something like that. So we decided to combine those services, make an API, and make it optimized. So the solution, one possible solution for that is to build some kind of mobile app or web app or something, but we decided to build a chatbot actually. It looks pretty nice, it's still in hard development, but the key concepts are actually here, there's three possibilities. One is when students need some basic information about contact info, prices, something like that, that's something that actually exists on our website or somewhere. So the chatbot should be able to go to that kind of open sources, grab those data, represent it to the user. Second possibility is something which is not open to public, that's something which is our internal, let's say student homework, student thesis, something like that. Although thesis should be digitalized and put some kind of knowledge base, Algebra knowledge base, so the chatbot should be able to go to that knowledge base and try to find the answers there. And the third one is actually if there is no possibility to find the answer on those two scenarios, first two scenarios, then we can go to internal staff or CRM and try to find the best person who can solve our issue. So let's say if I'm doing my homework and stuck on some algorithm that I don't understand, I need a person or student or professor or whatever who can help me with that algorithm. And also here's some other things that we can do, that part of chatbot or our system should be able to, I don't know, borrow me a book from a library, check when I have next exam or check my finances, which is also very important for private university. Oh, you maybe know who is this. Lucy Moran from Sheriff's Truman office in Twin Peaks. Have you ever watched Twin Peaks? Okay, it was very famous actually TV show, David Lynch TV show, featured in Seattle during the early 90s. Anyway, this is Lucy Moran, she is secretary of Sheriff's Truman and she's the one who should actually solve any issues that Sheriff's Truman has like any other secretary. So we choose her name Lucy for our chatbot. You know that any chatbot should have some name. Okay, so I was just to show you a few scenarios how the tech chatbot works. For this chatbot we use, for now we use Slack as a channel, but it could be any kind of other channels like Facebook Messenger, sorry Skype, but it could be Slack, Facebook Messenger, web chat, whatever. Okay, so I'll start interaction with Lucy. She recognizes that it's me and she offered me a few shortcuts like any other chatbot that could, let's say, common things that the students need to do with the chatbot. But I prepared something more weird, let's say, first one. I'll just copy, it will be easy than typing. So InfoEducah, InfoEducah is our student digital service. So sometimes that InfoEducah is blocked. A very common reason why it's blocked is because the student doesn't pay all the bills that he could pay. Okay, so I will ask Lucy to check my finances. If there are any issues with my finances, maybe that goes for blocking my InfoEducah. And Lucy go and try to my CRM. Okay, I pay all my dues. So there is probably another reason why it's blocked. But what I want to show you here, Lucy recognized my intent that I want to check my finances. So she got the branch of finances and checked my finances. I could do something more complicated like this. So I'm thinking to go study abroad. It's a very popular Erasmus program there in Europe for student interchange. But I need someone, I need someone who can help me with my enrollment process. Okay, so I need someone who can help me. And yes, Lucy go to our internal staff database and try to best match who can help me with my enrollment process to Erasmus. If we go to our staff database, we will see that Christina actually is Erasmus coordinator. So she's the only one here specialized for Erasmus coordinator process. And she's the one who is the first choice for me. So that's something which is easy. It could be more complicated. I could do something like this. So I am a student. And me and my pals, we are doing some job in Algera lab. We are almost done with that. So we need, at this moment, we need two marketing experts to help us to push our product to the market. Let's say like that. So what's the intention here? To find two marketing experts for us. Again, Lucy will go to our internal staff database. And she found two marketing experts for me. So again, if we go to our staff database. So Natasha and Tomislav are marketing guys. So that's the reason why they came to me as two choices. But there is one more. There is Vanya. Vanya is also a marketing guy. Why those two? Why not Vanya? Well, because Vanya is not an expert. So I asked for two marketing experts. So that's something that I want to show you how Lucy can recognize my intent and what I want to actually grab. The situation could be even more complicated in a situation like this. So we are working on our project in Algera lab. But my teammates actually do nothing. So I'm pretty angry on them. And I desperately need someone to help. Okay, so again I need two marketing experts, but I'm crazy on my teammates. And in this moment, Lucy found me only one, Natasha. So you know that we have in our database, we have two marketing experts. Natasha and Tomislav are marketing experts. But if you just take a look at the picture of Tomislav here. You will see that he's a pretty grumpy man. And if I am in that moment, if I'm crazy, so maybe two of us are not a good combination in that moment. So if you now take a look at our stuff database, you will see that yes, internal HR or students or whatever, grade Tomislav with number, I mean the lowest grade in sentiment column. So that's the reason why he didn't choose. Okay, there's a few more things that I want to share in presentation. What we discovered during this process is that building bots is actually a pretty easy thing you will see today. In this presentation, but the building intelligent one is pretty high. You need to interconnect so many services that could be able to discover the knowledge that you need. From the IT solution perspective, bots here is actually just an interface. It could be anything. It could be web page, web application, mobile application, bot, whatever. We use bot. But from the technology stack, that's an interesting part because let's say I'm coming from Microsoft World and all of these bots that I will be talking about today is actually built on open source technologies. Everything in yellow is actually open source. Just a few services that we need to consume are not open source. Okay, let's see how to build a bot like this. I will go step by step just to make you familiar how to build a bot from the beginning. You will understand it's not so hard actually, like it looks. We have four or five steps. Okay, so this bot is built on Node.js. Node.js and everything that we need for, let's say hello world bot is a bot builder. So if we go to step one, step one is great example of why does it zoom in and zoom out? It doesn't work. Okay, it doesn't work. What we have here is two key things or let's say two key ingredients for this scenario. One is bot builder. Bot builder is a Node package provided for Microsoft. It's open source package. It's key ingredient for any chat bot based on Microsoft technologies. So there in the reading file you have actually few lines of code that you need to copy and paste to your Node, to your JS page. And you can start it on Node.js server and that's it. You have a hello world bot. Our example is even simpler than that. So if you check here, we need a builder, we need a chat connector and we need a bot. Those two things. Every bot had it. In this moment we will use a console connector. So everything what we will be doing in a console. Okay, the end idea is to put chat bot somewhere in public and consume it on some channels like Skype, etc. For this purpose we could use a console also. And now I will start my step one bot and that's it. So if I type anything, you will see he will write high on bot. I mean that's normal because we have only one function here. So whatever I do, he will write high on bot. So it's pretty stupid bot but it works. It's hello world bot and it works. What's most important thing here to remember is dialogue. So every chat bot is build on several, one or I don't know, hundred dialogues. Like any web page. Web page website actually have many web pages. The similar thing is in chat bots. So chat bot could have many dialogues. For example, one dialogue is order a pizza. Second dialogue could be choose what kind of pizza. And third dialogue could be pay a pizza. And I don't know, next could be receive something like that. So those are dialogues. Every chat bot will probably have more than one dialogue but this is hello world. Second thing that I want you to learn from this session now is step two. So step two is actually almost the same equal like step one with one difference. We have two functions here in our dialogue. So if I say, okay, the first function will ask me what's my name. It's Tomislav. And he will say hello Tomislav. This is really actually important. Every dialogue, every dialogue could have more than one function in this functions array. That's something that we call waterfall. Okay, so why waterfall? Because the output of one or first function will be input to another and that's it. So if you go to order a pizza, you can add many ingredients on pizza. So that could be a water flow actually inside of our dialogue. So dialogue is one thing and waterfall is second thing that you need to remember. Every chat bot doesn't matter which technologies are built work on the same principles. Third thing is step three. Oh, this is something more complicated. I will not to explain everything why. Because everything beside building a bot is actually not important. Here I'm trying to build a movie recommendation bot. So I want to ask my bot, can you please recommend me one horror movie from early 90s? Let's say something like that and he will grab and turn me back to one movie. For that purpose we will use what we need is actually movie DB API or any other API. I'm not sure if you're aware of movie DB portal or not but that's free open service built from community for community. So everyone of you can go there, register there and start to sharing their knowledge, their experience about movies, etc. The good part here is they have open source and free service to bear the movies. That's something that we will use. It's nothing actually special. There's only a rest service that we will use to bear the movies. What's important here is that we will need another node module. It's movie DB and you can recognize something that we didn't have before which is intense. So the idea is to move to bot and recognize my intent, what I want to do here. If I order a pizza, he needs to recognize that I want to order pizza. If I want to grab information about movies, I want that he recognizes my intent to grab a movie, information about movies. That's the third thing that you need to know about chat development. So intense, very important thing. Every chatbot has several intents, 100 intents. Our Algebra chatbot will have at the end, I don't know, 200 maybe intents, possible intents. So if I want to check my finance, if I want to check my grades, that's also a different intense. Okay, so I have an intense dialogue and in my dialogue, the dialogue will be raised. It depends on the intent. So if I check here, nothing of this is not important. If I check here, intense movie, he will know that he needs to do something about movies. And that's basically it. We have only one and we have just one more, which is default. We have default one and we have movie. So in a situation on default intent, he will raise dialogue ask name. So you see that we have several intents and several dialogues. One of dialogues is ask for name. Second dialogue could be genre prompt and the last one will be ask me for a year from which I want to my movie. So if I start my bot here, now it's triggered default event, default intent. Okay, so he asked me for a name, about my name. Okay, Tom, here we are. He said, okay, I'm your one here. The only thing that he know actually is movie intent. So I need to write down movie. So my bot will recognize that intent as a movie. Now the movie intent is triggered. Now it's genre prompt raised. Okay, which genre? I don't know, action movie. Now it's raised a year prompt. Which year? I don't know. And here we are. Dragon Hill, the tree of something I don't see. Okay, so that's something that my bot recognize go to movie DB, try to find one action movie from 90s. Okay, that's good. Everything that we did till now, we did in console. The next step is actually put it somewhere on some of the clients like Skype, Slack, etc. For this example, for next example, we'll use the same example, but in the emulator. So step four example is equal like step three. The difference is only in, we don't use console connector, but chat connector. That's only actually difference. And the one more difference, we need the server for that. We need to use internal Node.js server for that. That's only difference. Everything below is equal like on a step three. So you will see if I start my step three JS, step four, sorry. It will be raised on a server on port 3978. Okay, so what I need to do now, actually my bot is now served on my local server. If you know address of my bot, you can access, yeah, you can access them with your client Skype or whatever. But I will use it here, what happens here? We have a problem how it happens. I'm not sure why it's on so much. Okay, I'll try to quit it. Every time this happens with the live demos. Just a second. I'm not sure why it's on so much. I'm sorry. I can, I can show you that. I cannot show you that. Okay. Sorry about that. It doesn't work. It doesn't work. You can go further. You need just to believe it. You can do that. Okay. So what I want to show you here with emulator is actually that, that's not good. I should show you that. Anyway, it doesn't work. So the same thing will happen here in a console, like an emulator, like my client as Skype actually. So what we can do is last thing, which means that we need to publish our bot to the Skype. Okay. Or any other client services, which can be used for that purpose. For that purpose, we can use several, several actually scenarios, but we will use Azure, Azure code component for, for serving a bot. But before that, why I like to show, why I like to show you an emulator, but it doesn't work. Unfortunately, I don't have idea how to, how to zoom it in or out. There's one more thing that I want to show you. So our bot, as you may saw here, is pretty stupid. Why? Because if I, if I want to trigger movie intent, I need to write down movie, movie word. It's, it's not good enough. It's not good enough. If you saw here, if you saw here on my chatbot, I could ask something like, I don't know, what was there? Yeah. Sentence like that. So, so the idea is from sentence like that, that my chatbot recognize my intent, my intent find me some person for me who can help me and recognize that I need two marketing experts. Okay. That's something that we, that we need. So to trigger like a type of just the movie, then ask for a genre, then ask for a year. It's not good enough. It's going to be better if I can go there and I ask me, I don't know, three horror from, from 90s. Something like that. That's something that we want. Okay. It's also possible, but for that, we need some kind of language understanding service. There is a many language understanding services in the world. Google has their own Facebook has their own Microsoft also. We will use Lewis. Lewis, I will copy this sentence here. Lewis is Microsoft language understanding service. It's pretty good. It works pretty well. So if you just take a look on first page of Lewis, you will see a few examples. Let's say here, book me flight to Cairo. This is my first uterine from this book me flight to Cairo. My boat should recognize book flight, book flight intent. Okay. And it should recognize where to Cairo. Okay. That's two things. So if you, if I press this one example, you will see, sorry, you will see that. Yes. Book flight intent is recognized almost 100% sure occurrence. Okay. But there is also more intense than that one. We have, I don't know, book flight, non-location finder, et cetera. That's all intense that we have. But from this sentence, he recognized that is, that he need trigger book flight intent. That's not all. He also recognize entity Cairo location. So we have two things. I don't know. If you go to order me two pieces, here the intent is food order, almost 100% sure. And also he recognize that we need two pieces. Okay. So that's something where our understanding service could help us. What we need here is that we need to build a model. For our movie boat, we need the model. And we need to train our model to become more occurs. So if I go to my apps, I have several of them here. But what we need here is movie app. Okay. If I go to build, that's what I'm doing. So I have a list of several intents. There could be a hundred intents. It doesn't matter. But for our movie boat, we need actually three. Hello. That's for a start as a default. Movie and none. Okay. So if nothing from my sentence is not recognized, then none will be fired. None intent will be fired. But movie intent, that's actually really the most interesting thing here. I have a bunch of utterances here. Some of them I wrote out manually. Why? I need to put a few utterances manually because our boat, our Lewis model is pretty dumb from the beginning. He don't understand anything. So I need to train him. What I need to do is put some utterances there. Like give me three top rated movies from 90s. Then I will just need to mark a few things here. So three is a number. Top rated is sort by popularity. And 90s is daytime. That's something that I need to be returned to me for my movie intent. Or I say here, can you suggest me a horror movie from last year? So horror movie. Horror movie is a genre. Last year is a daytime again. So after the training, you will see here that all these utterances is pretty, pretty sure that belongs to my movie, my movie intent. Okay, so what I need might tend to turn me back. Those entities, daytime is a year, genre, number, how many movies I need, and sort. Let's say top rated. That could be sort. So if I go here and test my model with the last utterance. If you suggest me three horror movies from 90s and press enter, press inspect. You will see here, okay, yeah, it's a movie intent will be triggered. It's three number horror movies from daytime. Okay, you understand that. So that's something actually that cover everything that I need. If I ask my movie, my bought something like that, he'll return me this. That's everything that I need to fetch the movies from the movie DP. Okay, we will check that code. I cannot show you there in emulator, but I will just put you a few comments here, what you need to remember. For this purpose, the only difference before step five and step four is that we need that we have here. Luis model model URL. It's my URL from my account. You will see it here. Here we are endpoint. Okay, I will use that endpoint here. And I need a recognizer. Recognizer is the important thing here. Those recognizers could be several tons of that. I will use a Luis recognizer. And then in my intense object, I will put all my recognizers. I could have more than one recognizer. And that's basically that's only difference here. Okay, so my recognizer, we will determine back intent movie or whatever. And based on that, I will go to another intense and everything else is the same on hello intent. We have none intent. We have moving intent. And one more is none that default. Okay, that's the only difference. Okay, so that's what we should public somewhere. We will public it to Azure, but you can host it anywhere. Wherever you have Node.js server, even in your local machine, you can host it easily. You just need the server. That's basically the normal web app like any other. Okay, but what you need is to register somewhere, your bot. Register is somewhere. So you need to say, okay, my bot is hosted here. Okay, and you can use it on Slack, on Skype, or whatever. That's something that we need. There is something that where we need our Azure. I will show you how to do that. It's also pretty simple thing. This is my Azure account. If you want to register, you have, I think, a year free account for every service there. So if you want to play with that, you have enough time to do that. I will go to my resource groups. I have DevConf. Okay, so here I have two things. One is my chatbot service. That's my server where my chatbot is served. And one thing is registration. That's it. This registration is really important thing. On this registration, I will say, where is my bot? Where is my bot server? On which server? Okay, I will give him a name, an icon. And the most important thing is to choose which channel I will use, which channel. There are several channels. By default, you can use it on a web chat. That's by default. You can then grab that code and put it on every page, web page that you want. That's a web chat. Second one, choose Skype and you have several of them here also. So basically, it could be covered pretty much of the channels, possible channels. And the last one is Telegram. That's the last one. Okay, I could test it in a web chat here. So that's the same web chat that you can implement on your web page. So if I ask my bot here the same sentence, like this, let's say like this. And here we have my favorite one and some other hormones from 1890. Okay, so as you can see, it works. But I will show you how it looks, how it looks the code. What we need to do, we need to go here on Azure. And we need to, you'll see now, it's a really, really, really simple thing. We need to add a new resource. We will choose web app bot. Okay, we'll press create. The only thing that we need is a name and technology. It could be built on C sharp or Node.js. And we will use EchoBot. EchoBot is Hello World bot. Okay, so everything will be built. We just need to go to our bot and copy and paste the code for our step 5 and paste it there. And the bot will work. So if we work on our emulator locally, it will work once when it will be published. If you take a look on that code, you will see that it's basically the same code like we have on our step 5. So that's it. Then I need to go to my bot again, to my bot. And I have channels. Then I will go to Skype. It will send me the link. Send me one link. If I send you that link right now, you can add my bot to your Slack channel. If I press here, it will open my Slack and it will add my bot to the Slack. And this is the same bot. Okay. So it's the same bot like we had on our test chat on Azure. And that's basically it. There's only a few things that you should remember. First of them from this session today. First of them is dialogues. Every chatbot should have more than one dialogue. Inside of dialogues, you have many functions. Chained in a waterfall. That's another thing. Then the third thing is R intents. I mean R intents, yeah. A chatbot should have at least two or three intents like our mobile bot. If it's specialized bot, then you have less than, I don't know, ten intents. And in step four or five is recognizer. Okay. It doesn't need to be Luis, but it could be. There's plenty of them on market. That's key, four key things that I want to remember from today's session. Okay. This, my code is not, any part of this code is not somewhere on the GitHub, but if any of you want to share, want me to share with you that code, you can contact me over my, I don't know, Twitter account or my LinkedIn account. I'll be glad to help you with the chatbot development if you want to do that based on Microsoft technologies, Microsoft bot framework. That's it from me today. If you have any questions, feel free to ask now or somewhere at the hall. That's it. Thank you. One question. What are your step six? Oh, step six. Yeah. We need the emulator for that. But you saw that, no, I mean, you, it doesn't sell. Here you can see that my movie actually turned back to me only rough data like title, like description and the link to the image. Right? So the idea is to present it not like that, but like that, like this. Okay. So we have a hero card here and three hero cards in Curse cell. That's something which is in step six. It's more about, let's say, chatbot design. I cannot show you in emulator because it doesn't work for some reason. I wasn't see that anytime. I don't know. I don't even know how to zoom in or zoom out. Okay. We're done.