 Let's be crazy on this very comical chatbot, a place called The Bus Uncle. Anyone actually used it before? Maybe you've heard of it before? But it's okay. So today we have Abelage Monty here to introduce you to the chatbot that you built. To introduce you in very comical and local series way how to find your bus routes around. Let's give it a round of applause and welcome Abelage Monty. Hey guys, how are you all doing? So I hope you guys have checked out The Bus Uncle because it's actually when viral when I wasn't really expecting it but maybe if I had re-summed a new speed or something. So The Bus Uncle is just this bot I thought of building as an experiment and turns out people really liked it. So I went to build more on it. So I'll just kind of slice it up a bit. So how did the idea come about? When you're at the bus shop you're always with a huge bunch of people, a huge crowd and everyone's just so bored. Like they're just standing there and they're just waiting for the bus. Some of them are playing games, some of them are chatting with their friends or family. So this is an example of some things that people think of. Like ladies think about how long and this whole lady needs to show up. Like they're just so bored and they've got nothing to do with it. So even I was actually like a lot of those people once and I just wanted to not be bored because waiting for a bus is one of the most boring things you can do. So that's how the idea actually came about. And then sometimes I also wanted to know like how long you'd have to wait for your bus. So in a lot of bus stops they're given this electronic board which shows you bus numbers and how long you'd have to wait for each bus. I found this quite useful but one problem it had was there was way too much information. So if you would know in your mind which bus you want to take and what you would do is you'd actually look at the board and try to find it with your eyes. That's quite a lot of like COVID and overload there. And because of that some people have also built apps. So these are some mock-ups I made of some apps that you guys might have used. I'm not naming them. But even in these apps there's a lot of information. You just need to be scrolling through to find your bus in some time. You need to go to a text box, enter your bus stop location or your bus number. Other apps they find to make it better but still the text is too small or you still have to find where it is. Too much info. All I wanted to know is seven minutes. Something like this. So we are in a bus stop. You want to know how long the bus is going to take and if someone told you seven minutes then you'd be happy right? That's how a bus stop should start. Just give you exactly what you want. You don't need any kind of cognitive overload. Another thing is when you're at a bus stop you notice that a lot of people don't talk to each other and they're very silent. And because of that you get bored too. Even the government introduced this person called Hush Hush Hanna. You see in MRT's and basically they tell you to calm down and stop talking. So you just get bored. So I thought that bus uncle could actually be someone you could talk to as well because that's when the idea of giving him a personality actually came about. So that's when it started. So for all of you guys who haven't actually tried out bus uncle here's like a little demo. Not a demo of it but I'll just show you a few things that it does. So how you can access it is you can go to m.me-sg-bus-uncle. The screen here is not covering my whole screen but basically if you go to m.me-sg-bus-uncle you can start going to the bus straight away. If you're on your phone or anything you can do it right now as well. So what it does is when you start the app you just have to speak to it like a completely normal person. You can just say hello uncle or hi or whatever and the uncle will respond. So the uncle also like gives you an idea of what you can say next with a little button there. So if you click on that button the uncle will ask you to find... I mean the uncle will ask you where you are so you can get your bus stop location. So that's actually one of the inputs that's required if you want to be able to find out your bus time and how long you have to wait for the bus. And then for here you could enter like this in plain text about location you're in or you could enter the bus stop number or you could even just click on send location there which will use Google Maps and give the uncle like a map view of where you are. And for this example actually let me just like not use cold screen because you guys can't see the whole thing. Alright, I hope that's better. So for this example I used Maple Tree. It's a place and I just entered Maple Tree and the bus uncle searches through a database of bus stops they even searches on Google Maps just to look for the nearest bus stops that are near where you just entered and it gives you like this horizontal scroll bar where you can just scroll and choose choose a place. That's where your bus stop is. And then when you click on choose the bus uncle already knows about all the buses that goes to the stop. So it gives you a list there you can just select your bus number and once you select your bus number you just need to wait 10 minutes. So I've given the uncle some personality as well which actually makes it a lot more fun than other bus stops. A lot of other bus stops say 10 minutes. 8 minutes. That's it. It's like so great. So I tried to think of things you could do in 10 minutes things you could do in 8 minutes. So for example if you have to wait 7 minutes you have to wait 7 minutes for a big software like or if you have to wait for more than 15 minutes the uncle will tell you go chit chat with your friend or something like that. So this actually makes it more fun. I noticed that a lot of people actually really like this. A lot of people actually try to talk to the uncle as though he's a real human being. So sometimes they say so over here he's still got 10 minutes going at groceries. Some people say but I'm not near sanction. Or they say I don't need a discount for groceries. So a lot of people actually think of this as a human being. That's interesting. So for this talk I guess what I can show you is the process I went through to building bus stops. It's a very general view. It might get technical a bit later but I'll still keep it brief. So you need to build a pot. What do you need to do? Number one, learn machine learning. Number two, master your linguistics. All your English literature and stuff. Number three, practice all your data structures and algorithms. Well actually you don't need to do any of that. A lot of services out there have actually done all of this for you and it's really easy for you to actually build a pot. So the first rule of actually building a pot is doing it yourself. It depends on someone else. There's a lot of services out there. So to give you an idea of some of the services you'll have to use BusNumber actually uses machine learning as a service. So machine learning is based off of natural I mean apart from machine learning it's natural with processing. So one thing that BusNumber does is he reads whatever you tell him and he picks out like parts of it of important value and he sends it back to you in a very structured format. So it's something very well structured something very structured. So some of the machine learning services out there are with AI and some of the speakers later are also going to speak of some other machine learning services. These are the most popular ones I've searched for at least. There's also Lewis at AI by Microsoft but the slide didn't have its place. So with AI was one of the first ever machine learning services out there. It was made in 2014 but it got bought by Facebook. API at AI was made a little later and got bought by Google. So these guys know their shit. Another thing other than machine learning it has to do with to build at what? Because you need a messaging platform. So there's a lot of places where people send messages. They send messages to Facebook messenger or WhatsApp telegram with a Slack in your office. So there's a lot of different platforms out there and you just have to choose one. Just choose something and start being around it. But I'd say that if you want to choose a platform you actually got to do a little bit of research to see what it can do because each of the services that you have each of the messaging platforms you're going to use provide very different experiences and features as well. So other than messaging platform the final thing you need to have is a web server. So every chatbot is very simply with just a web server out there that's accepting requests from one of the messaging platforms. So some of the common web servers out here are Heroku AWS and Microsoft Azure. Just choose one and just make sure that you're able to deploy an app there. So this is just a general overview of the infrastructure of most spots. There's a lot of services that simplify this even further. They just make it like one human here and one walks here. A lot of services may be very simple but what I felt comfortable was going for three different kinds of platforms because I wanted to be able to customize some things about it. So bus uncle started out something like this. So on day one bus uncle is basically a Facebook messenger platform that linked to a Heroku web server. The Heroku web app was built on Node and Express. It's one of a bunch of web servers there's also Python, Ruby on Rails choose one. And the machine learning platform I used was with AI. So this is basically like building blocks. But another thing that bus uncle actually needed was information about bus stops, information about how long the arrival time is for every bus that goes to a bus stop. So I had to go scrounge in Google and find out if there's any kind of service out there that gives me information about bus arrival times. I found out that LTA Datamall existed. LTA Datamall is actually this web server in Singapore that gives you information about all bus stops all buses and how long every bus will take to arrive every bus stop at any point of time is exactly what you need. And it's surprisingly extremely easy to get access to. If you just go to the LTA Datamall website you just have to enter your email address to give you access to all public data information in Singapore. Very surprising considering the Singapore government. So this was on day one. And bus uncle actually went to quite an adventure because initially the bot was not meant for so many people to use. The bot was just an experiment made by me and I just wanted to give it to my colleagues and give it to my friends to play around with it. So this kind of infrastructure was good enough for it. Soon it got featured on my mothership.sg and when it got featured on mothership.sg that's when it went viral and the page itself got 8,000 likes over one night and so many requests that couldn't handle. So because of that it crashed so many times my web server actually crashed so much it almost crashed once every 20 minutes once every 30 minutes and a lot of people who tried to talk to bus uncle while it crashed didn't get any response so they were really disappointed I didn't want to disappoint people so I had to do something about it So over time I just kept plugging in more services more and more functionality more and more load balancing services I learned a lot of this stuff just through the process of just keeping bus uncle active and in day 30 bus uncle is something like this So it looks really complex but to give you an idea of what it is the user uses facebook messenger to talk to heroku web server and heroku web server actually has access to databases so I used two databases one is mongolab based in mongol db and redis cloud I used mongolab more for static information such as bus stops locations all this is static information bus stops won't change the location over one night so all this kind of static stuff I just put it in mongol db and then I used redis for storing the context of our conversations so when you talk to bus uncle the uncle has to remember what you said previously and what you said before that it has a brain of its own basically redis cloud stores the brain of what to remember that's this part LTA data mall is the service I used to get bus times I used google maps as well for two things one is to get a street view image of every bus stop in Singapore so if anyone searches for a bus stop but just by looking reading the name of the bus stop in the photo and it will show you a street view image of where it is I also used google maps for a backup of searching for location data so sometimes when you search for things like NTU LTA data mall gives you like zero results because there's no bus stop in NTU at all so when that happens it falls back to google maps and gives you bus stops near NTU and then I used red dot machine learning and finally Facebook analytics so Facebook actually introduced this very recently just about two and a half weeks ago started using it what it does is it traps events it traps the whole process of how people speak to bus uncle and gives me an idea of what people are doing more what people are doing less what people are doing wrong what type of data you can actually collect and Facebook analytics actually does that for me so now I actually have a really good idea of things people actually like bus uncle versus the things they don't like based on that I use the data to tell me about what features I can build next so it's very data driven and then in my Heroku web server it's based on node express so I'm a front end developer and a trigger for right now and I do JavaScript all day so I've become a little proficient in JavaScript and because of that the whole of bus uncle is based on JavaScript everything is in JavaScript so I use node express for the web server each thing JS is this library that I really love because that's the thing that actually helped me with the load balancing sometimes bus uncle can get you can get requests about 30 to 40 requests per second because 30 to 40 people are asking bus uncle when is my bus coming in one second this kind of stuff was this really difficult to manage but using JS helps me like balance the load and sends it to like separate threads basically it helps in balancing I use Mokla Chennai in Sinon for my testing framework testing is very important a lot of companies out there don't really care about testing they say as long as it works for you it's fine or as long as you go and try it out it's fine but this is not really a practice it's better to have a testing framework that runs automated tests for you so I Mokla Chennai in Sinon has done 40 tests right now and almost every time I release a new feature or release some kind of improvement I have to run through all the 40-50 tests if any of them fails I won't push it up because basically you don't want to ruin the experience of anyone and I use this service called New Relic to understand like understand application performance New Relic actually helps you determine the speed of how it goes from one function to another it measures how long it takes to call a service and response time it gives you information about the throughput which is how many requests are made to each service so New Relic actually told me that API was actually my most used web service here and then it's followed by Facebook it's followed by Google so api.ai one of the decisions I made was because with.ai was actually getting a lot of requests I thought to myself I'm kind of fully dependent of with.ai right now so I don't want to be fully dependent on that because if they go down so one of the decisions I made was I'm going to try to mimic the logic or mimic the functionality that and that's one of the features I built for Passanko so now there's once when with.ai went down for 10 minutes but Passanko was still alive so New Relic actually helped me with that and finally I used this service called Paper Trail it's just a log management system all the logs of every window on the aisle with Passanko is just posted there so if you're a developer you get every single trace of which line of code was run and yeah that's basically it so I hope that didn't make it most of your sleep hello I guess I mean I gave you an idea of how Passanko was and how it was built but a lot of you probably have a lot of resistance to try something new so I thought this might be a good opportunity to go to with.ai with you guys so that you guys can actually start building blocks with with.ai it's a very small demo so when you go to with.ai the first thing you need to do is create a new app let's just create an app called Bassanti Bassanti okay sure Bassanti you hear the description wife of Passanko wife of Bassanti and you can make it either open or private so when it's open it means that whatever app you're going to build it's going to be available to everyone like anyone can find it from Google or anyone can find it from the with.ai search just make it private for now and finally you can import your app from a backup, a previous app you can just create a new app so when you first log into with.ai you come to this screen here and in this screen you're asked to create a story so let's just create a story and now a story is basically what stories you do in Scrum, in the Scrum framework for example if you guys are not very familiar with Scrum to give you an idea of what a story is it's just a really major functionality you can give your users that is very independent on its own it's not dependent on other stories so let's give it a story and the story, in the story you actually have to start with give me an example of what a user says and we'll now put down the mic because I need both hands to tag any suggestions to start off? Hello so let's say Basanti tells you I mean a user asks Basanti where is Basanti what you're giving here is actually a place where you can add entities now what entities are are small pieces of very relevant information within the text that was entered so what I'm going to do is I'm going to highlight Basanti here and make it an entity so the entity would be called a person or something like that or there's no, okay so which gives you default set of entities but you can also create your own okay let's say Basanti is a content and now this is an entity but what also needs to know what process is going on with Basanti right now what I'm going to do is create this thing called intent and an intent is something that's a trigger so when a user says where is Basanti their intent is to find Basanti so I'm just going to create that and now when that's done you can say what executes and in what executes you can actually mention a function that you're going to run in your application that starts promising as soon as it finds this entity and this combination of this combination of entities so let's give it a function say go and find Basanti and then when that's done what it expects you to do is they expect you to update your context so I didn't mention but briefly before every chat actually has a single context and context basically is like the brain of the chat tells Basanti what was said previously and what was said before that so it gives you an idea like the brain so after it goes to go and find Basanti let's say it updates the context with location of bus and then so once that's done you can say once that's done you can say what sends this means the bot will reply and say bus uncle is at and you can use curly braces to pick out pieces of variables within your context so the context we updated was location of bus so you can just say location of bus so that's a very simple story and all you gotta do is fix it and now what with the AI does is you can see the loading part of that what's happening is it's training the bot this means it's actually telling the bot ok the user has specified these rules now just follow these rules now you can actually test out the app with this small little chat on the bottom right and you can test it out saying where is bus uncle so now what happens is which says ok I saw that you entered where is bus uncle I'm gonna run a function called find bus uncle and it gives you an option to update your context over here so let's say it updates the context with location of bus uncle then when you click on take the bot tells you bus uncle is an official bus uncle so other things that you can do with wit is there's a dapple understanding so a lot of people will be very differently but as humans we always almost can't figure out what they're trying to say bots on the other hand they won't know about all the different kinds of things people say so in understanding you can actually train your bot to understand different ways of how people might ask about certain things so let's say normally people say where is bus uncle another thing someone might say is find bus uncle for me so now what happens is quit is searching for entities and wit actually like identify that there are two contacts here one is uncle and one is me but we want to say that bus uncle is a person not just uncle so what we say is we close this thing it's not uncle then we highlight bus uncle and then add contact and now bus uncle also it identify me as a contact but this might not really be useful at this stage so you can just like delete that and then it's fine bus uncle and then when you click on validate you're kind of telling which LPR here's another set of rules and this will please use this as another example of how to run the same function so now when you go to your chat and you type in find bus uncle for me it does the same thing it identify like now I have to run this function called go and find bus uncle and then you click on location and there you go so wit actually helps I mean wit actually tries to figure out on its own about a lot of different ways that people might speak to you about some people might do the combination of course with input and the second way so another way people might ask for location is I cannot find bus uncle now so wit understood that based on some of the logic that we've given it it created its own logic kind of created its own way so this is what machine learning does it's when you don't have to tell what the program does but the program itself figures out the use of it so when I said that's not the location of bus uncle it was this single error most of the time when wit cannot understand something you also have to create a new function called error in your application and make that run in something so that the bot can still look like a user yeah so that's for example wit there's also this thing called actions you guys can go and figure out there's not a communication about this so yeah that's wit bus uncle that I learned a lot of people actually make a mistake of saying I'm gonna start building a bot but in order to build a bot I'm just learning machine learning and then they go to Stanford University and they take out machine learning and six months pass pass the course and they're back to square one now they know machine learning but they don't know what to do again so if you start it's all just work you're actually already starting with some code, some working code that someone had already built you just read through that and just start playing around with something that's one of the big most common things I do because I never start doing it myself even bus uncle I never start it myself I copy or some git repo and change it and then one interesting thing that I learned was make it work so this is still an opinionated thing some people might say bots shouldn't be human bots should tell you exactly what they can do they should tell you all the constraints of what they can do so that they can manage user expectation they give you all the options of inputs this is one way of designing it I wouldn't say that's wrong I mean a lot of bots do that out there but what I like to do is when you build a bot you're essentially building a human being so you're building someone that someone else can talk to so for me personally I think that giving a bot a personality is definitely that's one of the best things you can do and it was also proven to all like how much I got on Facebook basically well bus uncle is so real and for my human I mean this bus uncle is human I actually got a lot of questions from a lot of people saying are you human or not and bus uncle would just reply with half so yeah that's one interesting thing I guess the downside of making a bot human is you don't tell the users about the limitations of your bot so they might try conversing you on a whole set of levels they might so a lot of people ask bus uncle are you married are you your girlfriend are you married are you serious for years so bus uncle just keeps replying all the train things that he said so most of it is just but sometimes bus uncle just identifies are you married as go find bus location so when someone says are you married bus uncle says 3 minutes wait for your bus yeah so that was take away and give away so I actually need something for all of you who attended but I wanted to make it like a little fun like a little game so I actually put something into bus uncle just for this talk now if any of you actually go to bus uncle and then message him saying I want a badge or give me a badge bus uncle will actually tell you congratulations you have won a badge but then once the number of badges has run up the bus uncle will tell you no more badges already so if you guys just go and chat with bus uncle right now and say I want a badge give me a badge or anything to do with a badge bus uncle will just tell you about a badge and once you all got like a positive response in this comment chat after this I'll just give you a badge very nice so much so much and those who those who want a badge please go on to bus uncle right now and then grab the badge from our Lush at the end of this session because we're going to move on to our next exciting talk thank you so much