Skip to main content
This guide takes you through the whole loop: add the widget, tell it who the customer is, start a session, and read the results.
You need an SDK API key for the widget and an API token for the reporting endpoints. Both come from the Cor team. See Authentication.

1. Install the widget

Add this snippet to your app’s HTML, ideally just before the closing </body> tag. You can also add it through a tag manager like Google Tag Manager.
<script>
  // Configure Obi.
  window.obiWidgetConfig = {
    apiKey: "your-api-key",
  };

  // Load Obi.
  !(function(){"use strict";var t=window;!(function(){var n,o;try{n=new URLSearchParams(location.search),o={},n.forEach((function(t,n){o[n]=t})),Object.keys(o).length&&localStorage.setItem("obi-url-params",JSON.stringify(o))}catch(t){}t.ObiSDK=t.ObiSDK||function(){return t.ObiSDK.q=t.ObiSDK.q||[],t.ObiSDK.q.push(arguments)},t.ObiSDK("update",t.obiWidgetConfig||{}),fetch("https://registry.npmjs.org/obi-sdk/latest").then((function(t){return t.json()})).then((function(t){return t.version})).catch((function(){return"latest"})).then((function(t){var n=document.createElement("script");n.defer=!0,n.src="https://unpkg.com/obi-sdk@"+t+"/dist/obi-sdk.standalone.iife.js",document.head.appendChild(n)}))})()})();
</script>
The widget now loads on every page. We recommend hiding it on your login page. See Controlling sessions.

2. Identify the customer

After a customer signs in, tell Obi who they are. This drives personalization, targeting, and reporting.
window.ObiSDK("update", {
  isActive: true,
  user: {
    id: "user-123",
    email: "user@example.com",
    firstName: "John",
    lastName: "Doe",
    company: "ACME",
    plan: "enterprise",
  },
});
See Identifying users for the full list of fields.

3. Start a session (optional)

Obi can start sessions automatically. To start one yourself (for example, from a “Start onboarding” button), pass the plan’s UUID:
window.ObiSDK("startSession", {
  planUuid: "<uuid-of-plan-to-start>",
});

4. Pull a report

Once a customer has run a session, fetch it from the Session Reporting API. This call is server-side and uses your API token.
curl -s -H "Authorization: Token <your-api-token>" \
  "https://app.coragents.ai/api/sessions/reporting?limit=5"
You get session metadata and a summary for each session. To download the full transcript, use the transcript endpoints.
That’s the full loop. Next, read Core concepts to learn the terms, or jump into the API reference.