Blog for Learning

| lesson material | material summary | questions and answers | definitions | types and examples | other information | materi pelajaran | ringkasan materi | pertanyaan dan jawaban | definisi | jenis-jenis dan contoh-contoh | informasi lainnya |

Powered by Blogger.


How to Make a Simsimi Telegram Bot with Webhook Service

Simsimi can we borrow her brain to control Telegram bots. So that bots can talk like simsimi.
We can access Simsimi's intelligence with the API Key / API / Token Key.
There are two API / Token keys given by simsimi:
  1. Trial Key (free)
  2. Paid Key
Trial keys are only valid for 7 days with a limit of 100 requests / day.
If it crosses that line, Simsimi won't respond.
But take it easy, there's a trick(update: can't already)
I'll tell you later at the end of this guide 😄.
Well, let's start making Telegram bots with Simsimi's intelligence.

How the Bot Works with and Simsimi

Previously, please know how to communicate bot with and Simsimi API.
The way to communicate Telegram Bot with and Simsimi API
The bot sends the text (message) to, then forwards the request to Simsimi.
Simsimi gives a reply, the code in processes it and sends a reply to the Bot.
It's easy?

Materials needed

  1. Telegram Bot Token ( How to get it ): its function to access Telegram Bots.
  2. account ( Register here ): where to store bot codes.
  3. API / Token Simsimi Key ( Register here ): its function to access Simsimi's intelligence.
Make sure you have prepared all the ingredients.

Make a Service at

Make a service on ( click here ).
Name is filled with the desired name.
For example, I made a service called iyan-chan.
Make a Service at
When done, we will have our own server with the address<username>/<nama service>/
My example:

Making Environmental Variables

After that, please create an environment variable at .
The environment variable serves to hold the token and API Key, so that we do not deactivate tokens in the code.
Because tokens are confidential.
There are two variables that need to be made:
  • variable iyan_chan_botfor storing Telegram Bot tokens
  • variable simsimi_keyto store Key Simsimi tokens / APIs
Create environment variable
* Ignore vairabel token_petani_bot, it's a variable for the previous tutorial .
Variables are case sensitive , upper and lower case are distinguished.
We can access this variable in the code with the object hook.env.
For more details, please see the next step.

Creating a Bot Control Code

