{"id":49888298,"url":"https://github.com/boxlinknet/kwtsms-supabase","last_synced_at":"2026-05-15T19:33:48.879Z","repository":{"id":348741273,"uuid":"1192376763","full_name":"boxlinknet/kwtsms-supabase","owner":"boxlinknet","description":"kwtSMS SMS gateway integration for Supabase. Phone OTP authentication, event-driven notifications, multilingual templates, and SMS queue processing.","archived":false,"fork":false,"pushed_at":"2026-04-02T15:46:22.000Z","size":37,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-03T03:51:22.259Z","etag":null,"topics":["a2p-sms","arabic","authentication","deno","edge-functions","kuwait","kwtsms","notifications","otp","sms","sms-gateway","supabase","typescript"],"latest_commit_sha":null,"homepage":"https://www.kwtsms.com/integrations.html","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/boxlinknet.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-26T06:40:57.000Z","updated_at":"2026-04-02T15:46:15.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/boxlinknet/kwtsms-supabase","commit_stats":null,"previous_names":["boxlinknet/kwtsms-supabase"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/boxlinknet/kwtsms-supabase","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boxlinknet%2Fkwtsms-supabase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boxlinknet%2Fkwtsms-supabase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boxlinknet%2Fkwtsms-supabase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boxlinknet%2Fkwtsms-supabase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/boxlinknet","download_url":"https://codeload.github.com/boxlinknet/kwtsms-supabase/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boxlinknet%2Fkwtsms-supabase/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33076221,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-15T11:35:32.926Z","status":"ssl_error","status_checked_at":"2026-05-15T11:35:31.362Z","response_time":103,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["a2p-sms","arabic","authentication","deno","edge-functions","kuwait","kwtsms","notifications","otp","sms","sms-gateway","supabase","typescript"],"created_at":"2026-05-15T19:33:47.986Z","updated_at":"2026-05-15T19:33:48.861Z","avatar_url":"https://github.com/boxlinknet.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://www.kwtsms.com/images/kwtsms_logo_60.png\" alt=\"kwtSMS\" height=\"60\"\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003ekwtSMS for Supabase\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  SMS gateway integration for Supabase using \u003ca href=\"https://www.kwtsms.com\"\u003ekwtSMS\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/boxlinknet/kwtsms-supabase/blob/main/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/badge/license-MIT-blue.svg\" alt=\"License\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://supabase.com\"\u003e\u003cimg src=\"https://img.shields.io/badge/Supabase-Edge_Functions-3FCF8E?logo=supabase\u0026logoColor=white\" alt=\"Supabase\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://deno.land\"\u003e\u003cimg src=\"https://img.shields.io/badge/Deno-TypeScript-000000?logo=deno\u0026logoColor=white\" alt=\"Deno\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.kwtsms.com\"\u003e\u003cimg src=\"https://img.shields.io/badge/kwtSMS-Gateway-FFA200\" alt=\"kwtSMS\"\u003e\u003c/a\u003e\n  \u003cimg src=\"https://img.shields.io/badge/i18n-EN%20%7C%20AR-blueviolet\" alt=\"Languages\"\u003e\n\u003c/p\u003e\n\n---\n\n## About kwtSMS\n\n[kwtSMS](https://www.kwtsms.com) is a Kuwait-based SMS gateway providing A2P (application-to-person) messaging across 200+ countries. It supports transactional and promotional sender IDs, Arabic and English messages, and a REST/JSON API for programmatic SMS delivery.\n\nThis integration connects kwtSMS to your Supabase project, replacing the default SMS provider for phone authentication and adding event-driven SMS notifications through a simple queue-based architecture.\n\n## Features\n\n- **Phone OTP login** using the Supabase Auth Send SMS Hook\n- **Event-driven notifications** through an `sms_queue` table (INSERT to send)\n- **Multilingual templates** with `{{placeholder}}` support (English and Arabic)\n- **Customer and admin recipients** from a single queue\n- **Phone normalization** with Arabic digit conversion, prefix stripping, and country code prepend\n- **Message cleaning** strips emoji, hidden characters, and HTML tags before send\n- **Balance, sender ID, and coverage sync** cached locally, updated daily\n- **SMS audit log** with full API response history\n- **Gateway test mode** for development without consuming credits\n\n## Architecture\n\n```\nSupabase Auth ──\u003e sms-auth-hook ──\u003e kwtSMS API\n                                        ^\nApp / DB ──\u003e sms_queue table            |\n                 |                      |\n           pg_cron (30s) ──\u003e send-sms ──┘\n\nsms-admin ──\u003e settings, templates, logs\nsms-cron  ──\u003e daily balance/coverage sync\n```\n\nFour Edge Functions, five database tables, PL/pgSQL triggers for normalization and template rendering, and pg_cron for queue processing.\n\n## Quick start\n\n### Prerequisites\n\n- Supabase project (local or hosted)\n- [Supabase CLI](https://supabase.com/docs/guides/cli) installed\n- [kwtSMS account](https://www.kwtsms.com) with API access\n\n### Install\n\n1. Clone this repo:\n\n   ```bash\n   git clone https://github.com/boxlinknet/kwtsms-supabase.git\n   cd kwtsms-supabase\n   ```\n\n2. Link to your Supabase project:\n\n   ```bash\n   supabase link --project-ref \u003cYOUR_PROJECT_ID\u003e\n   ```\n\n3. Run database migrations:\n\n   ```bash\n   supabase db push\n   ```\n\n4. Set your kwtSMS credentials:\n\n   ```bash\n   supabase secrets set KWTSMS_USERNAME=your_api_username\n   supabase secrets set KWTSMS_PASSWORD=your_api_password\n   supabase secrets set SEND_SMS_HOOK_SECRET=v1,whsec_your_secret_here\n   ```\n\n5. Deploy Edge Functions:\n\n   ```bash\n   supabase functions deploy\n   ```\n\n6. Enable the Send SMS Hook in the Supabase Dashboard:\n   - Go to **Authentication \u003e Hooks \u003e Send SMS**\n   - Select HTTP and enter the `sms-auth-hook` function URL\n\n### Send an SMS\n\nQueue an SMS with a template:\n\n```sql\nINSERT INTO sms_queue (phone, template_slug, variables, language)\nVALUES ('96598765432', 'order_confirmed', '{\"order_id\": \"1234\"}', 'en');\n```\n\nOr call the RPC function from your app:\n\n```typescript\nconst { data } = await supabase.rpc('send_sms', {\n  p_phone: '96598765432',\n  p_template_slug: 'order_confirmed',\n  p_variables: { order_id: '1234' },\n  p_language: 'en'\n})\n```\n\nThe queue processor picks up pending rows every 30 seconds, normalizes the phone number, cleans the message, and sends it through the kwtSMS API.\n\n## Default templates\n\n| Slug | English | Arabic |\n|------|---------|--------|\n| `auth_otp` | Your verification code is: `{{otp}}` | رمز التحقق الخاص بك هو: `{{otp}}` |\n| `order_confirmed` | Your order #`{{order_id}}` has been confirmed. | تم تأكيد طلبك رقم #`{{order_id}}`. |\n| `order_shipped` | Your order #`{{order_id}}` has been shipped. | تم شحن طلبك رقم #`{{order_id}}`. |\n| `order_delivered` | Your order #`{{order_id}}` has been delivered. | تم توصيل طلبك رقم #`{{order_id}}`. |\n| `order_cancelled` | Your order #`{{order_id}}` has been cancelled. | تم إلغاء طلبك رقم #`{{order_id}}`. |\n| `payment_received` | Payment of `{{amount}}` received. Thank you. | تم استلام دفعة بقيمة `{{amount}}`. شكرا لك. |\n| `welcome` | Welcome to `{{app_name}}`! | مرحبا بك في `{{app_name}}`! |\n\nTemplates are editable through the `sms-admin` Edge Function and can be reset to defaults at any time.\n\n## Admin API\n\nThe `sms-admin` Edge Function exposes these endpoints (requires `service_role` JWT):\n\n| Method | Path | Description |\n|--------|------|-------------|\n| POST | `/login` | Test credentials, save to settings |\n| GET | `/settings` | Get settings (credentials masked) |\n| PUT | `/settings` | Update gateway settings |\n| GET | `/templates` | List all templates |\n| PUT | `/templates/:slug` | Update a template |\n| POST | `/templates/:slug/reset` | Reset a template to default |\n| POST | `/templates/reset` | Reset all templates |\n| GET | `/logs` | Paginated SMS log |\n| DELETE | `/logs` | Clear logs |\n| GET | `/balance` | Get cached balance |\n| POST | `/balance/sync` | Sync balance from kwtSMS |\n| POST | `/test-gateway` | Send a test SMS |\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboxlinknet%2Fkwtsms-supabase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fboxlinknet%2Fkwtsms-supabase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboxlinknet%2Fkwtsms-supabase/lists"}