Build

Cool Hacks with PubNub and IBM Watson APIs

4 min read Michael Carroll on Feb 20, 2018

IBM Watson has a neat selection of APIs for adding language, speech, sentiment analysis, and insight capabilities into mobile and web apps. Since launching Functions, we’ve been growing a collection of pre-built functions, the PubNub BLOCKS Catalog, that integrate with various 3rd party APIs. The IBM Watson blocks are some of the most popular in our catalog, so here’s a summary of some of the cool things you can do with Watson APIs for social/chat applications and IoT apps you’re building with PubNub.

A quick note on Functions. With Functions, you can inject code into the PubNub Network that gets triggered as messages flow through the system. Effectively, each Function becomes a low-latency microservice within PubNub and, among other things, can efficiently call external APIs to enrich messages, support chatbots, add ML/AI on the stream of messages, and much more. Here’s a list of IBM Watson APIs that can be triggered from a Function useful for social/chat apps and device control/IoT apps:

For teams building next-generation collaboration and chat apps, these IBM Watson APIs are useful tools to enrich the end-user functionality. Over the last year we’ve created a tutorials that highlight what you can do.

Building a Home Automation Virtual Agent

Our first featured tutorial shows you how to build a voice-controlled home automation app, allowing a user to control smart devices in the home with their voice from anywhere. The user simply speaks a command into their phone, the IBM Watson Conversation block parses and understands the command, and triggers an action (like turning on or off a light). All this happens in a 1/10 second or less.

Ibm watson conversation

From the above diagram, you’ll see how it all works.

  • Receives messages from the human user.
  • Translates the message with the help of IBM Watson Conversation API, and breaks them down into command (intent) and device (entity).
  • Sends commands to the respective device.

And here it is in-action:

M2-1

Multilingual, Language Translator Chat App

Our next tutorial utilizes the Watson Language Translator block and shows you how to build a language translator app that translates one language to another directly in the chat application. Simply set the language on either side and watch as the chat app automatically translates messages. With over 11 supported languages and real-time speed, your app just became multilingual.

It’ll look like this:

Translation in Action

Analyze User Sentiment and Context

Sentiment analysis saves businesses a ton of time and resources. With the IBM Watson BLOCK for Sentiment and Context Analysis, you can analyze every single message that comes through your system, gauge the sentiment of the message, and apply a score to it. In our sentiment analysis tutorial, we’ll show you how to build an app to analyze text inputs and rate the emotion of the message on a scale of 1-100 and grouped as positive, negative, or neutral.

In the end, we have something that looks like this:

Watson Sentiment Analysis in Action

Text-to-Speech

Our last tutorial seamlessly converts text to natural-sounding speech to build a speech-enabled bot. In this case, our bot analyzes a firehose of data and will speak whenever it senses a finding based on a predetermined threshold. So, when say, a stock price eclipses a certain price, the bot will let you know.

Trade Bot Arch

In the end, we have something that looks (and sounds!) like this:

We hope you enjoy all the cool things you can do when you combine IBM Watson’s awesome cognitive APIs with Functions. For more inspiration, you can check out our Watson expert Shyam Purkayastha’s extensive library of tutorials over of the IBM blog.

0