Build

Cool Hacks with PubNub and IBM Watson APIs

4 min read PubNub Staff on Feb 20, 2018
Try PubNub Today

Free up to 1MM monthly messages. No credit card required.

Subscribe to our newsletter

By submitting this form, you are agreeing to our Terms and Conditions and Privacy Policy.

A collection of awesome tutorials using a number of IBM Watson APIs combined with PubNub Functions, including home automation, language translation, and more.

IBM Watson has a neat selection of APIs for adding language, speech, sentiment analysis, and insight capabilities into mobile and web apps. Since launching PubNub 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 PubNub 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 PubNub 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/4 second.

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 PubNub Functions. For more inspiration, you can check out our Watson expert Shyam Purkayastha’s extensive library of tutorials over of the IBM blog.

More from PubNub

Top Trends to Engage Your App Users
InsightsSep 27, 20224 min read

Top Trends to Engage Your App Users

Take a look at the top trends that are the most effective in attracting customers and reducing churn, and how you can incorporate...

PubNub Staff

PubNub Staff

Comparing Game Engines: Unity vs Unreal vs the Rest
Real-Time Gaming BlogSep 21, 20225 min read

Comparing Game Engines: Unity vs Unreal vs the Rest

Comparing the major game engines: Unity vs Unreal Engine vs Corona SDK vs GameMaker Studio, including the benefits and cons of...

PubNub Staff

PubNub Staff

Python Socket Programming: Client, Server and Peer Libraries
BuildSep 21, 20226 min read

Python Socket Programming: Client, Server and Peer Libraries

Sockets (aka socket programming) enable programs to send and receive data, bi-directionally, at any given moment. This tutorial...

PubNub Staff

PubNub Staff