This summer, I had the great opportunity to work as a software development intern at Smooch. During my first few weeks, my manager asked me to build something on Smooch. But what? We have customers connecting Smooch to Watson, to their custom bots, to their own backend systems, and so much more. I decided to go with a project that made use of a simple translation API.

Here’s how it went down and how you can use the same process using webhooks and the REST API to build almost anything on Smooch. It’s that flexible!

I decided that I wanted my translator service to translate messages from an app user (that’s the customer) to the app maker’s language of choice (that's the business) and vice-versa. And, because it was built with Smooch, messages could be sent to and from any of my favourite platforms :)

Building my translation app on Smooch

Step 1. Language detection and translation

Language detection and translation are huge topics in computer science and computational linguistics. Lucky for us, there are plenty of easy-to-use APIs out there. I went with the Yandex translation API. Taking as input a short sentence, I could then figure out the language and translate to English.

Step 2. Sending messages to Smooch

Once I translated my messages, I wanted to send them from the app user to the app maker, and vice-versa. Sending our translated messages is easy with the REST API.

Step 3. Putting it all together

Alright, so now we’re able to translate messages and send messages. Now, let’s put it all together by syncing our backend with Smooch using webhooks!

Webhooks make it super easy to build on top of Smooch. They are user-defined callbacks. They are triggered by events -- in this case, messages from customers and businesses. When the event occurs, the webhook will make a call to the URI it’s configured to.

To give you an idea, here’s how I set up my project:

// Receive app user messages'/fromAppUser', function(req, res) {  
   const payload = req.body;
   const message = payload.messages[0];
   const text = message.text;
   // Translation magic happens here
   // ...

// Receive app maker messages'/fromAppMaker', function(req, res) {  
   // Translation magic

In my express app I have two routes set up: one for receiving app user messages and one for receiving app maker messages.

To configure a webhook, navigate to the Smooch dashboard. In the URL text field, simply put the link to your backend service.

Step 4. Ready to go!

Here is the final result:

My translation app using Slack as my back-end and Web Messenger as my front-end

You can check out a live demo over here or fork your own version from the source code here.

With Smooch’s REST API and webhooks you can easily connect Smooch to IBM Watson, Pinterest, Tumblr, anything you can dream up! What will you build on top of Smooch?