October was a great month at work :-)
The DMN editor (the tool I’ve been working in last weeks) was released as a tech preview in the Business Central, and I could write an exciting blog post presenting its features to the community. You can read more about it here 🤓
With the new editor, users can create their DMN diagrams and make them available as a REST service. There are many complex and challenging use cases for this new feature, but I’m going to demonstrate an easy and fun one here.
Great! In summary, our bot receives the value of an expense, classifies it, stores, and finally, he answers “Ok, fine!”. No more than that.
Today, we’re going to make our dummy bot smarter. We want to ask:
- Is a good idea to buy a Nintendo Switch?
..and get something like this as an answer:
- Hmmm… Yes, you can! You have the budget for this.
Impressive, right? Ok, let’s do this in three simple steps.
1) Setup the environment
The first step is to enable the DMN editor, as it’s available as a tech preview and hidden by default. Just go to
Settings -> Roles, select the role you’re logged in (for example, “admin”) and remove the “DMN Designer” exception in the “Permissions” section.
Now that you have the DMN Editor enabled, let’s create a new project: Go to “Projects”, click on “Add asset” and then open the “DMN Preview”. Here you can explore the editor and create your DMN file.
You can check more details about this step here, but if you can see the following screen, you’re fine :-)
2) The Brain 🧠
We have four input nodes (
Expense Value) and two decision nodes (
Is special month? and
Message). The input nodes represent the variables provided by us in the REST service request. This data is used by the decision nodes to produce an output.
Notice that the default output is false, but when the
Current Month is
"December" the produced output is
true. I’ve added a short description to each rule, but this is optional ;-)
With that node and its simple DT, our bot can discover if I’m in a festive month (when I generally expend more money). But now let’s take a look at the significant node, the
Message, which is responsible for the message that our bot says.
Notice what rule 5 says: “When the balance is more or equals to 500, we’re in a special month, doesn’t a matter what week of the month we are, and the value of the expense is less than 500”, and considering these conditions, our bot says: “Generally, I would say ‘yes’, but I think you’re going to have other important expenses this month”.
It’s pretty impressive the huge amount of complex scenarios we can represent using Decision Tables, isn’t? 😃
3) Calling the DMN model from Ruby
Finally, go to
Projects -> Your project and click on “Deploy” to deploy our DMN model in a KIE Server.
Calling our model is pretty straightforward, see an example in Ruby:
The End 🤖
Probably you already have an idea about how to integrate the script above with the bot we coded together in the last bot. So, I won’t spoiler you. I’m sure you’ll have some fun implementing it ;-)
I hope you enjoyed reading this, and remember…
Have fun :-)