Passing the customer's ID into Zendesk chat

Updated June 14, 2026

Why pass the customer ID

By default, customers arrive at the chat widget anonymously and the AI must ask for an account ID before it can call tools like get_crm_data, get_recent_activity, or any custom data skills that key off a customer identifier. If you already know who the visitor is, you can pass the ID automatically — the AI has it from the very first message with no ask.

Option A — Client-side only (no backend required)

Read the customer ID from wherever it lives on the page — a cookie, a localStorage key, a JavaScript variable, or a data-* attribute — and pass it to the Zendesk Messaging widget as a conversation field.

One-time setup in Zendesk

  1. Go to Admin Center → Objects & Rules → Tickets → Fields and create a new Text field (e.g. "Customer ID"). Note its numeric ID from the URL.
  2. Go to Admin Center → Channels → Messaging, edit your widget, open the Responses tab, and under Customer details add the field — set it as Optional. (Some plans label this section "Conversation experience".)
  3. In Inquiru, edit your Zendesk integration and paste the field's numeric ID into the Customer ID field ID setting.

JavaScript snippet

function getCookie(name){var m=document.cookie.match(new RegExp('(?:^|; )'+name+'=([^;]*)'));return m?decodeURIComponent(m[1]):null;} var customerId=getCookie('your-user-id-cookie'); if(customerId){function trySet(){if(typeof zE!=='undefined'){zE('messenger:set','conversationFields',[{id:'<your_field_id>',value:customerId}]);}else{setTimeout(trySet,300);}} trySet();}

You can also read from localStorage.getItem('userId') or a variable like window.currentUser.id. Replace <your_field_id> with the numeric Zendesk field ID.

Option B — JWT (recommended if you can modify your backend)

JWT is cryptographically signed server-side, so the customer ID cannot be spoofed from the browser. It also gives returning customers a persistent identity and chat history across devices.

One-time setup in Zendesk

  1. Open Admin Center → Channels → Messaging, edit your widget, and open the Authenticated visitors tab.
  2. Click Generate signing key. Copy it once — it can't be retrieved again. Save.

Backend endpoint

Create an authenticated endpoint that signs a short-lived JWT (HS256) using the Zendesk signing key. Required claims:

{ "external_id": "<your internal customer ID>", "scope": "user", "name": "Alice Example", "email": "alice@example.com" }

On the page where the widget loads:

zE('messenger','loginUser',(callback)=>{fetch('/your-jwt-endpoint',{credentials:'include'}).then((res)=>res.text()).then((jwt)=>callback(jwt));});

Verify it's working

  1. Open the chat widget on a page where a known customer is logged in and send a message.
  2. In Inquiru's Conversations page, open that conversation — the Customer ID field should show your internal ID, not a long sc_xxxxx string.
  3. Ask the AI something that requires the customer ID (e.g. "what was my last order?") — it should answer directly without asking for an account ID first.