{"id":22385154,"url":"https://github.com/johnnybui/my-assistant-api","last_synced_at":"2025-03-26T20:23:48.812Z","repository":{"id":54306204,"uuid":"119488034","full_name":"johnnybui/my-assistant-api","owner":"johnnybui","description":"API of Okos the assistant (Telegram Bot)","archived":false,"fork":false,"pushed_at":"2021-02-25T07:27:58.000Z","size":65,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-01T02:19:51.906Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/johnnybui.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-30T05:39:11.000Z","updated_at":"2021-02-25T07:28:00.000Z","dependencies_parsed_at":"2022-08-13T11:31:09.742Z","dependency_job_id":null,"html_url":"https://github.com/johnnybui/my-assistant-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnnybui%2Fmy-assistant-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnnybui%2Fmy-assistant-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnnybui%2Fmy-assistant-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnnybui%2Fmy-assistant-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johnnybui","download_url":"https://codeload.github.com/johnnybui/my-assistant-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245728727,"owners_count":20662740,"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","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":[],"created_at":"2024-12-05T01:21:49.384Z","updated_at":"2025-03-26T20:23:48.787Z","avatar_url":"https://github.com/johnnybui.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Okos Assistant API\n## API of Okos the assistant\n* NodeJS\n* ExpressJS\n* Telegram Bot API\n\n### Demo\n[@OkosBot](https://t.me/OkosBot)\n\nAPI Server: https://okos.firefenix.cf\n\n### What can Okos do?\nFor the moment, Okos can send notifications to your Telegram. Response to general chat/commands and search GIFs.\n\n### Run\n`npm start` for local serving\n\nor\n\n`npm install -g nodemon`\n\nthen\n\n`npm run dev` for development serving\n\nApp will be running at `http://localhost:3000`\n\n### External Service API Keys\n- For local serving and testing, create `.env` file in project root folder with content (environment variables):\n```\nNTBA_FIX_319=1\nTELEGRAM_BOT_API_KEY=Your_Telegram_API_Key\nGIPHY_API_KEY=Your_Giphy_API_Key\n```\n\n- If you deploy this project on live server, add those environment variables to your server config.\n\n### Modify to use Okos as your personal assistant\n- First, fork this repo.\n\n- You can chat with [@BotFather](https://t.me/BotFather) to create new bot then set your bot's API Key to environment variable as instrunction above.\n\n#### 1. Notification Service\nFor your own notification services, implement them in `routes/notification.js`. Change `CHAT_ID` to the `chat_id` bewteen you and your bot. Then modify or implement HTTP webhooks to match your needs.\nTo get `chat_id`, chat with your bot and then make a HTTP request:\n```bash\ncurl https://api.telegram.org/bot460111688:AAE93QlqcYNSRK1FO1UwL1Ytdk3PxPFmo2U/getUpdates\n```\nYou will see your `chat_id` you need.\nIf you ran this project before making this request or you manually set webhook for you bot. You'll have to make this request before the last one:\n```bash\ncurl https://api.telegram.org/bot460111688:AAE93QlqcYNSRK1FO1UwL1Ytdk3PxPFmo2U/deleteWebhook\n```\n\n#### 2. Chat \u0026 Command Responses\nFor general chat reply and response to commands, implement in `routes/chat.js`, inside this block:\n```javascript\ntelegramBot.on('message', msg =\u003e {\n...\n}\n```\n`msg` object contains important data from message sent to your bot. You can switch cases to response base on what message text your bot got. It's in `msg.text`. Example for greetings message:\n```javascript\nif (msg.text === '/start' || msg.text.trim().toLowerCase() === 'hi' || msg.text.trim().toLowerCase() === 'hello') {\n    telegramBot.sendMessage(msg.chat.id, `Hello ${msg.from.first_name}`);\n}\n```\nUse `telegramBot.sendMessage` with `msg.chat.id` and message text to response to sender.\n \nFor more information about `message` object, modifying `inline_keyboard`, `callback_query` and everything else, checkout https://core.telegram.org/bots/api\n \n### Contribution\nPlease help me to develop more services for this API. Any helpful service ideas are welcome. If you think we should change improve the structure, please let me know.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnnybui%2Fmy-assistant-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohnnybui%2Fmy-assistant-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnnybui%2Fmy-assistant-api/lists"}