{"id":26678307,"url":"https://github.com/telexintegrations/telex-who-typed-it-first","last_synced_at":"2025-03-26T05:15:26.635Z","repository":{"id":278918070,"uuid":"937162954","full_name":"telexintegrations/telex-who-typed-it-first","owner":"telexintegrations","description":"Stage 3 project for HNG12 Internship program","archived":false,"fork":false,"pushed_at":"2025-02-22T15:14:49.000Z","size":28,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-22T15:19:01.304Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/telexintegrations.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-22T13:42:53.000Z","updated_at":"2025-02-22T15:14:52.000Z","dependencies_parsed_at":"2025-02-22T15:29:08.395Z","dependency_job_id":null,"html_url":"https://github.com/telexintegrations/telex-who-typed-it-first","commit_stats":null,"previous_names":["telexintegrations/telex-who-typed-it-first"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telexintegrations%2Ftelex-who-typed-it-first","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telexintegrations%2Ftelex-who-typed-it-first/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telexintegrations%2Ftelex-who-typed-it-first/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telexintegrations%2Ftelex-who-typed-it-first/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/telexintegrations","download_url":"https://codeload.github.com/telexintegrations/telex-who-typed-it-first/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245591532,"owners_count":20640692,"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":"2025-03-26T05:15:25.921Z","updated_at":"2025-03-26T05:15:26.622Z","avatar_url":"https://github.com/telexintegrations.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"### **Who Typed It First? (Speed Game) - Telex Integration**\n\nThis integration enables a fun and competitive speed game in Telex, where users race to type a message first. The bot detects duplicate messages and announces the first person who sent it.\n\n---\n\n## **🚀 Features**\n- Detects duplicate messages within a **configurable time window** (default: **10 seconds**).\n- Announces the first user who typed a message.\n- Responds to **all users** who send the duplicate message within the window.\n- **FastBot** announces the winner.\n- Supports **configurable webhook endpoints** for Telex.\n- Includes **error handling** and **retry mechanisms**.\n\n---\n\n## **⚙️ How It Works**\n1. A user types a message in Telex.\n2. If it's the first occurrence, it gets recorded.\n3. If another user sends the **same message** within the **10-second window**, FastBot announces the **first user** who typed it.\n4. **All users who send the same message** during this period will receive FastBot’s response.\n5. After the window expires, the message resets, allowing a new round to begin.\n\n---\n\n## **📦 API Endpoints**\n### **1️⃣ Health Check**\n**Endpoint:**\n```http\nGET /health\n```\n**Response:**\n```json\n{\n  \"status\": \"ok\",\n  \"timestamp\": \"2025-02-24T12:00:00.000Z\"\n}\n```\n\n---\n\n### **2️⃣ Process Message**\n**Endpoint:**\n```http\nPOST /process-message\n```\n**Request Body:**\n```json\n{\n  \"channel_id\": \"https://ping.telex.im/v1/webhooks/0195338c-9ee4-7a67-a2d5-4673dbf0cc22\",\n  \"message\": \"Hello world!\",\n  \"target_url\": \"https://ping.telex.im/v1/webhooks/0195338c-9ee4-7a67-a2d5-4673dbf0cc22\",\n  \"user_id\": \"user123\",\n  \"request_id\": \"req-abc-123\"\n}\n```\n**Responses:**\n- **First message recorded**\n```json\n{\n  \"message\": \"Hello world!\",\n  \"metadata\": {\n    \"processed\": true,\n    \"user_id\": \"user123\",\n    \"request_id\": \"req-abc-123\",\n    \"timestamp\": \"2025-02-24T12:00:00.000Z\"\n  }\n}\n```\n- **Duplicate detected (FastBot announces the winner)**\n```json\n{\n  \"message\": \"Hello world!\",\n  \"metadata\": {\n    \"processed\": true,\n    \"user_id\": \"user456\",\n    \"request_id\": \"req-def-456\",\n    \"timestamp\": \"2025-02-24T12:00:05.000Z\"\n  }\n}\n```\nFastBot then sends:\n```json\n{\n  \"channel_id\": \"https://ping.telex.im/v1/webhooks/0195338c-9ee4-7a67-a2d5-4673dbf0cc22\",\n  \"message\": \"🏆 user123 typed it first!\",\n  \"event_name\": \"game_result\",\n  \"status\": \"success\",\n  \"username\": \"FastBot\"\n}\n```\n\n---\n![Telex Screenshot](assets/image.png)\n---\n\n## **🛠️ Configuration**\nThis integration uses **environment variables** to configure the bot.\n\n| Variable | Description | Default |\n|----------|------------|---------|\n| `PORT` | Server port | `5000` |\n| `TELEX_WEBHOOK_URL` | Webhook URL for sending results to Telex | _Required_ |\n| `TELEX_CHANNEL_ID` | Telex Channel ID | _Required_ |\n| `TELEX_API_TOKEN` | API Token for authentication | _Required_ |\n| `DUPLICATE_TIME_WINDOW` | Time (seconds) before the message resets | `10` |\n\n---\n\n## **📝 Notes**\n- The **default time window is 10 seconds** but can be configured.\n- **All duplicate messages within the time window get a response** from FastBot.\n- If **Telex API fails**, the bot **retries 3 times** before stopping.\n- **FastBot always announces the first user** who sent the message.\n\n---\n\n## **🚀 Getting Started**\n1. Clone the repository:\n   ```sh\n   git clone https://github.com/telexintegrations/telex-who-typed-it-first.git\n   cd telex-speed-game\n   ```\n2. Install dependencies:\n   ```sh\n   npm install\n   ```\n3. Create a `.env` file and configure variables.\n4. Start the server:\n   ```sh\n   npm start\n   ```\n5. Use **Postman**  to test the `/process-message` endpoint.\n\n---\n\n## **📜 License**\nMIT License\nThis project is open-source and free to use.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelexintegrations%2Ftelex-who-typed-it-first","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftelexintegrations%2Ftelex-who-typed-it-first","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelexintegrations%2Ftelex-who-typed-it-first/lists"}