Junction’18 Recap: Multilingual smart chatbot with NodeJS/AWS/SAP Conversational AI

Note from 2020. This blogpost was written two years ago. I decided to publish it anyway. Now it looks like a retro movie already but it gives the idea and outcomes of our solution during Junction 2018. Have a nice reading!

Can you imagine a weekend full of ideating, coding, sleepless nights, exotic saunas, and bold people who want to change the world, all of it enabled by great companies? Together with my friends, we participated in Junction 2018 Hackathon in Espoo, Finland. We were a 2nd Runner-Up team in the challenge of ‘AI-Driven Customer Interactions. I want to share the idea, slightly revised code, outcomes, and tips from last year's event in this article.

The Idea

SAP has sponsored the challenge. The company was searching for ideas on how to enhance customer support made by humans. It was a suggestion from them to use the SAP Conversational AI which is a handy tool to create chatbots and make them smart. By that, I mean to provide bots with NLP (Natural Linguistic Processing) capabilities.

Our team knew that the clients of SAP are multinational corporations that have customers from all over the world. The main problem in these global interactions is the language barrier. So we concluded that it is possible to create a bot that will translate the user’s message and give an answer in the same language by understanding the intent. Here comes magic, which is done by Google Translate API (in the current version it was changed to AWS Translate for the sake of simplicity) and SAP Conversational AI API.

In the picture above, you can find the concept of the project. A person writes to the chat. SAP Conversational AI captures it (SAPCAI). Then it triggers the webhook with the POST method and request body. API Gateway invokes the Lambda function with the payload which contains the user input text in the original language of the user. AWS Translate, in this case, is called to translate the message to English. For simplicity, we chose English as a core language for which NLP service from SAPCAI was trained.

The Code

After that, we are requesting an endpoint from SAP. The API gets the text, analyzes it, and returns the response in a form similar to that. Here we are interested in the array of ‘intents’. There can be 0 to many elements in that array. The elements of the intents array would be sorted in descending order. The first one with index 0 is the needed one for our purposes.

{
"results": {
"uuid": "21ec79d8-3865-40e3-be8b-f31d040efed8",
"source": "Hello",
"intents": [
{
"slug": "greeting",
"confidence": 0.95
}
],
"act": "wh-query",
"type": "desc:desc",
"sentiment": "neutral",
...
}

Now it is time to find the answer because we have the intent to query DynamoDB. The objects in this AWS-native NoSQL database are in the form of:

{
"intent": "greeting",
"fi": "Terve!",
"sv": "Hej!",
"es": "Hola!",
"en": "Hello!"
}

Later it is easy to get the value for the saved language from AWS Translate response from the returned answer of the database. In a lucky case scenario, our database has the answer in the user’s language. However, there can be a case of the language is not there. Then, our lambda should call the AWS Translate again for the user to get the answer in the same language he asked. Also if there is a need for rich-text messages with links, carousels, or cards, the function can send the reply to the customer in these forms.

As you noticed, there are many asynchronous requests in this application. Thanks to modern EcmaScript where you can use it instead of callbacks and promises the async/await way. So the code is becoming more elegant and readable. Without this possibility, it will be impossible to structure the app with such requests as getTranslatedMessage() and request.analyseText(). The full code can be found on my GitHub:

Outcomes & Tips

Participating in a hackathon can be a very frustrating experience but you need to be prepared for that. Here are my tips:

  • Try to sleep more before weekend X (you will need at least one night which is full of focus)
  • Do not overuse caffeine-contained drinks (they will just drain you later. Better to do breaks, walk and breathe outdoors)
  • Find a team beforehand (for me it was a decisive factor on the latest hackathon)
  • Do not lock yourself in one role (in such a harsh environment, you should use all your potential and not just ‘backend guru with 10 years of experience of Java’)
  • Enjoy the atmosphere by talking to other participants and partners

P.S. Thanks to Niclas Lindgren, Chandara Chea, Mikhail Losev, and Natalia Torres for being the greatest team members at Junction 2018.

This is my article on software development. Please, clap, if you like the article and follow my account to read other stories about motivation and tech. In another one, I am telling my story about becoming a software developer.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Igor Soroka

Igor Soroka

⚡ AWS Community Builder, 📺 wabi-sabi, 👨‍💻 Soroka Tech founder, 🏃 long-distance runner, 🇫🇮 Finland. Writing about tech, motivation, learning, and sports.