Akinator Telegram Bot
A Telegram bot to play the classical Q20 Akinator game
using the node-red-contrib-akinator node and the node-red-contrib-telegrambot node
You must first create a bot with the telegram botfather
How do I create a bot?
There's a… bot for that. Just talk to BotFather (described below) and follow a few simple steps. Once you've created a bot and received your authorization token, head down to the Bot API manual to see what you can teach your bot to do.
Once your bot has been created, configure the telegram node credentials and set your authorization token.
Finally type send "/akinator" to your telegram bot and start to play the game ! you can answer akinator questions with the inline keyboard.
[{"id":"4a9b7303.5bcabc","type":"akinator","z":"c21b1bba.93c518","name":"","region":"en","x":680,"y":600,"wires":[["1ac86e65.4ee252","17b67c4e.c4738c"]]},{"id":"6abbc3ab.354e1c","type":"inject","z":"c21b1bba.93c518","name":"reset","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"chatId\":1195709763}","payloadType":"json","x":150,"y":600,"wires":[["8f430275.5633f"]]},{"id":"c8a8015.60267","type":"telegram sender","z":"c21b1bba.93c518","name":"","bot":"e1ea62de.401e9","x":1110,"y":600,"wires":[[]]},{"id":"17b67c4e.c4738c","type":"debug","z":"c21b1bba.93c518","name":"0xDEBUG","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1090,"y":520,"wires":[]},{"id":"763686c2.e7ca88","type":"telegram command","z":"c21b1bba.93c518","name":"/akinator","command":"/akinator","bot":"e1ea62de.401e9","strict":false,"hasresponse":false,"useRegex":false,"x":140,"y":520,"wires":[["8f430275.5633f"],[]]},{"id":"f1cd165e.b45288","type":"telegram event","z":"c21b1bba.93c518","name":"","bot":"e1ea62de.401e9","event":"callback_query","autoanswer":false,"x":160,"y":660,"wires":[["67865d9.26aa2a4"]]},{"id":"67865d9.26aa2a4","type":"function","z":"c21b1bba.93c518","name":"answer","func":"msg.payload.answer = parseInt(msg.payload.content);\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":340,"y":660,"wires":[["8f430275.5633f"]]},{"id":"1ac86e65.4ee252","type":"function","z":"c21b1bba.93c518","name":"Build Answer","func":"let results = msg.payload.answers[0];\nif (typeof results === 'string' || results instanceof String) {\n var opts = {\n reply_to_message_id: msg.payload.messageId,\n reply_markup: JSON.stringify({\n \"inline_keyboard\": [msg.payload.answers.map((val,idx)=>{return {\"text\": val,\"callback_data\": idx}})]\n })\n };\n msg.payload.options = opts;\n msg.payload.content = msg.payload.question ? msg.payload.question : \"ERROR\";\n msg.payload.type = \"message\";\n \n} else {\n msg.payload = {\n \"chatId\":msg.payload.chatId\n };\n msg.payload.content = results.absolute_picture_path;\n msg.payload.caption = results.name + \" \" + results.description;\n msg.payload.type = \"photo\";\n}\n\nmsg.err = false;\n\n\nreturn [ msg ];\n","outputs":"1","noerr":0,"initialize":"","finalize":"","x":870,"y":600,"wires":[["17b67c4e.c4738c","c8a8015.60267"]]},{"id":"8f430275.5633f","type":"function","z":"c21b1bba.93c518","name":"HUB","func":"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":510,"y":600,"wires":[["4a9b7303.5bcabc","17b67c4e.c4738c"]]},{"id":"5ddbe179.0fd03","type":"comment","z":"c21b1bba.93c518","name":"Telegram Chat Bot Example","info":"","x":200,"y":460,"wires":[]},{"id":"e1ea62de.401e9","type":"telegram bot","botname":"your_bot","usernames":"yourusername","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"1000","usesocks":false,"sockshost":"","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":false}]