Skip to content

Instantly share code, notes, and snippets.

@ardianta
Created February 21, 2017 02:33
Show Gist options
  • Select an option

  • Save ardianta/b67caece3b5ded0a4d958c9fed8adcac to your computer and use it in GitHub Desktop.

Select an option

Save ardianta/b67caece3b5ded0a4d958c9fed8adcac to your computer and use it in GitHub Desktop.
Hook.io script for telegram bot using Simsimi API
module['exports'] = function iyanChanBot(hook) {
var request = require('request');
var simiUrl = 'http://sandbox.api.simsimi.com/request.p?key=API_KEY_SIMSIMI&lc=id&ft=1.0&text='+hook.params.message.text;
request(simiUrl, function (error, response, body) {
if (!error && response.statusCode == 200) {
var data = JSON.parse(body);
request.post('https://api.telegram.org/bot' + hook.env.iyan_chan_bot + '/sendMessage')
.form({
"chat_id": hook.params.message.chat.id,
"text": data.response
});
}
});
};`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment