ダッシュボードに戻る

ドキュメント

Asyntaiの使い方を学ぶ

機能
Ask AI バー AI 検索バー WordPress のための AI 検索 AI Search for Joomla AI Search for Webflow AI Search for Ghost AI Search for Moodle AI Search for TYPO3 AI Search for Craft CMS AI Search for Grav AI Search for Concrete CMS AI Search for October CMS AI Search for ProcessWire AI Search for Odoo AI Search for Bagisto AI Search for Medusa AI Search for OpenCart AI Search for BigCommerce AI Search for Magento ウェブサイトクロール 知識のギャップ 商品カード 動的商品カード ダイナミック画像 ユーザーコンテキスト カスタムツール リンクパラメータ ライブモニタリング オペレーター対応 エスカレーション AI通知 デイリーレポート リアルタイムデータフィード リアルタイムデータフィードMax チームメンバー シングルサインオン 二要素認証 画像を含める 画像認識 翻訳ウィジェット ローカライズ AIの透明性 リード スマートリード獲得 サポートチケット チャットのカテゴリ 予約 埋め込み ページの除外 ブロックされたIP データ保存ポリシー ゼロ保存モード 個人情報マスキング 出力クラシファイア Access Tags ウィジェットのバージョン固定 監査ログ よりスマートなモデル 思考モードを有効化 返信候補 フォローアップメッセージ 音声テキスト変換 トランスクリプトのダウンロード 埋め込みチャット iframe による埋め込み

Set Up User Context on WordPress

Pass logged-in user information from WordPress or membership plugins into your chatbot

Back to User Context
Standard・Pro・Enterprise プラン

Running a WooCommerce store? Our WooCommerce guide covers customer-specific fields like orders and cart.

What You're Setting

User Context is a client-side JavaScript object. On every page where the widget loads for a logged-in user, you attach an object to window.Asyntai.userContext describing who they are. The widget sends this with each message, so the AI can reply with their name, order status, plan tier, or anything else relevant.

Keys act as labels the AI sees, so make them descriptive — use "Customer name" or "Loyalty points", not just "name" or "points".

window.Asyntai = window.Asyntai || {};
window.Asyntai.userContext = {
  "Customer name": "Sarah Chen",
  "Email": "[email protected]",
  "Subscription plan": "Pro",
  "Loyalty points": 1840,
  "Last order": "#8847, out for delivery"
};

Two ways to set it

Either assign synchronously (if data is already on the page), or provide a fetcher that runs when the chat opens. The second option is better for performance — user data is only loaded when someone actually opens the chat.

// Option A — synchronous (data already available)
window.Asyntai.userContext = { "Customer name": "Sarah", ... };

// Option B — async fetch on chat open (better performance)
window.Asyntai.fetchUserContext = function() {
  return fetch('/api/chat-context/')
    .then(r => r.json())
    .then(data => { window.Asyntai.userContext = data; });
};

Security & size: Never include passwords, credit card numbers, API tokens, or anything sensitive — this data is on the client and visible to anyone inspecting the page. Context is capped at 2,000 characters on Standard and 10,000 characters on Pro; if you exceed it, the tail is truncated.

Core Approach — wp_get_current_user()

WordPress provides wp_get_current_user() to retrieve the logged-in WP_User. Hook into wp_footer and inject an inline script that sets window.Asyntai.userContext.

1
Install a snippets plugin Code Snippets, WPCode, or FluentSnippets — so you can add PHP safely without editing theme files.
2
Paste the snippet below and activate it Customize the fields to include whatever makes sense for your site (membership tier, progress, subscription, etc.).
add_action('wp_footer', function() {
  if (!is_user_logged_in()) return;

  $u = wp_get_current_user();
  $context = [
    'Name'  => $u->display_name,
    'Email' => $u->user_email,
    'Role'  => implode(', ', $u->roles),
    // Add any user meta you want the AI to see:
    'Member since' => date('F Y', strtotime($u->user_registered)),
  ];

  echo '<script>window.Asyntai=window.Asyntai||{};window.Asyntai.userContext='
    . wp_json_encode($context) . ';</script>';
}, 100);

Adding User Meta Fields

Most sites store extended profile data in user meta (subscription tier, points, plan, etc.). Read them with get_user_meta:

$context['Subscription plan'] = get_user_meta($u->ID, 'subscription_plan', true);
$context['Loyalty points']    = get_user_meta($u->ID, 'loyalty_points', true);
$context['Preferred language'] = get_user_meta($u->ID, 'preferred_language', true);

Popular Membership Plugins

MemberPress

if (class_exists('MeprUser')) {
  $mepr_user = new MeprUser($u->ID);
  $active = $mepr_user->active_product_subscriptions('ids');
  if ($active) {
    $context['Active memberships'] = count($active);
  }
}

Paid Memberships Pro

if (function_exists('pmpro_getMembershipLevelForUser')) {
  $level = pmpro_getMembershipLevelForUser($u->ID);
  if ($level) {
    $context['Membership level'] = $level->name;
  }
}

LearnDash / LifterLMS (course platforms)

// LearnDash — current courses
if (function_exists('learndash_user_get_enrolled_courses')) {
  $courses = learndash_user_get_enrolled_courses($u->ID);
  if ($courses) {
    $names = array_map(fn($id) => get_the_title($id), array_slice($courses, 0, 3));
    $context['Enrolled courses'] = implode(', ', $names);
  }
}

ヒント: If you're running bbPress, BuddyPress, or a custom profile plugin, most expose their data via user meta or a global function. Check the plugin's API docs for the fetch call, then drop it into the snippet.

トラブルシューティング

The AI doesn't seem to know who I am

Open your browser DevTools → Console → type window.Asyntai.userContext after the page loads. You should see your object. If it says undefined, your script didn't run — check the script order (context must be set after the widget script loads, or be re-set whenever the user logs in).

Context works on some pages but not others

The widget reads window.Asyntai.userContext on every message. If a page loads fresh (no SPA routing), you need to set context on that page too. For single-page apps, set it once after login and update it whenever user data changes.

Data is stale after the user updates their profile

Re-assign window.Asyntai.userContext with the fresh data after any update. The next message the user sends will include the updated values — no page reload needed.

Context is truncated

You're over the size limit (2k chars Standard, 10k Pro). Trim verbose fields — keep order history to last 2-3 items, truncate long descriptions, drop fields the AI doesn't need.

User Context status page shows "Not receiving context"

Visit the User Context settings page while logged in as a test user, then send a chat message. The status refreshes within a few seconds. If still empty, check the browser console for JavaScript errors and verify the object is set before the chat message is sent.

Privacy reminder: Only share fields relevant to the conversation. Passing a customer's full purchase history when they just want to ask a general question is wasteful and can confuse the AI. Scope context to what helps.