Overview

Skill Level: Any Skill Level

Slack commands have been created to do cool things without leaving Slack’s environment and in this example we show you how to create a slash command to translate messages in Slack leveraging the power of IBM Watson Translation API. A super useful thing fo

Ingredients

The slash command needs to know just the target language for the translation, the language of the message that we want to translate will be automatically identified.

Step-by-step

  1. Get your Watson Language Translation credentials

    To get started with IBM Watson Conversation, you’ll need a Bluemix account. If you don’t have one already, you can sign up here. Once you have signed in, enable the IBM Watson Language Translation service by selecting it here and then clicking on the Create button on the following page.

     

    Once you create it, go to your enabled Watson services list here, select Language Translation and grab its credentials.

     

  2. Creating the Slack Slash Command

    This application is available as a Stamplay Blueprint, a pre-built integration that can be deployed in your Stamplay account with minimum effort. To get started click here or on the button below:

    You’ll be asked to pick a name for your project and then to provide credentials for IBM Watson translation service. Paste those here, click Connect and then on Next.

     

    That’s it the blueprint is now fully configured and you’re ready to move on to the next step. Easy right?

    After the configuration is complete, click on Go To App, and then select Webhook from the left-hand sidebar. There you’ll be able to see the API endpoint URL that we’ll need to provide to Slack. Copy it and let’s move to the next step.

  3. Configuring the Slack command

    Time to create and configure the Slack command. Open https://slack.com/apps/manage/custom-integrations, it should open on your primary organization but if it doesn’t you can switch that in the upper right corner.

     

    Select Slash Command custom integration (if you don’t see it listed, you can add it. Search it from the App Directory search bar on the top) and create a New configuration.

    Here you decide which command your users will have to type (we used /translate) and provide an URL which is the one we copied from the Webhook view and append “?sync=true” to it.

    So if your webhook URL looks like this https://watsontranslateonslack.stamplayapp.com/api/webhook/v1/translate/catch

    Insite the Slack URL field you have to type: https://watsontranslateonslack.stamplayapp.com/api/webhook/v1/translate/catch?sync=true

    Other field in this view let you customize the look of the command with a name and an icon. Here is how we did it, the thing you don’t want to miss is the Autocomplete section so you can add the slash command to the autocomplete list and add some usage hints.

     

     

    Now you’re all set. Go to Slack and type something like “/translate -es this tool works like magic!” and get it translated in a few seconds. Funny uh?

    If you have any feedback or questions tweet us at @stamplay. Enjoy!

Join The Discussion