Moni.ai Enabling My Chat bot
Hickmat 100000QA3T Comments (2) Visits (9572)
Early last week I was browsing the Bluemix services catalog to see if there was anything new I could tinker with and I came across Moni.ai. After a quick review of the docs and a watch of the YouTube video I decided to have a shot at adding it as another channel for my Watson powered Chat bot (to compliment Facebook and Telegram).
I started by creating and instance of the Voice Channel Designer app. Once I had this up and running I could see that it was basically a NodeRED instance with the following package added to package.json
Adding this has the result of adding the following nodes to the NodeRED instance:
Armed with this information I updated the package.json in my NodeRED instance which was already hosting my "Chat Bot Broker" and the interfaces to "Facebook" and "Telegram". With this done and the NodeRED instance re-cycled I set about creating a flow to handle the interaction with Moni.ai.
My first step was to register an account on Moni.ai so I could use the nodes, and once that was in place I created the following handler flow (based on my Telegram handler).
If you've read my other blog posts you can see that I've linked in to my "Chat Bot Broker" via MQLight so all the integration with Watson and the session management was covered by that. I set the Moni.ai listener up so it register a tiger phase of "Hi Bramble" and I hoped it didn't decide to ignore me in the same way as my cat "Bramble" does. Once an inbound connection is established via a call though the Moni.ai listener node I stashed the msg object in a global as I was going to need it to pass information back to the Moni client. I also then make a call to the chat broker to set up a session with Watson and store all the necessary details in the WSX held cache. With both the Moni.ai and Watson sessions set up I could the simply loop around calling the Mona.ia "Ask" node to return the responses from Watson and ask for input from the user. This all worked very well but I had a couple of things to resolve...
In the case of 1) I couldn't find any option other than sending back a single message so I had to resort to aggregating multiple message responses in to a single response to Moni.ai - not really a major hassle but I do like to be able to send back separate blocks for readability.
As for 2) that took a bit more experimentation. I found that I could send a link back via the Moni.ai Ask node by passing it in msg.payload.link but it took me a while to get the format right. Here are somethings I discovered:
With this all in place everything worked and I could hold similar chats via Moni.ai as I can via Telegram and Facebook. So yes it works but there are some things I need to iron out, not least the nasty hack of storing the Moni.ai session as a global.
Anyway job done for now, hope this is some use to you.