| 开发者 | bhoot |
|---|---|
| 更新时间 | 2026年8月3日 18:02 |
| PHP版本: | 8.1 及以上 |
| WordPress版本: | 7.0 |
| 版权: | GPLv2 or later |
| 版权网址: | 版权信息 |
https://api.openai.com/v1/responses for OpenAI, or https://generativelanguage.googleapis.com/v1beta/models/*:streamGenerateContent for Google.https://api.openai.com/v1/files, /v1/vector_stores, /v1/vector_stores/*/files) so the chat can retrieve them. The sync runs in the background, not while you click Save. This happens on OpenAI regardless of which provider answers the chat.https://api.openai.com/v1/vector_stores/*/search to find matching articles, and the matched article text is then sent on to whichever provider is generating the reply.api.openai.com and, if you select Google, generativelanguage.googleapis.com. The plugin does not contact any other external service — no analytics, no telemetry, no third-party fonts or CDN assets, and no phone-home for updates. Updates come from WordPress.org.
How your API keys are handled
The API key you enter for a provider under AI Settings authenticates that provider's requests. Keys are encrypted at rest (AES-256-GCM) in your WordPress database, masked in the admin UI after the first save, and excluded from the WordPress REST API. A key is only ever sent to the service it belongs to. Saving a key for a provider you have not selected stores it but does not use it — that is what lets you switch back without re-entering it.
Your responsibilities
Before activating the plugin, please review the terms of the provider you select — OpenAI's Terms of Use and Privacy Policy, and if you use Gemini, Google's Gemini API Additional Terms of Service and Privacy Policy. Note that Google applies different data-handling terms to free-tier and paid API keys; read the terms for the tier you are on. Because Knowledge Base indexing runs on OpenAI either way, a site with the Knowledge Base switched on shares data with OpenAI even when Gemini answers the chat. Site owners are responsible for obtaining the appropriate legal basis (consent, contract, legitimate interest, etc.) to share visitor messages with these services under GDPR, CCPA, and other applicable privacy regimes in the jurisdictions they operate in. On a WooCommerce store that basis needs to cover the shopping tools too — what a visitor has put in their cart is information about that visitor, even though no name or address is attached to it. If you would rather it never left your site, the shopping tools can be switched off individually in code; see the FAQ below.
Privacy
Conversations and messages are stored in custom database tables on your own site.
For signed-in visitors, the plugin registers WordPress's personal-data exporter and eraser, so the standard Tools → Export Personal Data and Tools → Erase Personal Data flows include their Sohay conversations, matched on their account email.
Anonymous (logged-out) visitors' chats aren't tied to an email address, so those email-based tools can't locate them. To erase a specific guest conversation, open it under Sohay → Conversations and delete it (available to users with the AI-settings capability); it leaves the inbox immediately and is permanently purged after the retention window — 30 days by default, filterable in code. A visitor can also delete their own chat from the widget, and every soft-delete follows the same purge path.
On a WooCommerce store, the chatbot's shopping tools read your catalog, your policy pages, and the visitor's own cart. What they find is sent to your AI provider so the model can answer, and it is also saved with the conversation — that is what lets the product card or cart summary still be there when the visitor scrolls back. So a stored conversation on a WooCommerce store can contain a snapshot of what that visitor had in their cart at the time. It is covered by the same export, erase and retention paths as the rest of the conversation: erasing the chat erases the snapshot with it. No customer name, address, or payment detail is involved — see External services for the exact list.
See the External services section above for what gets sent, and to which service.
Sohay works with OpenAI or Google (Gemini) — choose one under Sohay → AI Settings. OpenAI is the default. You can switch at any time; each provider's key and model choice are stored separately, so switching back does not mean re-entering anything. One thing to know before choosing: the Knowledge Base indexes and searches your articles through OpenAI whichever provider answers the chat. If you select Gemini and use the Knowledge Base, keep an OpenAI key saved as well. Without one, the chatbot still replies but stops consulting your articles.
Yes. Sohay is a front-end for someone else's models — without an API key the plugin has no model to call and the chat cannot answer questions. The provider bills you directly per token; Sohay does not resell access. The Spend protection controls under AI Settings let you cap daily token usage to keep costs predictable.
Providers charge per token, and the per-token rate depends on the model you pick (the cheaper models cost a fraction of a cent per chat reply). A small support site typically stays in single-digit dollars per month. The Spend protection controls under AI Settings let you cap daily token usage — once the cap is hit, the plugin stops calling the provider for the rest of the day. The Diagnostics page shows today's usage so you can spot a runaway loop or a hostile bot before it costs you real money.
The chatbot is grounded in the articles you publish — if it can't find a matching article, it tells the visitor it doesn't know instead of inventing an answer. To improve answer quality, publish articles covering the questions you actually get asked, and write a fallback "Contact us" article so the chatbot can route off-topic questions to your human support team.
Sohay → Conversations lists every chat — search them, filter by status, assign a chat to a teammate, or reply yourself. The Diagnostics page shows OpenAI errors if you're investigating a technical problem.
By default, every WordPress administrator can read every conversation. The plugin ships with five granular capabilities so you can delegate access — for example, give a support agent the ability to read and reply to chats without granting them access to AI Settings. See the developer questions below for an overview, and the capability documentation in the plugin's GitHub repository for the full matrix with worked role-configuration examples.
A tiny launcher (~8 KB) loads on every page. The full chat code only downloads when a visitor actually clicks to open the chat, so most visitors never download it. No third-party scripts, fonts, or trackers are loaded from external CDNs.
The chat renders inside an isolated container so that your theme's styling cannot break the chat, and the chat's styling cannot change your site's fonts, colours, borders, or spacing. That isolation is deliberate — it is what makes the widget look and behave the same way on every theme. The trade-off is that other plugins and scripts which scan your pages for content do not look inside that container. In practice:
On stores running WooCommerce 7.0 or later, a shopper can:
Yes. The chat widget, Knowledge Base, and Conversations inbox work on any WordPress site — the shopping tools simply never appear. On stores running WooCommerce 7.0 or later they switch on by themselves, with no configuration. The plugin also declares HPOS and Cart-Checkout-Blocks compatibility so stores don't see an "uncertified plugin" banner.
Uncheck Show widget under Sohay → AI Settings to hide it everywhere. To hide it only on certain pages or post types, see the developer questions below.
Yes. Sohay → AI Settings has a Welcome Message field (max 280 characters). Sohay → KB Settings → Settings has a Custom System Prompt field (max 4000 characters) for the instructions the chatbot follows when it generates answers. The Custom System Prompt field recognises {site_name} and {current_date} placeholders — they are replaced with your site's title and today's date before the prompt is sent to the model.
Encrypted with AES-256-GCM in your WordPress database. The admin UI shows a masked placeholder once you've saved a key, and the values are excluded from the WordPress REST API. Each key is only ever sent to the service it belongs to.
Uninstalling deletes the plugin's own database tables (conversations, messages, sync jobs, diagnostic logs), its settings, and the capabilities it added. Your Knowledge Base articles are kept — they're regular WordPress content, so removing the plugin doesn't delete them, and they're still there if you reinstall. If you want them gone too, delete the articles under KB Articles before you uninstall.
Yes. Each site in the network keeps its own conversations, Knowledge Base, and settings — nothing is shared across the network. Network-activate to enable Sohay everywhere (each site sets itself up on first load) or activate it per-site. Uninstalling from the network removes Sohay's data from every site.
The questions below cover code-level customization. Sohay exposes 48 filters and 12 actions in total; the most-used ones appear here, and the full catalog lives in docs/HOOKS.md in the plugin's GitHub repository, alongside docs/CAPABILITIES.md for the full capability matrix.
The most commonly customized filters:
sohaychat_should_render_widget (bool) — per-request gate on the chat widget. Combine with is_singular() / is_product() to scope the widget to specific pages.sohaychat_allowed_openai_models / sohaychat_allowed_google_models (string[]) — allowlist of model slugs the proxy may call for each provider. Restrict to cheaper models to cap spend.sohaychat_default_ai_provider (string) — which provider answers the chat when no choice is saved in the admin.sohaychat_provider_options (array) — provider-specific request settings, such as Gemini's safety thresholds, thinking budget, or search grounding.sohaychat_help_url and sohaychat_upgrade_url (string) — override the admin-header "Help" and "Upgrade" links for resellers.sohaychat_admin_conversation_scope — restrict which conversations a non-admin operator can see.sohaychat_tools — the resolved tool list for the request. Remove an entry and the chatbot is never told that tool exists, so it can neither call it nor send its data to your AI provider.add_filter( 'sohaychat_tools', function ( $tools ) { unset( $tools['sohaychat-wc/get-cart'], $tools['sohaychat-wc/update-cart'] ); return $tools; } );
The keys are the tool names: sohaychat-wc/search-catalog, sohaychat-wc/lookup-catalog, sohaychat-wc/get-product, sohaychat-wc/search-shop-policies-and-faqs, sohaychat-wc/get-cart, sohaychat-wc/update-cart, and sohaychat-kb/get-information for the Knowledge Base lookup. Returning an empty array disables tool use entirely — the chatbot still replies, just with no way to look anything up.
Example — hide the widget everywhere except the WooCommerce shop and product pages:
add_filter( 'sohaychat_should_render_widget', function ( $enabled ) { if ( ! $enabled ) { return false; } return function_exists( 'is_shop' ) && ( is_shop() || is_product() ); } );
The constants on Bengal_Studio\Sohaychat\Sohaychat_Hooks are the recommended form for new code; the legacy literal form continues to work across releases.
Five granular capabilities let you delegate parts of the plugin to non-admin roles:
sohaychat_manage — AI Settings page, provider selection, API key entry, model selection. Implicitly grants all four other plugin caps.sohaychat_view_conversations — Sohay menu, Dashboard + Conversations submenus (read-only). Non-admin users with this cap are scoped to "assigned to me or unassigned" conversations.sohaychat_reply_conversations — everything sohaychat_view_conversations grants, plus operator reply, assignee changes, pin / unpin, close / reopen. Implicitly grants sohaychat_view_conversations.sohaychat_manage_kb — KB Settings admin page and KB sync routes.sohaychat_view_logs — Diagnostics admin page (read-only). Clearing the log buffer is escalated to sohaychat_manage for forensics integrity.manage_options capability implicitly grants all five, so administrators keep working unchanged. Use Members, User Role Editor, or WP-CLI (wp cap add <role> sohaychat_view_conversations) to delegate caps to non-admin roles. See docs/CAPABILITIES.md in the GitHub repository for the full matrix, every REST route's required cap, three worked role-configuration examples, and the conversation-scope filter contract.
Three independent limiter filters. The chat-message rate limit (limit requests per rolling window seconds, per visitor):
add_filter( 'sohaychat_rate_limit_options', function ( $opts ) { $opts['limit'] = 60; $opts['window'] = 60; return $opts; } );
Behind Cloudflare or another reverse proxy, enable proxy-aware client-IP detection so per-visitor limits key off the real visitor rather than the proxy:
add_filter( 'sohaychat_rate_limit_options', function ( $opts ) { $opts['proxy_support'] = true; return $opts; } );
Enable proxy_support only when your site is reachable exclusively through the trusted proxy, and that proxy overwrites the CF-Connecting-IP / X-Real-IP / X-Forwarded-For headers on every request. On an origin that's also reachable directly, a visitor could forge those headers to sidestep per-visitor limits; the site-wide daily token budget still caps total spend.
The public /auth/guest-token mint rate limit (separate so token-mint amplification protection can be tuned independently):
add_filter( 'sohaychat_auth_rate_limit_options', function ( $opts ) { $opts['limit'] = 5; $opts['window'] = 60; return $opts; } );
The daily OpenAI token budget (caps also configurable under AI Settings → Spend protection; ceilings reset at UTC midnight; setting either value to 0 disables that particular ceiling):
add_filter( 'sohaychat_usage_tracker_options', function ( $opts ) { $opts['site_cap'] = 5000000; $opts['actor_cap'] = 25000; return $opts; } );
The live readout on the Diagnostics page shows today's usage so you can spot a runaway loop before it 429s real visitors.
KB vector-search results are memoized in the sohaychat_kb object-cache group for 5 minutes by default. To shorten the window, lengthen it, or disable the cache entirely, use the sohaychat_kb_search_cache_ttl filter (return 0 to disable):
add_filter( 'sohaychat_kb_search_cache_ttl', '__return_zero' );
KB sync events flush the cache automatically, so content updates don't get masked.
The plugin sets Cache-Control: no-cache, X-Accel-Buffering: no, and clears output buffers, but some CDNs still buffer Server-Sent Events. If your CDN supports it, mark the chat REST route as bypassing the cache and disable transformations on the response.
Sohay → Diagnostics shows the last 100 plugin log entries with timestamps and context. Each entry also fires the sohaychat_log_error action for integration with Sentry, Stackdriver, Query Monitor, etc.
sohaychat_allowed_ai_providers, sohaychat_default_ai_provider, sohaychat_provider_options, sohaychat_allowed_google_models, and sohaychat_default_google_model.sohaychat_tool_cache_ttl filter.{site_name} and {current_date}; your own custom system prompt still takes priority.sohaychat_system_prompt filter, a tools/abilities foundation with new action and filter hooks, and a conversation tool-call audit table. This release also runs a one-time, automatic database update on upgrade.