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:
Enter your app name and create the service:
Bind the Conversation and Language Translator services to the Node-RED app:
Configure Watson Conversation
Click on the Watson Conversation service and click on the Launch Tool button.
In workspaces, click on the upload icon to import workspace (next to the Create button):
Choose file conversation_workspace.json from here and click on Import Everything. And after choosing the file, click on Import.
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:
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.
After that, go to OAuth & Permissions and then note the Bot User OAuth Access Token, which will be used in later steps.
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:
In the Slack Reply node, enter the Slack Bot token and update it.
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.
Enter your conversation Workspace ID ( Shown in the Conversation tool in Bluemix->Workspace->View Details):
Click Deploy (top right side) in Node-RED.
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!