Today we announced that developers can now use the Alexa Skills Kit (ASK) to build skills for Hindi speaking customers in India using the new Hindi (hi-IN) language model. This is a detailed walkthrough for building your first skill in Hindi. To add the Hindi language model to your existing skill, read this detailed guide.
In this tutorial, you will learn:
Every skill has a front end and a back end. The front end is where you map utterances (what the user says) into an intent (the desired action). You must decide how to handle the user's intent in the backend. Let’s build the front end of the skill.
The first thing a user will want to do with the skill is open it. The intent of opening the skill is built into the experience, so you don't need to define this intent in your front end. However, you need to respond to the HelloWorldIntent intent in your backend. In this step, you will update your backend code to greet the user when they open the skill.
You will use the ASK SDK for Node.js module. To define how your skill responds to a JSON request, you will define a handler for each intent
There are two pieces to a handler:
canHandle() function
handle() function
The canHandle() function is where you define what requests the handler responds to.
The handle() function returns a response to the user.
If your skill receives a request, the canHandle() function within each handler determines whether or not that handler can service the request. In this case, the user wants to launch the skill, which is a LaunchRequest. Therefore, the canHandle() function within the LaunchRequestHandler will let the SDK know it can fulfill the request.
This speechText variable in the LaunchRequestHandler() method contains the string of words the skill should say back to the user when they launch the skill. Let’s modify the speechText variable to hear Alexa speak in Hindi.
const speechText = “नमस्ते, आप hello या help कह सकते हो. आप क्या करना चाहेंगे?”
Look for handlerInput.responseBuilder. This piece of the SDK will help build the response to the user. On the next line, look for .speak(speechText). Note the speechText variable, which you defined earlier. Calling the .speak() function tells responseBuilder to speak the value of speechText to the user.
If you look at the code, you will notice the HelloWorldIntentHandler. This method handles any request from the HelloWorldIntent. Earlier we had defined few utterances for this intent in our interaction model. Let’s modify the speechText variable in the HelloWorldIntentHandler() to reply to the user when the user greets the skill.
const speechText = “नमस्ते दोस्त”
That’s it. Click Save and then Deploy. Your skill will take a few moments to deploy.
That’s it! You have just built your first Hindi skill.
Since your users can reply in a mix of English and Hindi, there are few guidelines and best practices that you should follow while building a Hindi skill. Read this document to find out more.
Alongside our Technical Evangelist (Sohan Maheshwar) and Solutions Architect (Karthik Ragubathy) you will learn how to reach new Hindi speaking customers by building new Hindi skills and updating your existing skill to the Hindi model.