Reopen the service that was created.
Please change the code (hook source) with the following code.
module['exports'] = function iyanChanBot(hook) {

    var request = require('request');    
    var botName = "iyan"; // nama bot, silahkan ganti sesukanya
    var simiUrl = ''+hook.env.simsimi_key+'&lc=id&ft=1.0&text='+hook.params.message.text;

    // tulis teks yang dikirim dari Telegram ke Logs
    console.log("Telegram: " + hook.params.message.text);

    // buat request ke API Simsimi
      request(simiUrl, function (error, response, body) {
      if (!error && response.statusCode == 200) {
         var data = JSON.parse(body);

         // tampilkan balasan dari Simsimi ke Logs

        var pesanBalasan = "";

        // kode error dari Simsimi
        // 400-Bad Request.
        // 401-Unauthorized.
        // 404-Not found.
        // 500-Server Error.
        // 509-melewati batas.

        if(data.result == 509 || data.result == 400 || data.result == 401 || data.result == 404 || data.result == 500 ){
            pesanBalasan = botName + " sedang tidur, silahkan hubungi kakak @ardiantapargo!";
        } else {
            pesanBalasan = data.response;

            // replace teks "simsimi" dengan nama bot
            pesanBalasan = data.response.replace(/simisimi/g, botName);
              pesanBalasan = data.response.replace(/simsimi/g, botName);
            pesanBalasan = data.response.replace(/Simsimi/g, botName);            
            pesanBalasan = data.response.replace(/cimicimi/g, botName);
            pesanBalasan = data.response.replace(/Simi/g, botName);
              pesanBalasan = data.response.replace(/simi/g, botName);

        // kirim balasan dari simsimi ke Bot Telegram
          .post('' + hook.env.iyan_chan_bot + '/sendMessage')
                "text": pesanBalasan


The main function of the code above is to accept and make a request.
First Servie will receive a request (chat) from the bot, then the request is forwarded to the Simsimi API.
After getting a reply from API simsimi, we send the reply back to the bot.
Pay attention:
hook.env.simsimi_keyand hook.env.iyan_chan_botmake sure it's the same as the name of the environment variable that was created.
After that, save the code.
The Bot Control Code is ready
Don't forget to run the service:
Run Servie
If you get an error like this
Error when running service
Ignore it.
That's because there are no parameters given.
Later the parameters come from the Telegram Bot.

Connect a Bot with

Bot Relations with
The next step connects Bot with
We can use the following URL to do this:<TOKEN>/setWebhook?url=<hook-user>/<hook-name>
Please replace:
  • <TOKEN> with your bot token
  • <hook-user> with your username
  • <hook-name> with the name of the service / service hook that you made
Then, please open the URL via the browser.
If you get a reply like this, then the bot successfully connects with the service.
Connect a Bot with

Trial Demo:

Please chat with the bot @iyan_chan_bot .
Demo of Telegram Bot Experiment with Simsimi API
Yohoo !, The bot can respond like Simsimi.
"What should be done if the bot doesn't respond?"
First try checking the log, is there something displayed there?
Because we used the function console.log()to print the output there.
Bot Logs at
what I marked red is a log error, because the bot has exceeded the limit set by Simsimi. Sleeping sleep ...
In addition, we can view logs in realtime through Terminal or CMD with the command:
curl -N
For example, see in this video.
The next thing to do is to check the code.
Is there a typo code?
Are there different uppercase and lowercase letters?
Please research.

Add Bots in the Group

Previously, please set the Bot at @botfather to be able to join the Group.
Send order /setjoingroups.
Set the Bot to be able to join the Group
After that add it to the Group and make the Bot an administrator.
Making a bot as an administrator
Or if you don't have administrator access in the Group, please turn off theprivacy bot.
Send the command /setprivacyto @botfather .
Then select Disable .
Disabling privacy bot
Description :
  • Enable: means that the bot will only receive messages to the group if it is mentioned or by command /.
  • Disable: means that the bot will accept all messages in the group.
Please note, the free package has a limit of 1000 requests / month.
So use it wisely 😄.
If you want more, please rent a paid package.

Tricks for Bots to Live

Update [May 23, 2017] : Simsimi has implemented Capcha on the web. So, we cannot access it via a bot. This method can no longer be used ...
As we know, the API simsimi trial period is up to 7 days with a limit of 100 requests / day.
This means that our bots will fall asleep if they have sent a message 100 times and will die after 7 days.
If you want to stay alive, it means you have to pay the API Key with the price of the package that has been determined .
Price of the Key Simsimi API package
It seems expensive if only for experiments.
Therefore, we need to 'outsmart' a little 😄.
Please open, web .
Then right click, select inspect elements .
Enter the network section .
inspect Eelement Network Simsimi
After that try sending a message to Simsimi and pay attention in the Networksection .
URL Request Simsimi
See what we get ...
Request URL and a token.
If we open the URL, we will get JSON like this.
Simsimi's response
Well! already know what to do next.
Yep! so true…
we must modify the bot control code by using the Request URL to the URL.
So be like this.
module['exports'] = function iyanChanBot(hook) {

    var request = require('request');

    var botName = "iyan"; // nama bot, silahkan ganti sesukanya

    //var simiUrl = ''+hook.params.message.text;

     var simiUrlWeb = '' + hook.params.message.text + '&status=W';

      // untuk menyimpan pesan balasan dari Simsimi
      var pesanBalasan = "";

    // tampilkan pesan dari Telegram ke Logs
      console.log("Telegram: " + hook.params.message.text);

      request(simiUrlWeb, function (error, response, body) {


      if (!error && response.statusCode == 200) {
         var data = JSON.parse(body);

        // 400-Bad Request.
        // 401-Unauthorized.
        // 404-Not found.
        // 500-Server Error.

        if ( data.status == 509 || data.status == 400 || data.status == 401 || data.status == 404 || data.status == 500){
            pesanBalasan = botName + " sedang tidur, silahkan hubungi kakak @ardiantapargo!";
        } else {
            pesanBalasan = data.respSentence;
              pesanBalasan = data.respSentence.replace(/simisimi/g, botName);
              pesanBalasan = data.respSentence.replace(/simsimi/g, botName);
            pesanBalasan = data.respSentence.replace(/Simsimi/g, botName);            
            pesanBalasan = data.respSentence.replace(/cimicimi/g, botName);
            pesanBalasan = data.respSentence.replace(/Simi/g, botName);
              pesanBalasan = data.respSentence.replace(/simi/g, botName);

      } else {
          // kalau request ke Simsimi gagal
        pesanBalasan = botName + " sedang tidur, silahkan hubungi kakak @ardiantapargo!";


      //kirim balasan ke Telegram
          .post('' + hook.env.iyan_chan_bot + '/sendMessage')
                "text": pesanBalasan //hook.params.message.text

Save the code and run the server again.
Good luck.
Note [May 2017]: Tokens obtained from the simsimi Web do not seem to last long. I don't know exactly how long the token is. It looks like following the Cookies period in the browser.
In the experiment I did in bot @iyan_chan_bot , the bot was dead. But you can come back to life by changing the token with a new one.

0 Komentar untuk "How to Make a Simsimi Telegram Bot with Webhook Service"

Silahkan berkomentar sesuai artikel

Template By Kunci Dunia
Back To Top