Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

A Watson-Powered Language Translator Slackbot

DZone's Guide to

A Watson-Powered Language Translator Slackbot

With Watson and Slack's powers combined, you can put the power of real-time translation and conversation into the hands of eager learners.

· IoT Zone
Free Resource

Have you ever got lost in a new city not knowing the language? Ever gotten stuck on your French/Spanish classes/homework? This simple Slackbot powered by Watson Conversation and Language Translation translates a language and helps you understand them faster and better by conversing.

It is a simple Slackbot that can translate from English to French, French to English, and Spanish to English (more translations are possible since Watson Language Translator supports Arabic, French, Spanish, and Portuguese). The Slackbot identifies the intent of a natural language input through Watson Conversation and responds with the translated language. This use case can be further extended and applied to different segments.

To build this app, you have to first set up the app in Bluemix, then configure Watson Conversation, Slack, Node-RED, and then test it in the Slack channel.

Watson Conversation allows you to quickly build, test, and deploy a bot or virtual agent across mobile devices, messaging platforms like Slack or even on a physical robot. Conversation has a visual dialog builder to help you create natural conversations between your apps and users, without any coding experience required.

Language Translator translates text from one language to another. The service offers multiple domain-specific models that you can customize based on your unique terminology and language. Use Language Translator to take news from across the globe and present it in your language, communicate with your customers in their own language, and more.

Setting Up Your App on Bluemix

Select Node-RED Starter from the Boilerplates section:

Image title

Enter your app name and create the service:

Image title

Bind the Conversation and Language Translator services to the Node-RED app:

Image titleImage title

Configure Watson Conversation

Click on the Watson Conversation service and click on the Launch Tool button.

Image title

In workspaces, click on the upload icon to import workspace (next to the Create button):

Image title


Choose file conversation_workspace.json from here and click on Import Everything. And after choosing the file, click on Import.

Image title

Configure Slack

Create a New Team in Slack

  • Create a new team in Slack by entering your Email ID.
  • Enter the 6-digit confirmation code that you receive.
  • Create a new username and password.
  • Enter the details about your team and company name.
  • Choose the address you’ll use to sign into Slack (the address has to be unique) and click on CREATE TEAM.
  • Review and agree to the Terms and Conditions.
  • If required, send invitations to your friends or skip it for now.

Your team is set up! You can enter your team with the address you have set. For example: nutritionistgroup.slack.com

Configure Your Bot in Slack

Go to your team on the left side, then click as shown below. In the dropdown menu, click on Apps & Integrations.

Click Build on the right side:

Image title

And then click on Start Building. You will be prompted to create an app. Once you create the app, create a bot, then Install that app to your team.

Image title

After that, go to OAuth & Permissions and then note the Bot User OAuth Access Token, which will be used in later steps.

Image title


Now, Configure Node-RED

Copy the nodes from here into the NODE-RED flow editor. In the Slack Listen node, enter the Slack Bot Token and update it:

Image title

Image title

In the Slack Reply node, enter the Slack Bot token and update it.

Image title

Image title

Note: If the Slack Listen and Slack Reply nodes aren’t available, go to Manage Palette in the Node-RED menu and click on the Install tab to install Slack nodes.

Image title

Image title

Enter your conversation Workspace ID ( Shown in the Conversation tool in Bluemix->Workspace->View Details):

Image title


Click Deploy (top right side) in Node-RED.

Image title

Go to the Slack team (For eg: languagetranslator.slack.com). Open the @translator bot and type Translate Merci Beacoup (Format to ask translation: Translate <query>)

You can see the response now!

Topics:
ibm watson ,ibm bluemix ,slack bot ,iot ,node-red ,translation ,tutorial

Published at DZone with permission of Riya Roy. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}