Customer account lookup
Give the AI agent live context about the signed-in visitor: their plan, trial status, seats, recent activity, open invoices, and any custom attributes. This lets it look up a plan or renewal date instead of relying on static training content. Your backend must verify which account the visitor may access.
You expose one read-only JSON endpoint on your backend. Boei calls it during the conversation via a webhook tool, using a shared bearer token for auth. No SDK changes needed for the basic setup.
How to get there: Go to AI agents in the left menu → click your agent → Actions. Open Copilot from the app header and ask it to create the action described below. Review the proposed action and credential settings before enabling it.
How it works
- Visitor opens the chat and provides their email (via the widget's
Boei({ email: ... })call, a lead form, or by typing it). - When the AI needs account context, it calls the
get_customer_accounttool. - Boei sends a
GETto your endpoint with the visitor's email and your shared bearer token. - Your endpoint returns a JSON object describing the account.
- The AI uses those fields to answer the visitor's question.
The AI only calls the tool when it's actually useful (billing, plan, usage questions), not on every message.
Your endpoint
Host a single endpoint on your backend, for example:
GET https://app.example.com/api/boei/customer-lookup?email={email}
Authorization: Bearer <shared-secret>
- Read-only. Never accept writes on this endpoint.
- Rate-limit it (e.g. 60 req/min per token): the AI can call it multiple times per conversation.
- Return
200with{"found": false}if the email isn't a customer. Do not return404. - Do not include other users' PII (colleagues, teammates, etc.). Only the identified visitor's own data.
- Do not include secrets (passwords, API keys, session tokens, full credit card numbers).
Response shape
Return a JSON object. All fields are optional. Include only what you have. Return only fields needed for the supported questions. Keep the response short.
{
"found": true,
"identity": {
"customer_id": "cus_9F3aQ",
"email": "sara@example.com",
"name": "Sara de Vries",
"company": "Acme BV",
"phone": "+31 6 12345678",
"locale": "nl",
"timezone": "Europe/Amsterdam",
"signup_date": "2025-11-14",
"account_url": "https://app.example.com/admin/customers/cus_9F3aQ"
},
"subscription": {
"status": "active",
"plan": "Pro",
"plan_interval": "monthly",
"price": 49,
"currency": "EUR",
"trial": false,
"trial_ends_at": null,
"renews_at": "2026-08-01",
"cancel_at_period_end": false,
"payment_method": "card_visa_4242",
"billing_portal_url": "https://billing.stripe.com/session/xyz"
},
"usage": {
"seats_used": 3,
"seats_limit": 10,
"projects": 12,
"storage_used_gb": 4.2,
"storage_limit_gb": 50,
"period_start": "2026-07-01",
"period_end": "2026-07-31"
},
"billing": {
"open_invoice": false,
"open_invoice_amount": 0,
"last_invoice_date": "2026-07-01",
"last_invoice_amount": 49,
"past_due": false,
"vat_number": "NL123456789B01"
},
"activity": {
"last_login_at": "2026-07-05T14:22:00Z",
"days_since_signup": 236,
"days_since_last_login": 2,
"active_last_30_days": true,
"onboarding_completed": true,
"onboarding_step": null
},
"role": {
"is_admin": true,
"is_owner": true,
"team_size": 4
},
"flags": {
"is_vip": false,
"beta_features": ["new-editor", "ai-summaries"],
"referral_source": "google"
},
"custom": {
"industry": "logistics",
"signup_utm_campaign": "spring-launch",
"csm_name": "Milan"
},
"recent_events": [
{ "type": "invoice_paid", "at": "2026-07-01", "detail": "€49" },
{ "type": "seat_added", "at": "2026-06-18", "detail": "user #3" },
{ "type": "plan_upgraded", "at": "2026-05-02", "detail": "Starter → Pro" }
]
}
Guidance on what to include:
- identity: anchors the AI to the right account. Include
signup_dateso the AI can reason about "new vs long-time customer". - subscription: the single most useful section.
status,plan,trial_ends_at,renews_at,cancel_at_period_endsupport common plan and billing questions. - usage: lets the AI answer "am I close to my limit?"
- billing:
open_invoiceandpast_duelet the AI acknowledge payment issues instead of ignoring them. - activity: helps the AI adjust tone (new user vs power user).
- flags / custom: anything else that helps triage. Feature flags, VIP status, assigned CSM, industry.
- recent_events: 3-10 recent lifecycle events. Great for questions like "what happened to my account last week?".
Do not include: other users' emails, chat transcripts, support ticket bodies, uploaded files, or any content the visitor shouldn't see about themselves.
Not-found response
{ "found": false }
Set the action instructions to explain that no account was found and ask the visitor to check their details. Test this response too.
Configure the tool in Boei
1. Store the shared secret
In Copilot, ask:
Store a credential called
customer_lookup_tokenwith value<your shared bearer token>.
Credentials are encrypted at rest and only referenced by name from tools. They appear in the Credentials panel next to the chat, where you can override or delete them.
2. Create the webhook tool
In Copilot, provide the action settings below. Review the proposal before saving:
{
"name": "get_customer_account",
"description": "Look up the current visitor's account details (plan, trial status, seats, billing state, recent activity). Call this whenever the visitor asks anything about their subscription, billing, invoices, plan limits, usage, or account status. Only call this once you have the visitor's email, either from the SDK identity fields, a lead form, or because they typed it. Do not call it for general product questions.",
"execution_type": "webhook",
"http_method": "GET",
"endpoint_url": "https://app.example.com/api/boei/customer-lookup?email={{context.email}}",
"headers": {
"Authorization": "Bearer {{credential:customer_lookup_token}}",
"Accept": "application/json"
},
"parameters": [],
"response_mapping": {
"found": "found",
"plan": "subscription.plan",
"status": "subscription.status",
"trial_ends_at": "subscription.trial_ends_at",
"renews_at": "subscription.renews_at",
"past_due": "billing.past_due",
"seats_used": "usage.seats_used",
"seats_limit": "usage.seats_limit",
"last_login_at": "activity.last_login_at",
"billing_portal_url": "subscription.billing_portal_url"
},
"requires_confirmation": false,
"is_enabled": true
}
The response_mapping block selects fields from the returned JSON. Do not rely on this mapping to hide private data. Your endpoint must leave out anything the visitor may not see.
3. Test it
Open the widget preview, tell the bot your email, and ask "what plan am I on?" or "when does my trial end?". You should see the AI call get_customer_account in the trace and respond with real values.
Identity strategies
Email lookup (default)
A typed email address does not prove who the visitor is. Do not return private account details based only on that address. Use an authenticated backend session or a signed token that your endpoint verifies.
Signed identity (recommended for sensitive data)
If you want to expose more sensitive fields (open invoice amounts, billing portal URLs, event history), verify the visitor first.
- On page load, your backend signs
{email, exp}with the shared secret (HMAC-SHA256, 5-minute expiry). - Pass it to the widget by calling
Boei({...}). Theidentity_tokengoes inside thecustombag because it isn't one of the built-in identity fields:
window.Boei({
email: "sara@example.com",
custom: {
identity_token: "<hmac-signed-token>"
}
});
- In the tool config, forward the token:
"endpoint_url": "https://app.example.com/api/boei/customer-lookup?email={{context.email}}&identity_token={{context.custom.identity_token}}"
- Your endpoint verifies the token before returning data. Reject on failure.
This token is your own endpoint's verification method. It is separate from Boei's signed visitor identity. Validate it on your server; passing a custom field alone does not verify a visitor.
Security checklist
- Use HTTPS.
- Rotate the shared secret periodically.
- Log requests server-side for audit (which email was queried, when, from which IP).
- Rate-limit per token.
- Never return other users' data.
- Never return secrets (session tokens, API keys, full card numbers).
- Verify account access before returning private fields or billing portal links.
Test the lookup safely
Use a demo account and check a valid visitor, an unknown account, an expired token and an attempt to request another account. Confirm that the endpoint refuses unauthorized access and that the agent explains missing information without inventing account details.