Hello everyone. After I saw the popularity of Juan's Qlik Bot for Telegram written all in C#, I decided to create another one in JavaScript with Node.js and Enigma.js. Today I am going to share with you the code and how to get started creating your own bot for Telegram on any Operating System that has Node.js installed.
The server will be running under https so if you do not have valid certificates for your domain, or localhost if you are testing it on your local computer, you can have Qlik Sense Enterprise take care of that for you. From QMC, go to start->Certificates and then export for localhost using the "Platform Independent PEM-format"
Copy these certificates and paste them into {QlikBotNode folder}/app/server/certs/localhost
Every platform, upon creation of the bot, it gives you some tokens so your code can authenticate with the platform's servers. Once we have these tokens, for security reasons, we need to set them as environment variables. So, lets create our bot and get our token.
Once you install Telegram Desktop, go to your "BotFather" contact and type "/newbot". Everything in Telegram that starts with "/" is a command. So we typed the command to create a new bot. This will give you an options menu to configure your bot.
Go ahead and give your Bot a name, an icon and a description. If you click on "Back to Bot", you will get a button with the "API Token". Take that token and store it as Environment Variable.
In windows you have to go to "Control Panel" -> "System" -> "Advanced System Settings" -> "Environment Variables" and set a new one as "TELEGRAM_BOT_TOKEN", while in Linux, from your directory (~), type "nano .bash_profile" or "vim .bash_profile" and enter a new line with the token "export TELEGRAM_BOT_TOKEN=######".
Now you should be ready to run your code. From the command line (Git Bash), type "gulp". If everything goes well and you do not have any errors, you should see a message "[nodemon] starting `node app/server/server.js`". Your server is up and running and communication via the Token auth has been established.
Now lets explore the Bot.
Type help to view all of the available commands
Click on the Salesforce button or type /salesforce
Here, there are some buttons to get KPIs and one that takes you to the mashup for validation. Try them all!!!!!
Click on the CIO button or type /cio and then click on "Management" to get the set of KPIs
Click on the Helpdesk button or type /helpdesk
That's it! Now you can a have a Node.js server running with your QlikBotNode and you can start experimenting with KPI commands in the Telegram app.
I have gone thru the Link shared by you for 'Skype'. I am not able to create a bot service. When i click on AI + Cognitive Services > Bot Channels Registration, i am not getting any option to create Bot service. Pls help
After completing the configurations it is working as expected. However, I am facing few issues.
Below undefined javascript error and:
error: error: {} model=Enigma::getHyperCube()
error: error: {} model=Enigma::kpiMulti()
info: error: Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client model=models/sense-bot/Db::get
info: error: Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client model=models/sense-bot/Db::put
Thank you Yianni for your response. I edited Db.js with below data on my local machine and restarted gulp.
this.config = {
host: 'localhost',
user: 'local',
password: 'local',
database: 'sensebot'
};
also have this database in my sql:
I also updated:
mysql> select plugin from user where user='local'; +-----------------------+ | plugin | +-----------------------+ | caching_sha2_password | +-----------------------+ 1 row in set (0.00 sec)
mysql> update user set plugin='mysql_native_password' where user='root'; Query OK, 1 row affected (0.25 sec) Rows matched: 1 Changed: 1 Warnings: 0
However I am still facing same error. Is there any problem in communication between Node server and MySQL server.