Adaptive Cards 101

While dabbling with MS (Microsoft) Teams Chat, I realise adaptive cards are being using for their bot framework. That will explain why “\n” or CRLF is not working on its chat display. So, if you are working with MS Teams bot. You will need to look into adaptive cards UI. Now, there is another new UI framework to have fun!

Why Adaptive Cards

It seems adaptive cards will be used for the MS Teams as the standard for card object. Adaptive cards are JSON serialised object model. This model describes text with images similar like your name cards. Developers can send content in these cards in JSON format. This will mean you can use code with Adaptive card format in ODA (Oracle Digital Assistant) bot framework. The content will be rendered in the look and feel of the host applications like MS Teams. This sounds cool, right?

Designing Adaptive Cards

Adaptive cards will be in JSON format. There is a designer portal which allows you to preview the JSON codes and format. It may take you a while to familiarise with the adaptive cards because it is mainly properties and configuration. You will need a lot of trial and error to render the adaptive cards properly.

Adaptive card is a MS driven approach for target system to share cards into MS products with a better UI. In a way, this provide a richer feel for just pure text in Chatbot. This will also give you a reason to invest in Teams bot framework.

Advertisement

Chatbot Channel

Chatbot can be challenging for the different channel unless you are going for full text display. Channels are chat application like WhatsApp, Teams, WeChat, Telegram or LINE, Users are so used to text formatting and GUI that they are spoilt for these display. Chatbot channel is like the days of SMS where you can only display limited important text is a straight line.

Chatbot Channel Consideration

If your Chatbot is going to be suitable for different channel, you will need to consider a universal full text or code for different channel. What will be your choice? There are so many types of channel or chat applications around. How should you choose and select the right channel to focus on? These are some quick tips to help you make your choice.

  • User Base Location – different countries adopt chat application locally eg WeChat in China.
  • Ease of Customisation – Telegram is customised friendly and popular with developers.
  • Cost – Some chat application like WhatsApp needs a paid business account.
Channel Testing

The major efforts of Chatbot Channel development is actually spend on testing. There will be a lot of trial and error as you attempt to develop a single view for different channel. What looks great on emulator will differs in laptop and mobile? You will need a lot of time to tweak spacings for each channels on different devices.

Welcome to Chatbot development! Be patience and happy testing.

Node.js 101

Node.js is a JavaScript backend for service side scripting. If you are familiar with JavaScript, it is a client side scripting. Basically, you can imagine Node.js as JavaScript for server. That is really interesting as you can JavaScript client and server side.

var http = require(‘http’);

http.createServer(function (req, res) {

res.writeHead(200, {‘Content-Type’: ‘text/plain’});

res.end(‘Hello World!’);

}).listen(8080);

w3schools
Starting NodeJs

Usually, I will Hello World as my starting point. Although it is quite simple, it took me a while to get used to Node.js. This is because I am very used to JS as a client side scripting language. You will also need to run npm (node package manager) for some of the JS library. In terms of syntax, there are many similarities between Node.js and PHP. Of course, the best part is the reuse of JS on server side.

ODA Node.js SDK

One reason for playing Node.js was testing of Oracle Digital Assistant (ODA) Node.js SDK. It was required in the integration of ODA to another channel like Telegram. ODA also use Node.js as its custom component. To utilise this SDK, you end up having to learn Node.js and npm. On how to setup, that will be another post.

Node.js is a lightweight container type of scripting language. It can exist by its own package. Perhaps this is why it was used as custom component for ODA. However, it creates the need for this skillset for maintainability of ODA.

Why RPA is Useless?

There are too many clicks for this software feature. You could use RPA.

A business user

RPA (Robotics Process Automation) have been steadily gaining popularity recently. Supposedly, it become a quick fix for underlying issues like too many clicks. In contrast, I find that this is a big step back from many improvements such as BPR (Business Process Re-engineering), UI/UX and Rules Automation.

RPA for the Wrong Reason
  • Too many clicks spoil the system feature.
  • Developers creates many linking UI for relational data.
  • The product feature cannot be changed.
  • The user wants to use Excel for their data inputs.
What should have been Done
  • Change of business process to streamline data updates.
  • Redesign of UI/UX or usage of Chatbots
  • Consider usage of NoSQL database for complex business scenarios.
  • Evaluate products with support of API and customised plugins
  • If users insist comparing data inputs with Excel as data inputs, it is time for some serious change management!

The repackage of scripting and automated testing in the guise of RPA is truly a marketing genius! It is no wonder that many have fallen to the this gimmick. It is worth to considering fundamental concepts to solve root cause instead of using RPA to automate the issue.

Oracle ODA and Apache FreeMarker

This is part 3 of my foray into Oracle ODA (Oracle Digital Assistant). After the intro in slaying ODA pizzaBot and then subduing Composite Bag, I managed to reach into a new uncharted water called Apache FreeMarker. ODA uses FreeMarker to display, evaluate or format the variables and entities.

Ok, so we are getting you a ${pizza.value.PizzaSize?lower_case} ${pizza.value.PizzaTopping?capitalize} pizza.

Oracle
Biggest Challenge in FreeMarker

