Skip to content

Chat card: visitor city and region, messenger visitor language - #107

Open
mysubcult wants to merge 1 commit into
LiveHelperChat:masterfrom
mysubcult:feat/chat-card-location
Open

mysubcult wants to merge 1 commit into
LiveHelperChat:masterfrom
mysubcult:feat/chat-card-location

Conversation

@mysubcult

Copy link
Copy Markdown
Contributor

Makes the first message of a new chat topic (buildChatCard()) more informative, without extra messages or API calls.

Location (web chats)

  • Read from the MaxMind City database LHC geo detection already uses (geo_data.max_mind_city_location), one local lookup per new chat (a few ms).
  • Names in the language of the default site access (ru_RU → Russian, en_EN → English…); country name via intl (Locale::getDisplayRegion), MaxMind names as a fallback.
  • City only when the database is reasonably sure (accuracy_radius < 200 km), otherwise country + region; a region that only repeats the city is skipped.
  • Without a database (or another geo service) the card shows the stored country as before. Location moves to its own line together with the IP.

Example: 🇷🇺 Россия, Чита · Забайкальский край · 176.x.x.x

Messenger visitors (incoming webhooks: Telegram, Max)

  • Language from the stored webhook payload (message.from.language_code / Max user_locale), shown only when it differs from the site language: 🗣 English.
  • Username from the payload when the webhook does not store it in iwh_field (Max).
  • Telegram visitor without a username: the name links to tg://user?id=….

No settings, DB changes or core changes.

🤖 Generated with Claude Code

…and profile link

- Location line from the LHC MaxMind City database, names in the language of the default
  site access (country via intl, city only when accuracy radius < 200 km, then region);
  falls back to the stored country.
- Telegram/Max visitors: language (when different from the site language), username and
  Telegram profile link (tg://user?id) read from the stored incoming webhook payload.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant