The aim of this article is to show how to create a chatbot in SAP Conversational AI and
integrate it with a Telegram chat and Alexa.
This exercise will require to have some previous steps:
The first step is to create a Bot in SAP CAI. As my objective is to test the integration with Telegram and Alexa I will create a simple FAQ Bot using a .csv file like in the example below. I am using common questions in a high school secretary.
Once the .csv file is loaded you can see it in the Bot Train label
Uploaded file can be edited manually to correct possible classification errors. We can start then the training, testing the bot with different prompts to check if the questions asked to the user are correctly related to the intents created.
In the Monitor label, the procedures followed by the Bot in previous conversations can be analyzed in order to observe and assign the correct intent based on the user questions. This will help the Bot to learn with new expressions.
Having corrected the bot's classification of the questions and answers, the bot can then be tested in the SAP console. This continues the training of the bot, enabling its continuous learning.
Once the Bot is tested we can integrate it in different platforms, on a website, MS Teams, Twitter, Slack, Line, Telegram or Amazon Alexa, among others.
In order to create a user-bot interaction external to the SAP CAI console, the bot can be connected to an external channel In this case, it will be connected to the messaging application Telegram. To do this, create an account in the Telegram app and then search for the channel "BothFather". In the chat, type the command "/newbot", answer every question directly in the chat to configure your bot.
Ask BotFather to get your token by typing the command /token in the conversation panel. Copy your token and then go to the Connect label of your Bot in SAP CAI, under Telegram Third party channels and paste your channel Telegram name and token, Telegram.
The CAI Bot is already deployed in Telegram. Now it can be shared with other users to converse with the bot, which will continue to expand its learning in intent recognition.
See this video how the SAP CAI Bot works in Telegram: https://youtu.be/17ULH8Fz-JU
To test the Alexa integration, I have created a new SAP Coversational Bot based in intents and skills. Follow this tutorial to build your own bot: https://developers.sap.com/tutorials/cai-bot-getting-started.html
To connect this new bot created in SAP CAI with Alexa, access Connect label and select Amazon Alexa channel and follow the steps below:
Once these steps are completed, the skill is linked to the bot in SAP CAI, we are able now to test it in the Alexa Developer Console:
To connect the bot with Alexa Echo Dot, we must export the skill's compliance by agreeing to some conditions. The Developer Console also has several modifiable code files in javascript. For this development, it needs the following dependencies:
"dependecies":{
"ask-sdk-core": "^2.7.0",
"ask-sdk-model": "^1.19.0",
"aws-sdk": "^2.326.0",
"i18next": "^2.326.0",
"i18next-sprintf-postprocessor":"^0.2.2"
const Alexa = require('ask-sdk-core');
const i18n = require('i18next');
const sprintf = require('i18next-sprintf-postprocessor');
To put it into operation, we will need a structure with String in several languages. This can be done by adding Interceptors:
const LogginRequestInterceptor = {
process(handlerInput){
console.log(`Incoming request: $(JSON.stringify(handlerInput.requestEnvelope.request)}`);
}
};
const LogginResponseInterceptor = {
process(handlerInput, response){
console.log(`Outgoing response: $(JSON.stringify(response)}`);
}
};
.addRequestInterceptors(LogginRequestInterceptor)
.addResponseInterceptors(LogginResponseInterceptor)
Each handler can process an event that occurs in operation and triggers a given action, responding according to a database. In this case, the request type is to open the Launch Request skill.
SAP Conversational AI is a powerful platform to build Bots with almost no code and be deployed in several channels in an easy way. I hope this article was useful for those who are starting projects In this area of great application opportunities.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Subject | Kudos |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
User | Count |
---|---|
10 | |
7 | |
5 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |