{"id":29897644,"url":"https://github.com/green-api/green-api-chat","last_synced_at":"2025-08-09T16:23:36.199Z","repository":{"id":306253651,"uuid":"1012472235","full_name":"green-api/green-api-chat","owner":"green-api","description":null,"archived":false,"fork":false,"pushed_at":"2025-07-31T13:35:24.000Z","size":1323,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-01T10:49:34.772Z","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/green-api.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,"zenodo":null}},"created_at":"2025-07-02T11:39:24.000Z","updated_at":"2025-07-29T05:48:06.000Z","dependencies_parsed_at":"2025-07-24T17:08:35.345Z","dependency_job_id":null,"html_url":"https://github.com/green-api/green-api-chat","commit_stats":null,"previous_names":["green-api/green-api-chat"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/green-api/green-api-chat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-api%2Fgreen-api-chat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-api%2Fgreen-api-chat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-api%2Fgreen-api-chat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-api%2Fgreen-api-chat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/green-api","download_url":"https://codeload.github.com/green-api/green-api-chat/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-api%2Fgreen-api-chat/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268231130,"owners_count":24217029,"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-08-01T02:00:08.611Z","response_time":67,"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":[],"created_at":"2025-08-01T10:19:37.324Z","updated_at":"2025-08-09T16:23:36.191Z","avatar_url":"https://github.com/green-api.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 📦 sw-console-chat\n\nChat module for personal accounts using [GREEN-API](https://green-api.com/en).\n\n## 📥 Installation\n\nTo install dependencies:\n\n```bash\nnpm install\n```\n\n## 🚀 Development Mode\n\nStart the development server:\n\n```bash\nnpm run dev\n```\n\n## 📦 Production Build\n\nBuild the app for production:\n\n```bash\nnpm run build\n```\n\nCompiled files will be located in the `dist/` directory.\n\n---\n\n## 🔐 Authorization Methods\n\nYou can provide authorization data to the chat module using either **postMessage** or **URL query parameters**.\n\n---\n\n### 1. Authorization via `postMessage`\n\nTo send authorization data from a parent window to an embedded iframe, use the `postMessage` API.\n\n#### Example:\n\n```ts\niframeReference.current?.contentWindow?.postMessage(\n  {\n    type: MessageEventTypeEnum.INIT,\n    payload: {\n      login: login,\n      apiTokenUser: apiTokenUser,\n      idUser: idUser,\n      idInstance: instanceData.idInstance,\n      apiTokenInstance: instanceData.apiTokenInstance,\n      apiUrl: instanceData.apiUrl,\n      mediaUrl: instanceData.mediaUrl,\n      tariff: instanceData.tariff,\n      locale: resolvedLanguage,\n      theme: currentTheme,\n      platform: platform,\n      projectId: projectId,\n\n      // customization\n      brandDescription: 'Welcome to our support chat!',\n      logo: 'https://example.com/logo.png',\n    },\n  },\n  CHAT_APP_URL // Replace with the actual iframe URL\n);\n```\n\n#### Payload Fields\n\n| Field              | Type                  | Description                                 |\n| ------------------ | --------------------- | ------------------------------------------- |\n| `login`            | `string`              | User login                                  |\n| `apiTokenUser`     | `string`              | User API token                              |\n| `idUser`           | `string`              | User ID                                     |\n| `idInstance`       | `number`              | Instance ID                                 |\n| `apiTokenInstance` | `string`              | API token for the instance                  |\n| `apiUrl`           | `string`              | Base API URL                                |\n| `mediaUrl`         | `string`              | Media upload URL                            |\n| `tariff`           | `TariffsEnum`         | Tariff plan (see below)                     |\n| `locale`           | `string \\| undefined` | Optional language code (e.g., `en`, `ru`)   |\n| `theme`            | `ThemesEnum`          | Theme mode (see below)                      |\n| `platform`         | `string`              | Platform ID (e.g., `web`, `android`, `ios`) |\n| `projectId`        | `string`              | Project identifier                          |\n| `brandDescription` | `string`              | Welcome message when no chat is selected    |\n| `logo`             | `string`              | Image/logo URL above the description        |\n\n#### TariffsEnum\n\n```ts\nexport const enum TariffsEnum {\n  Developer = 'DEVELOPER',\n  Business = 'BUSINESS',\n  BusinessUSD = 'BUSINESS_USD',\n  BusinessKZT = 'BUSINESS_KZT',\n}\n```\n\n#### ThemesEnum\n\n```ts\nexport const enum ThemesEnum {\n  Default = 'default',\n  Dark = 'dark',\n}\n```\n\n---\n\n### 2. Authorization via URL Query Parameters\n\nYou can also pass authorization and customization data via the URL:\n\n```\nhttp://localhost:5173/?idInstance=YOUR_ID\u0026apiTokenInstance=YOUR_API_TOKEN\u0026apiUrl=https://api.green-api.com/\u0026mediaUrl=https://media.green-api.com/\u0026lng=ru\u0026dsc=Добро%20пожаловать%20в%20чат\u0026logo=https://example.com/logo.png\n```\n\n#### Required Query Parameters\n\n| Parameter          | Description                |\n| ------------------ | -------------------------- |\n| `idInstance`       | Instance ID                |\n| `apiTokenInstance` | API token for the instance |\n| `apiUrl`           | Base API URL               |\n| `mediaUrl`         | Media API URL              |\n\n#### Optional Customization Parameters\n\n| Parameter | Description                                              |\n|-----------|----------------------------------------------------------|\n| `lng`     | Language (`ru`, `en`, `he`)                              |\n| `dsc`     | Description text on home screen when no chat is selected |\n| `logo`    | Image/logo URL shown above the description               |\n| `chatId`  | If you need only one chat. In format XXXXXXXXXXX@c.us    |\n\n## 📄 License\n\nMIT License\n\n---\n\n# 📦 sw-console-chat\n\nМодуль чата с использованием [GREEN-API](https://green-api.com/).\n\n## 📥 Установка\n\nДля установки зависимостей:\n\n```bash\nnpm install\n```\n\n## 🚀 Режим разработки\n\nЗапуск сервера разработки:\n\n```bash\nnpm run dev\n```\n\n## 📦 Сборка для продакшена\n\nСборка приложения для продакшена:\n\n```bash\nnpm run build\n```\n\nСкомпилированные файлы будут находиться в директории `dist/`.\n\n---\n\n## 🔐 Методы авторизации\n\nВы можете передать данные авторизации в модуль чата с помощью **postMessage** или **параметров URL**.\n\n---\n\n### 1. Авторизация через `postMessage`\n\nЧтобы отправить данные авторизации из родительского окна в встроенный iframe, используйте API `postMessage`.\n\n#### Пример:\n\n```ts\niframeReference.current?.contentWindow?.postMessage(\n  {\n    type: MessageEventTypeEnum.INIT,\n    payload: {\n      login: login,\n      apiTokenUser: apiTokenUser,\n      idUser: idUser,\n      idInstance: instanceData.idInstance,\n      apiTokenInstance: instanceData.apiTokenInstance,\n      apiUrl: instanceData.apiUrl,\n      mediaUrl: instanceData.mediaUrl,\n      tariff: instanceData.tariff,\n      locale: resolvedLanguage,\n      theme: currentTheme,\n      platform: platform,\n      projectId: projectId,\n\n      // кастомизация\n      brandDescription: 'Добро пожаловать в наш чат поддержки!',\n      logo: 'https://example.com/logo.png',\n    },\n  },\n  CHAT_APP_URL // Замените на фактический URL iframe\n);\n```\n\n#### Поля payload\n\n| Поле               | Тип                   | Описание                                              |\n| ------------------ | --------------------- | ----------------------------------------------------- |\n| `login`            | `string`              | Логин пользователя                                    |\n| `apiTokenUser`     | `string`              | API токен пользователя                                |\n| `idUser`           | `string`              | ID пользователя                                       |\n| `idInstance`       | `number`              | ID инстанса                                           |\n| `apiTokenInstance` | `string`              | API токен инстанса                                    |\n| `apiUrl`           | `string`              | Базовый URL API                                       |\n| `mediaUrl`         | `string`              | URL для загрузки медиа                                |\n| `tariff`           | `TariffsEnum`         | Тарифный план (см. ниже)                              |\n| `locale`           | `string \\| undefined` | Необязательный код языка (например, `en`, `ru`, `he`) |\n| `theme`            | `ThemesEnum`          | Тема интерфейса (см. ниже)                            |\n| `platform`         | `string`              | Платформа (`web`, `android`, `ios`)                   |\n| `projectId`        | `string`              | Идентификатор проекта                                 |\n| `brandDescription` | `string`              | Текст приветствия, когда чат не выбран                |\n| `logo`             | `string`              | Ссылка на логотип, отображаемый над описанием         |\n\n#### TariffsEnum\n\n```ts\nexport const enum TariffsEnum {\n  Developer = 'DEVELOPER',\n  Business = 'BUSINESS',\n  BusinessUSD = 'BUSINESS_USD',\n  BusinessKZT = 'BUSINESS_KZT',\n}\n```\n\n#### ThemesEnum\n\n```ts\nexport const enum ThemesEnum {\n  Default = 'default',\n  Dark = 'dark',\n}\n```\n\n---\n\n### 2. Авторизация через параметры URL\n\nВы также можете передать данные авторизации и кастомизации через параметры URL при загрузке приложения:\n\n```\nhttp://localhost:5173/?idInstance=YOUR_ID\u0026apiTokenInstance=YOUR_API_TOKEN\u0026apiUrl=https://api.green-api.com/\u0026mediaUrl=https://media.green-api.com/\u0026lng=ru\u0026dsc=Добро%20пожаловать%20в%20чат\u0026logo=https://example.com/logo.png\n```\n\n#### Обязательные параметры\n\n| Параметр           | Описание                     |\n| ------------------ | ---------------------------- |\n| `idInstance`       | ID инстанса                  |\n| `apiTokenInstance` | API токен инстанса           |\n| `apiUrl`           | Базовый URL API              |\n| `mediaUrl`         | URL для загрузки медиафайлов |\n\n#### Необязательные параметры кастомизации\n\n| Параметр | Описание                                                        |\n|----------|-----------------------------------------------------------------|\n| `lng`    | Язык интерфейса (`ru`, `en`, `he`)                              |\n| `dsc`    | Описание, отображаемое на главной странице, когда чат не выбран |\n| `logo`   | Ссылка на изображение/логотип, отображаемое над описанием       |\n| `chatId` | Если вам нужен только один чат. Формат XXXXXXXXXXX@c.us         |\n\n## 📄 Лицензия\n\nЛицензия MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreen-api%2Fgreen-api-chat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgreen-api%2Fgreen-api-chat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreen-api%2Fgreen-api-chat/lists"}