Skill Level: Any Skill Level

In this recipe you will see how to build a multilingual solution using some Node-RED components connected to a Slack channel. People in the room will write using own language and solution will identify language and translate everything to EN-US.


Some assumptions for this recipe:

- you have an IBM Bluemix Account;
- you have a Slack Account;
- you created a Slack channel and invited a Bot (Bots);
- you have the Bot integration code.


  1. Create a Bluemix new Node-Red Application

    • Log in to the bluemix using your IBMid (on my case URL is https://console.bluemix.net);
    • Go to Catalog;
    • Go to Apps and Boilerplates;
    • Find and click on the Node-Red started;
    • Put an App name;
    • Optionally put another Host name for the App (default will be set as your App name);
    • Click Create (** you can keep all other options as default **).
  2. Create Required Bluemix Service

    • Go back to Catalog;
    • Go to Services and Watson;
    • Find and click on the Language Translator;
    • Optionally change Service Name and Credential Name;
    • Click Create.
  3. Connect Bluemix Service to Bluemix Application

    • Go to your Bluemix initial Dashboard;
    • Click on your Language Translator Service;
    • Go to Connections;
    • Click on Create Connection;
    • Click on your previews created Node-Red Application (Step 1);
    • Click on Connect button;
    • Click on Service Credentials.
  4. Create Node-Red flow

    • Go to your Bluemix initial Dashboard;
    • Click on the created Node-Red application Route (it is a external URL);
    • Click on the Node-Red flow editor link (answer all the questions and click next);
    • On the filter nodes box, type nodes described below and add them to your flow:
      • slack* (add Skack Bot In and Slack Bot Out);
      • function (add 3 functon nodes);
      • switch (add 2 switch nodes);
      • translator (add Language Translator and Language Identifier);
      • debug (*optional – add debug node).


    *in case you don’t see slack nodes it is because you don’t have it installed. If you need to install slack node, please follow steps below.

    • inside Node-Red application, on the top-right, there is an option button, click on it;
    • click on Manage Pallete;
    • click on Install tab;
    • type slack on the search;
    • search for node-red-contrib-slack;
    • click on stall button and wait for installation;
    • click done.
  5. Create Node-Red Flow

    Update your flow and connect your nodes so your flow will looks like below



    You need to write few code on the existing nodes. Please follow steps below. To edit a node just double click on it.

    • Edit “Bot in” node and add the Bot API Token (see prereqs);
    • Edit “EN” node, set Property to msg.lang.language and set formula to “== en”;
    • Edit “Not EN” node, set Property to msg.lang.language and set formula to “!= en”;
    • Edit “Set srclang” node, set code as shown below:
      • msg.srclang = msg.lang.language;
      • return msg;
    • Edit “Format msg” node, set code as shown below:
      • var MSG = “User ” + msg.slackObj.fromUser;
      • msg.payload = MSG + ” wrote : ” + msg.payload;
      • return msg;
    • Edit “Translator” node, set Mode to Translate, Domains to Conversational, Target to English. Source can be set to anything, because it will be set dinamically by Formula node;
    • Edit “Format msg” node, set code as shown below:
      • var MSG = “User ” + msg.slackObj.fromUser;
      • msg.payload = MSG + ” wrote [” + msg.srclang + “]: ” + msg.payload;
      • return msg;
    • Edit “Bot out” node and add the Bot API Token (see prereqs).

    Once flow is created, it needs to be deployed to application. Click on the Deploy button on the top-right.

  6. Testing the Solution

    To test the solution you need to go to your Slack channel and type something on different languages.

    Bot needs to pick the text, identify the user name, identify the language used, translate it to en-us (if not already) and write text back to Slack channel to all the members can read in english and write on their own language.

    Examples below:



    My current translator node only supports few source languages (Arabic, English, Portuguese, Spanish and French).

    If I type something in some other not supported language, solution will identify language but it will not translate it to english, as shown below.




    THE END – Thanks for watching.

1 comment on"A simple Watson Translator implementation within a Slack Channel for a Multilingual Team"

  1. CarlosPenante July 01, 2017

    Good work ! We are seeing how we can put some smart tools to work together in our behalf. This really brings us to think about where else we can reach. Thanks, Ayron

Join The Discussion