{"id":19076122,"url":"https://github.com/gapur/cupido-bot","last_synced_at":"2025-08-01T00:36:48.607Z","repository":{"id":39893487,"uuid":"220533731","full_name":"Gapur/cupido-bot","owner":"Gapur","description":"🤖 Love Calculator Telegram Bot with Node.js","archived":false,"fork":false,"pushed_at":"2023-05-07T05:48:17.000Z","size":2200,"stargazers_count":9,"open_issues_count":3,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-30T03:52:30.698Z","etag":null,"topics":["bot","javascript","nodejs","telegraf"],"latest_commit_sha":null,"homepage":"https://medium.com/@gapur.kassym/build-own-telegram-bot-with-node-js-516b8f233585","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Gapur.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-11-08T19:24:01.000Z","updated_at":"2023-03-08T20:12:09.000Z","dependencies_parsed_at":"2022-08-30T18:20:20.863Z","dependency_job_id":"3fef21ac-89bf-4228-82df-610357b90707","html_url":"https://github.com/Gapur/cupido-bot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Gapur/cupido-bot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gapur%2Fcupido-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gapur%2Fcupido-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gapur%2Fcupido-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gapur%2Fcupido-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Gapur","download_url":"https://codeload.github.com/Gapur/cupido-bot/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gapur%2Fcupido-bot/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268147437,"owners_count":24203280,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-31T02:00:08.723Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot","javascript","nodejs","telegraf"],"created_at":"2024-11-09T01:57:11.198Z","updated_at":"2025-08-01T00:36:48.579Z","avatar_url":"https://github.com/Gapur.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg width=\"680\"src=\"https://github.com/Gapur/cupido-bot/blob/master/images/bot-father.png\"\u003e\n\u003c/p\u003e\n\n# cupido-bot\n\nLove Calculator Telegram Bot with Node.js\n\nSince Telegram Bot has appeared, I always interested in how they work. So I decided to build simple Telegram Bot with Node.js and Telegraf. Telegraf is a modern bot framework for Node.js.\n\n## Create own Bot with BotFather\n\nFirst, We should create own bot with BotFather. BotFather is the one bot to rule them all. We will use it to create new bot accounts and manage your existing bots.\n\nIf you open a chat with a BotFather, click on the “Start” button:\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"680\"src=\"https://github.com/Gapur/cupido-bot/blob/master/images/start.png\"\u003e\n\u003c/p\u003e\n\nWe should create a new bot by clicking /newbot command. Next, you should enter any name for the bot. I named Cupido \n\n## Setting up the Project\n\nInstall and run the project:\n\n1. Clone this repo:\n```\ngit clone https://github.com/Gapur/cupido-bot.git\n```\n\n2. Install dependencies:\n```\nnpm install\n```\n\n3. Launch project:\n```\nnode index.js\n```\n\n## Write bot’s code\n\nWe can create bot by the following code lines:\n```js\nconst Telegraf = require('telegraf') // import telegram lib\n\nconst bot = new Telegraf(process.env.BOT_TOKEN) // get the token from envirenment variable\nbot.start((ctx) =\u003e ctx.reply('Welcome')) // display Welcome text when we start bot\nbot.hears('hi', (ctx) =\u003e ctx.reply('Hey there')) // listen and handle when user type hi text\nbot.launch() // start\n```\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"680\"src=\"https://github.com/Gapur/cupido-bot/blob/master/images/two-step.png\"\u003e\n\u003c/p\u003e\n\nWe can change bot’s icon by /mybots command.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"680\"src=\"https://github.com/Gapur/cupido-bot/blob/master/images/image.png\"\u003e\n\u003c/p\u003e\n\nLet's create loveCalculator.js to work with api:\n```js\n\nconst axios = require(\"axios\");\n\nconst BASE_URL = \"https://love-calculator.p.rapidapi.com\";\n\nmodule.exports = {\n  getPercentage: (yourName, partnerName) =\u003e axios({\n      \"method\": \"GET\",\n      \"url\": `${BASE_URL}/getPercentage`,\n      \"headers\": {\n        \"content-type\": \"application/octet-stream\",\n        \"x-rapidapi-host\": \"love-calculator.p.rapidapi.com\",\n        \"x-rapidapi-key\": process.env.RAPID_API_KEY\n      },\n      \"params\": {\n        \"fname\": yourName,\n        \"sname\": partnerName\n        }\n      })\n};\n```\n\nI used stage from telegraf to implement a two-step conversation between user and bot. Stage is a simple scene-based control flow middleware.\n```js\nconst Telegraf = require('telegraf');\nconst Markup = require(\"telegraf/markup\");\nconst Stage = require(\"telegraf/stage\");\nconst session = require(\"telegraf/session\");\nconst WizardScene = require(\"telegraf/scenes/wizard\");\n\nconst loveCalculator = require(\"./api/loveCalculator\");\n\nconst bot = new Telegraf(process.env.BOT_TOKEN)\n\nbot.start(ctx =\u003e {\n  ctx.reply(\n    `Hello ${ctx.from.first_name}, would you like to know the love compatibility?`,\n    Markup.inlineKeyboard([\n      Markup.callbackButton(\"Love Calculate\", \"LOVE_CALCULATE\")\n    ]).extra()\n  );\n});\n\n// love calculator two-step wizard\nconst loveCalculate = new WizardScene(\n  \"love_calculate\",\n  ctx =\u003e {\n    ctx.reply(\"Please, enter your name\"); // enter your name\n    return ctx.wizard.next();\n  },\n  ctx =\u003e {\n    ctx.wizard.state.yourName = ctx.message.text; // store yourName in the state to share data between middlewares\n    ctx.reply(\n      \"Enter the name of your partner/lover/crush to find Love compatibility \u0026 chances of successful love relationship.\"\n    );\n    return ctx.wizard.next();\n  },\n  ctx =\u003e {\n    const partnerName = ctx.message.text; // retrieve partner name from the message which user entered\n    const yourName = ctx.wizard.state.yourName; // retrieve your name from state\n    loveCalculator\n      .getPercentage(yourName, partnerName)\n      .then(res =\u003e {\n        const { fname, sname, percentage, result } = res.data;\n        ctx.reply(\n          `${fname} + ${sname} = ${percentage}% \\n ${percentage \u003e 50 ? '☺️' : '😢'} ${result}`,\n          Markup.inlineKeyboard([\n            Markup.callbackButton(\n              \"♥️ calculate Another Relationship\",\n              \"LOVE_CALCULATE\"\n            )\n          ]).extra()\n        );\n      })\n      .catch(err =\u003e ctx.reply(\n        err.message,\n        Markup.inlineKeyboard([\n          Markup.callbackButton(\"calculate again\", \"LOVE_CALCULATE\")\n        ]).extra()\n      ));\n    return ctx.scene.leave();\n  }\n);\n\nconst stage = new Stage([loveCalculate], { default: \"love_calculate\" }); // Scene registration\nbot.use(session());\nbot.use(stage.middleware());\nbot.launch();\n```\n\n## Our Telegram Bot\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"680\"src=\"https://github.com/Gapur/cupido-bot/blob/master/images/bot.png\"\u003e\n\u003c/p\u003e\n\n## Article on Medium\n\n[Build own Telegram Bot with Node.js](https://medium.com/@gapur.kassym/build-own-telegram-bot-with-node-js-516b8f233585)\n\n## How to contribute?\n\n1. Fork this repo\n2. Clone your fork\n3. Code 🤓\n4. Test your changes\n5. Submit a PR!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgapur%2Fcupido-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgapur%2Fcupido-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgapur%2Fcupido-bot/lists"}