Handling missing values is the biggest challenge for me! I literally tear my hair trying to figure out how to handle missing or null values. Needless to sad, Oracle ODA documentation is not helpful and I have to refer to Apache FreeMarker documents. Many scripting languages allows you to display the variables even they do not exist. Unfortunately, FreeMarker is more strict and helpfully dedicate an entire section. Like all coding documents, help is cryptic. It takes a lot of trial and error to figure out where it goes wrong with its critical ! and (( )).

Default value and Formatting

FreeMarker have a funny way to evaluate default values. It is easy for simple variables in ODA or you are not formatting the variables. However, things gets very tricky when you are using composite bag with formatting. Below are some cheats for you to figure out the correct syntax.

${pizza!’Not Set’} – Simple variable with no formatting and default value after !.

${(pizza.value.PizzaSize)!’Not Set’} – Composite Bag with no formatting with ( ) to encapsulate the (composite bag variable)

${((pizza.value.PizzaSize)!’Not Set’)?upper_case}} – Composite Bag with formatting with ( ) to (encapsulate the variable and default value) and another ( ) to encapsulate (both values for formatting).

Hope these tips will save you a lot of time in formatting with FreeMarker in ODA. Just in case you are wondering, validation do not flag FreeMarket expressions. You only get the error when you test the skill. Below is a standard error shown due to above.

error is: freemarker.core.InvalidReferenceException: The following has evaluated to null or missing: ==> eReadyPickUpDateTime.value [in template “FlowTemplate” at line 1, column 324] —- Tip: It’s the step after the last dot that caused this error, not those before it. —- Tip: If the failing expression is known to legally refer to something that’s sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use when-presentwhen-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??

Oracle ODA Composite Bag

After pulling my hair in Oracle ODA intro, I strive onwards and continue my foray into the deep pit of ODA (Oracle Digital Assistant). Today is my first attempt to try out the ODA entities. There are variables in ODA that are described as Entities like real world data format. In this module, there is a cool feature called Composite Bag.

Source: Oracle

Composite Bag allows you to fill in variables grouped in a “bag”. There is also a neat feature to let you auto resolve entities via the chatbot. It really sounds very cool but getting it to work is harder than I thought.

For example, a composite bag for a pizza might include entities for type, size, crust, and extra toppings. If a user enters “I’d like a large pepperoni pizza with a gluten-free crust”, the skill could extract “large”, “pepperoni”, and “gluten-free” from that input and not need to prompt the user for those values individually.

Oracle

As this is a new concept to me, the sequence, flow and placement of the code is important. It takes me a while to reference the pizza template repeatedly and changing the variable to what you have. In the end, I manage to get the auto prompt working! Code wise, it is much elegant than my individual variables.

However, I hit issue to display the bag details. Grrr. I must retry pizza example to analyse how to display Composite Bag details. Another side note is that I have yet to test composite bag for REST or integration. That will be another battle!

Not sure if Oracle heard me, please include auto complete in the syntax and flag the flow error for YAML!

Oracle ODA Chatbot Development Intro

My latest “hobby” is playing with Oracle Digital Assistant (ODA) Chatbot. However, this is taking me longer than usual to get used to it. I will think that ODA is a simple configuration of ask and response. Sadly, it is still very code driven. Today is my nearly 3/4 of immersion day struggling and dedicated to master ODA.

Source: Oracle ODA
More Templates Please

I will love to have more templates to quick start my Chatbot beside ordering PizzaBot. By now, I am getting sick of looking at Pizza. Templates alway speed up development as we just need to change certain variables and tweak the flow. Oracle Help is not really very helpful too.

YAML flow error

Anyone playing with JS, NodeJs or PHP will be always expert in syntax troubleshooting? Seriously, I enjoy this loose coding too. For one moment, I and baffled by YAML flow error. YAML is suppose to be a human readable language. However, the error flagged is magician level. Guess what, the error is due to a missing close quote “. Level up!

Takeaway from Intro

In a way, it is a new paradigm way in trying code for a natural language. Somehow, I feel that the ODA environment is still seated in the old development model. I will prefer more drag and drop instead of mastering the syntax. It is definitely not for business or layman to configure. There is a sense of achievement to create the chat. I will get used with more days of development.

Chatbot is the New UI

User Interface (UI) has always been a hot topic to simplify usage for system. Recent cloud technologies have evolve UI to a next level which is not seen in the past. We are now able to use machine learning to recognise natural language for Chatbot. How will Chatbot change our paradigm towards software development? Let us break Chatbot into basic components for easier understanding.

Machine Learning

Machine Learning (ML) have materialised AI (Artificial Intelligence) in action response logic in systems. This makes perfect sense to introduce machine learning framework into systems to handle predictable events with users.

Natural Language Processing

System response have been constrained by standard system logic processing. Natural Language Processing (NLP) gain a lot of breakthroughs with the addition of machine language framework with speech and voice recognition and natural language understanding.

Chatbot

The RE introduction of Chatbot is due to the advances made on the two fundamental concepts of Machine Learning and Natural Language Processing in its ability to replace the UI. Users can really interact with minimum switch cost, decrease training time and high stickiness for superior Chatbot.

In 2021, we should expect to see a fierce battle of Chatbot in the future Cloud space due to COVID-19 pandemic and the need to distance and remote work from home. Do watch for more updates and review about Chatbot technologies.