 ring doorbell probably but I don't own one. I have to build a candy dispenser. I have to automate the whole thing. There's some stuff in the middle and I'm rich from from this idea. And I will give you a little spoiler about what's coming because somebody actually did something very close to this in real life and it's it's hilarious. So here it is. This was a month ago and I was just getting ready to get up on stage at another conference and give a version of this talk and a guy sent me one of somebody in our user group actually sent me this that in order to enter this supermarket in Denmark you have to smile and as you walk up to it it takes your picture and it decides whether you're happy enough to come into the store. I'm like how brilliant is that, right? I took my idea I could have been rich but anyway so I've got to build all this stuff and I just happen to have all this hardware lying around, right? Motors and stepper drivers and if you follow me on Twitter which you're welcome to do you will notice that this would surprise absolutely no one that knows me. I have a cabinet next to my desk that weighs about 400 pounds and it's all full of tiny little electronic parts like just everywhere so I had all the stuff to do it. This is why when I was told you know hey do this project I'm like well I'm gonna do what I know which is IoT and somehow I'll make it work with BPMN. So start with hardware. Side note for anybody who's doing IoT never start with hardware I have a whole talk about that I'll give that another time but never start with hardware. This is another reason why 70% of IoT deployments fail. So I came up with a schematic and I built this thing and it was pretty spot-on with it and it's just an ESP32 camera board and a button and you push the button and it takes a picture and that's as complicated as that is. Some would say that's not even IoT and I might even agree with him. So I had to build a candy dispenser. Never built a candy dispenser before I'm gonna use a stepper motor and a little ESP8266 to run the stepper motor and then I built it and it came out exactly as my schematic I'm really happy when my hardware and my schematic come out the same. That's always a good day for me. So I'm terrible at 3D CAD if I had to design this thing by myself it would have taken me six months and it would have looked even worse than this and it looks pretty awkward anyway but it was a free design on the internet so I downloaded it made a few changes simple changes and I had my candy dispenser to give candy to kids. So now where's the BPMN and all this? I said I was gonna automate this with automation I could have done all this with just IoT where it takes the picture and it you know does the evaluation and it runs this thing right? But if I wanted to make any changes to that I would have to go in and alter the firmware on these things and alter the back-end software and all this kind of software engineering and I wanted to be able to do it with automation. So I built this long complicated process model and I'll show it to you larger but you can see it looks pretty complicated this is because I had no idea what I was doing. My friend Nile helped me with this because I literally had no idea what I was doing. It requires a lot of human interaction and it's really not very maintainable I learned this later but I did it anyway. So here we get to see it in action. We don't have any trick or treaters yet so for now you're just gonna have to see my dog get his picture taken and that kicks off a process in Kamunda and you can see the picture there so I'll claim that and there's the picture that was taken and so next thing I'll do since I can't use it as a clickable link is I'll open it up in its own tab. Oh look how cute he is in his head. The audio is a little off. He's wearing a costume so I'll complete that and now let's see I could go see it again but I don't really need to so I can claim it and I can rate his costume and that was a great costume so I'll complete that task and then next one that pops up is to estimate his age and I happen to know his age and he is under five years old so I'll complete that task and as you see he gets a bunch of treats. Bruno loved this. Rehearsal with Bruno was like the thing. I couldn't rehearse with my other dog because she's way too food motivated and she tried to eat the treat to Spencer. So the candy to Spencer I stole wasn't really designed for candy didn't really work with candy it worked with dog treats quite well so I used my dogs and they're useless I mean like that's a tip that's a that's a whole day for them so after being at the company for a while probably about six or eight months I decided that I could make this better I could make it more sort of best practices shall we say and I could take a lot of stuff out of it that was not in best practices some of the stuff was actually hard-coded into the business model in a script that's really hard to maintain right means that anytime anything changes I have to go make sure that that script still works in the model not great right so don't do it there was way too much human interaction I had to go through three forms to get candy out at the back end which meant that if it was actually Halloween I'd be sitting there all night just going through forms and going through forms and the kids would really get backed up and probably vandalize my house so I collapsed the whole thing into a single form and then I used the decision table to decide how much candy they got here's the really cool thing about this I didn't have to make any changes to any of the IOT hardware the doorbell or the treat dispenser any of that in order to change the model I made the model much shorter much more efficient and deployed the new model and the same hardware worked with it and that's what I'm talking about about automating the automation right I didn't have to go back and rework any of the other hardware any of the low-level programming I didn't have to change any code basically all I had to do is change the model redeploy the new model and run it and in a minute I'll go through a whole demo where you can see all of this working and how it works and how I changed it and how it continued to work people ask what's the no candy for you I did make it an executive decision that anybody that was over the age of 15 should probably have a job and buy their own candy so I'm not giving them any candy that's the only if you're not wearing a costume or you're not or you're over 15 no candy for you everything else is good to go so I'm actually using some nested DMN decision tables to do this I take the age and the costume rating and I determine how many we called them Skittles at the time how many Skittles they get based on I based on that and then we decide if it's a costume and if it is a costume then those Skittles will come out if they're not wearing a costume they got no Skittles now this was all stuff that I had hard-coded into the model previously in the first giant model I'd hard-coded that all in and so if I decided that I wanted to change how many pieces of candy somebody got based on their age I would have to go through the whole model and change it all in the model here I can just change it in the decision table so I did last iteration of this I decided I could automate the whole thing if I just moved the goalposts a little bit and the reason I have to move the goalposts a little bit is because I didn't have a trained AI model to recognize costumes or age of children so if anybody wants to build me that AI model for evaluating a picture for costume and age of children I'd be happy to use that so instead I built this much shorter task a picture comes in it's evaluated and we either dispense candy or no candy simple as that no human interaction I don't have to do anything all based on a single decision table well not really a single decision table turns out there's a bunch of decision tables I had to come up with a very secret and proprietary formula based on anger sorrow suspense and joy which is what Google image AI will give you back for a human picture to decide how many pieces of candy somebody gets so each one of those little boxes has its own formula in it for how much candy you get based on how angry you look how joyful you look all those sorts of things right and it all then feeds up into the larger table which puts it all together and dispenses candy to you so I'm using Google image processing and it's a short little go program all it does is submit the picture that it's given to Google AI and it gets back these things it gets the anger the joy the surprise and the sorrow as numbers that's really easy to deal with right I take those numbers I put them into the decision table and the amount of candy comes out the other side really easy so I've been talking and it all looks like it works but it doesn't actually work until I show you that it works so let's start with who's the other thing that happened in the since I did the very first version of this and actually since I did all three versions of it two months ago we announced a new product which is a cloud-based product I had been using our on-premise run-it-yourself software to do this all this came out in in our cloud product and so I decided well let's make it work with the cloud turns out it was a lot easier than I thought because some of the things that I had been doing like putting those scripts in line in the model you can't do with the cloud product so I was forced to not do things that I shouldn't have done anyway so good for me so this is actually live this is my cluster and if we look I have a couple of dashboards here so this is that last product process that I showed you right submit to Google AI evaluate the results dispense Skittles and you can see that stuff has been some processes have been stuck here for a long time probably because I didn't have the processes running to handle them so I can actually go through and I can see like how well is my model performing where do I need to make changes to make this work better right so before we do that you might recognize this big ugly model right big ugly model lots of human interaction so I can deploy that diagram here's the other cool thing about BPMN is it's not just a like a vizio model of here's what I want it to look like right it's actually executable so I can take that model that I've drawn out and I've put all the stuff in of how I want things to happen and I can deploy that model and the diagram is deployed and I can now start an instance of that process and I don't have the doorbell with me on my last trip overseas Delta saw fit to like crush my candy dispenser and some other stuff so I'm just doing it virtually virtually so I'm going to paste in a variable for the image location remember in that form I had the image location so this is an image location and we'll start an instance of that and I can go see that instance and I told you that the model was executable this is actually the model that I just deployed actually executing and you can see over here this little green spot that's where the token is so that's where the process currently is and it's waiting for me to evaluate the picture and indeed if I go to my task list I have one task which is to evaluate the picture and here's that we'll go to it just to evaluate the picture yep that's a picture I'm not wearing a costume I'm not a kid but you get the idea and so I can say yes it's wearing a costume complete the task and if we go back to here shortly we'll see that token move there it is it's adding candy but it's waiting for a process to handle that and I just happened to have one of those so I'll start that process up and all it's going to do is look for processes that have that name and do what it tells them which is add those two numbers together and you can see it was told to add one because I'm wearing a costume so I get one piece of candy and complete the job go back over here and yep sure enough the job got completed and we'll evaluate the costume I'm not going to go through this whole model because it takes a while to go back and forth and back and forth and back and forth of evaluating the picture and submitting it I mean I could have short circuited it at the first one by saying I wasn't wearing a costume and it would have said no costume no candy for you and we're done but we'll just leave that alone and we'll go look at the second version new picture comes in a person evaluates the picture and then decisions are made and candy is dispensed so we'll deploy that we'll start an instance of that again we'll give it the same picture because we don't have the doorbell to take a picture all I'm doing is giving it a variable with with the location of the picture and we can go and look at that and we can see that the tokens here if we go to our task list we have this and look I combined it all into one form so yes they're wearing a picture they're wearing a costume it's a terrible costume I mean is that even really a costume we'll say that they're under 15 but just barely and we'll submit that and if we go back over to our operate instance it's already waiting to dispense candy so it's made its decision and I can see down here that I said they were a tween they had one piece of candy coming in and yeah they're wearing a costume and their rating is bad I'm rating myself as a terrible costume because we also picture really so and all I need to do now to complete this is start the worker that will dispense the candy oh wrong one and there you go dispensing candy pieces it gave out one piece of candy yay we got the answer right and over here we'll see that the tokens now gray it's at the end we successfully completed the entire process and we gave out one piece of candy not so interesting it's when we get to being able to fully automate it right and again I'm not changing any of the code that was running on the devices I didn't have to change any of that code I'm just changing the business model right so if a business is deploying an IOT solution they don't have to pull the embedded programmers in every time they want to change right as long as the devices work we can change the business model above it however we want deploy the new business model and those devices will keep working and we can get the new information one of the examples I use for this and I actually built this later on is a greenhouse let's say I'm managing a greenhouse and I've got temperature sensors and CO2 sensors and humidity sensors and all this kind of stuff deployed in my greenhouse and I'm growing a crop that requires those values to be in a certain range for this crop right great I can do that build a model that makes sure that that's all you know that opens the windows and turns on the fans and does all these sorts of things to keep the temperature and the humidity right let's say next season I change crops and all those values need to change I can simply go into my business model change those values in the business model redeploy the model and now I can grow a different crop I didn't have to go and change touch any of the hardware that's distributed through however many greenhouses happen to be running so let's do one last version of this and this is the fully automated version a new picture comes in it's submitted to Google AI we evaluate the results and we either dispense candy or we don't I don't have to go fill out a form I really can do Halloween now from anywhere I'll just put this on my front porch and you know go to Portugal and this whole thing can run and kids ring the doorbell and they'll get candy and I never have to even be there right so we'll deploy this diagram we'll start an instance again we'll give it the same picture we know what that picture looks like I need the jeopardy theme song to play here oh there it went basically before I could load the diagram it got the results back from Google it evaluated the results and it dispense the candy and if I look down here I could see that I got 28 pieces of candy because I was not angry and I was joyful lots of candy right and again it was that fast and I can go back to the process here and I can see yep it dispensed 28 pieces of candy so I've now changed that model from rudimentary I know nothing about BPM and I know nothing about commando so I made this really complicated process that took a lot of human interaction to make this all work to a process that I don't even have to be in the same time zone with and it will automatically do everything and I never changed any of the underlying code you saw that I'm still right I'm running the whole thing in software instead of hardware but I didn't go and change any of this code right I just started up the process as I leave them running and they pick up the jobs as they come in and they handle everything and the whole thing runs smoothly and I don't have to make any changes at all to my business model if I want to change how many pieces of candy I give out I can go back into my modeler and I can look at my decision tables you saw this before on my slides and I'm going to reveal to you some of my proprietary formula if you're angry we're going to multiply it by five because if you're angry you probably need candy right I could have not given angry people any candy at all but I figured that would just make them more angry and that was that was not at my best interest and here we'll see why I got 28 pieces this is a really complicated formula I take that number I divide it by four and I multiply it by 20 and all made up entirely made up because I didn't have anything else to base it on and again the big table all it does is add all those together and spit out the final number and the candy dispenser sends out candy I can even build a better candy maker that actually dispenses candy instead of dog treats because that wouldn't go over so well at Halloween right without changing any of my model so I've in essence I've disassociated this whole thing from I'm sorry I've disassociated the hardware functionality from what's actually happening in the in the business part of this deployment so the business people can make the decisions about what they want out of this hardware deployment while the hardware people we have to have them come in and write all this embedded code and get it all deployed and working but we don't have to do that once I don't have to call them back in just because I want to change how many pieces of candy somebody gets right or how the doorbell reacts I can do all of that in this higher level model I almost always end my talks this way not with this same quote but that's from my mom so if you're wondering why I'm so weird that's my mom I grew up like that my mom was actually a computer scientist and has a whole raft of these sayings that she used to say all the time about computers and so I've sort of started tagging them on to the end of my talks just for fun questions anybody I'm done way early so I have lots of time for questions now I was that clear how do I test how did I test the model well so I had an easier time because I had first deployed it on commando platform seven right and then I deployed it I basically just altered the models to fit the new patterns on come into platform eight on our on our cloud service I'm probably not the best person to ask because I'm one of these people that write software and compiles it and if it you know and then I find out where it doesn't compile and I go fix that right and then I run it and I see where it crashes and then I go fix that and I do this with embedded software and I do this all the time it's not best practices for software development I've started doing test first you know development lately and it's made things a lot easier but for a lot of my models they're they're fairly simple and all I have to do with that so for instance if we look at this model there really wasn't a whole lot to test here because this activity here all it's going to do is say I'm going to put a put a job out there that says do picture AI and I'm just going to wait until some process comes along and picks up that job and handles it so that's really all I had to do in the model to make sure that that part of it worked the hard part was writing the go code to actually do the the AI and return the return the variables once I had that all I had to do was turn on the part in the go code to listen for the do picture AI job and execute that right and that was even pretty simple I defined the process name that I'm looking for as do picture AI and we have an officially supported go library for commando so I imported those zb libraries for go I have a couple of data structures one for the AI return model and one for there's my emotions and here's the information that I'm going to get from commando so I can actually start the process knowing that it's a picture by giving it the is picture variable as true and it'll understand that and then it won't have to decide whether or not it's a picture and I just start a new zb client as part of the library start a new zb client it connects to my cluster with my credentials and my secret and all of that and then it just starts to listen and it listens for any job called do picture AI and it will sit there and listen forever so I can start that on either my laptop which I'm running it on now but that's not really fault tolerant but I can run it on a server somewhere and it will listen for that forever and anytime any job comes in says do picture AI from the cloud it'll execute that and all it will do is get the variables and it'll do AI on the picture fill out the data structure complete the job and send back to variables that I got so as I said the the testing on this one at least was very straightforward because it didn't really do much right testing on the on the dmn table we do have an online dmn tester I'm not sure that we've updated it for the commando platform 8 yet but again this was a straight move over of a table so I used the online tester to make sure that I could give it the right numbers and it gave me the right answer out the back side and then I could just deploy that table and I deployed that table as part of the model so now I can either change the table and redeploy the table and the existing model that's running will use the new table or I can change the model and deploy it and it'll continue using the same decision table that I gave it before and I get my answers yes right so here's the thing the the only way I'd have the only place I'd have to make a change to differentiate that would be in the actual candy dispenser right because every time a picture comes in it starts an instance of this model right of this process model and runs that so it doesn't necessarily talk to other instances of that and I just have to make sure that the only change I'd have to make is making a change to the I'm using MQTT right so all I'd have to do is make a change to the name of the MQTT broker so it knew which candy dispenser to go to and then it would would give that out and I would probably do that I'd probably have to make a change in the in the actual code to have it listen for you know just the right if I'm deploying multiple candy dispensers I'd have them listen for a certain topic to do that to listen to their topic and then I wouldn't have to change the model it would just submit the the I'd probably use the the job ID or the or you know the dispenser name that's associated with the doorbell and it would get the right right answer and give it to the right dispenser and again I I would have to change my MQTT code to make sure it's listening for the right thing but other than that I wouldn't have to change my any other hardware any doorbell would would work you know other questions yes great question in fact and I was having error conditions earlier today when I was testing the demo to make sure that it worked because I hate when my demos don't work and if it comes up with an error condition the the I would see in my running instance an error condition thrown and I could then go click on that and look and see what that error condition was and in fact if I go to I don't know if I have any I don't but it will show you the error condition and you can click on the error condition it'll tell you exactly what happened right you called this process and it needed this variable and you didn't have that variable I messed up right and you can then go add that variable where it needs to be and it'll and and restart it and it'll continue and I believe that I am now out of time if you have other questions email my github my website and down at the bottom david gs iot is my twitter handle feel free to follow me for other stupid iot tricks that I do and ask questions whatever you need thank you