Skip to content
Documentation /

Connect signed-in accounts

Connect signed-in users to Summer AI Messenger with short-lived, server-signed identity assertions. Set up the callback, key storage, renewal and logout.

This pageView Markdown ↗Download .md
Entire libraryView llms-full.txt ↗Download all docs

Your application owns the login. Summer AI accepts a short-lived statement signed by your server, scoped to one installation and the widget's current challenge. You can use your existing account IDs; they do not need to be Rebody IDs or UUIDs.

Keep the signing key on your server

Summer AI shows a new installation's signing key once. Store it in your server's secret manager alongside its installation ID and key ID. Never return the key to the browser or add it to a public environment variable. Key rotation invalidates existing widget sessions.

You supply this Summer AI signing key to your own backend. You do not need to supply clinical-system API keys to Summer AI for this integration.

Add the browser callback

Replace YOUR_INSTALLATION_UUID with your installation ID. See Find your installation ID.

html
<script>
window.summerMessengerConfig = {
  installationId: "YOUR_INSTALLATION_UUID",
  getIdentityAssertion: async ({ nonce }) => {
    const response = await fetch("/api/summer/identity", {
      method: "POST",
      credentials: "same-origin",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({ frame_nonce: nonce })
    });
    if (!response.ok) throw new Error("Identity unavailable");
    const result = await response.json();
    if (result.kind === "guest") return null;
    if (result.kind !== "authenticated" || typeof result.assertion !== "string") {
      throw new Error("Invalid identity response");
    }
    return result.assertion;
  }
};
</script>
<script src="https://gosummer.ai/messenger/v1/loader.js" async></script>

Implement the server endpoint

Check same-origin requests and verify your application's current login using your authentication library. Accept the frame nonce, not a browser-supplied user ID. Derive the account ID, session ID and session expiry from the verified login.

Return { "kind": "guest" } only when no login is present. An invalid login, failed refresh or authentication-service error must return an error, not silently become a visitor.

Send Cache-Control: private, no-store on guest and authenticated responses, and exclude this endpoint from CDN or application response caching. Each authenticated response contains a fresh assertion for that request's nonce and login.

Create an HS256 JWT with this header and payload:

json
{
  "alg": "HS256",
  "typ": "JWT",
  "kid": "YOUR_KEY_UUID"
}
json
{
  "iss": "summer-installation:YOUR_INSTALLATION_UUID",
  "aud": "summer-messenger:customer-session:v1",
  "installation_id": "YOUR_INSTALLATION_UUID",
  "identity_namespace": "host-account",
  "sub": "YOUR_STABLE_ACCOUNT_ID",
  "host_session_ref": "SHA256_OF_INSTALLATION_AND_SESSION_ID",
  "host_session_expires_at": 1792458000,
  "parent_origin": "https://www.example.com",
  "frame_nonce": "THE_NONCE_FROM_THE_WIDGET",
  "iat": 1792454400,
  "exp": 1792454460,
  "jti": "A_FRESH_RANDOM_UUID"
}

The timestamps above show the format only. Generate current Unix timestamps in seconds: iat is now, exp is now plus 60 seconds, and host_session_expires_at comes from your actual login. Use a cryptographic random UUID for each jti.

sub is a stable opaque account ID, 1 to 256 characters. Avoid email addresses and medical information. host_session_ref is a lowercase SHA-256 hex digest of your installation ID and actual session ID. parent_origin comes from trusted server configuration and must exactly match an allowed website origin. Validate the browser's nonce against ^[A-Za-z0-9_-]{32,128}$ before signing.

Node.js signing example

After you have verified the login and validated the nonce, construct the payload above and sign it using Node's built-in crypto library:

js
import { createHmac, createHash, randomUUID } from "node:crypto";

const now = Math.floor(Date.now() / 1000);
const payload = {
  iss: `summer-installation:${installationId}`,
  aud: "summer-messenger:customer-session:v1",
  installation_id: installationId,
  identity_namespace: "host-account",
  sub: verifiedUser.id,
  host_session_ref: createHash("sha256")
    .update(`${installationId}:${verifiedSession.id}`).digest("hex"),
  host_session_expires_at: verifiedSession.expiresAtSeconds,
  parent_origin: configuredWebsiteOrigin,
  frame_nonce: validatedNonce,
  iat: now,
  exp: now + 60,
  jti: randomUUID()
};
const encode = value => Buffer.from(JSON.stringify(value)).toString("base64url");
const data = `${encode({ alg: "HS256", typ: "JWT", kid: keyId })}.${encode(payload)}`;
const signature = createHmac("sha256", signingKey).update(data).digest("base64url");
const assertion = `${data}.${signature}`;
// Return { kind: "authenticated", assertion } with Cache-Control: private, no-store.

The variables beginning with verified must come from your server's authenticated session. They are not fields to accept from the request body. For patient-specific links, add the optional care context before signing.

Bind an external customer account (optional)

For an external company's private administrative account context, the authenticated host may add customer_ref to the signed payload. It is the UUID of an active Summer customer record in this installation's company and environment. Create or update those records through customers.save; search discovery leads through customers.search in the API, CLI or MCP.

Your server must derive the reference from its saved mapping for the authenticated account. Never accept it from browser input, a typed email or phone, a selected search result, or a customer-supplied order number. A saved contact or staff case association does not verify identity. customer_ref is supported only for the host-account namespace, and Summer rejects another company's or environment's record. It is separate from sub, which remains the stable opaque host subject.

Summer exposes only owned administrative observations from currently verified provider connections. It does not expose raw clinical content or infer that an empty result means no orders exist. Bask reads still require a verified supported Bask integration. Session revocation, expiry, key rotation, a disabled installation or removing the signed reference ends access through this context. Refreshes must carry the reference again when continued access is intended.

Show your team who is writing (optional)

sub is opaque, so the inbox shows a signed-in person as "Customer". To show their name, add an optional profile object to the payload before signing:

json
"profile": { "name": "Pat Lee", "email": "pat@clinic.example", "company": "Clinic" }

Every field is optional. Each value is plain text of 1 to 200 characters, with no leading or trailing spaces and no line breaks. email must be an email address. Leave out a field you do not know. Do not send an empty object.

Your team sees the name, or the email when there is no name, in the inbox list. The conversation's Customer panel shows the email and company, and inbox search matches them. Summer AI saves the profile from the latest sign-in. A sign-in without profile clears the saved details.

These details only label the conversation. They do not prove who the person is, do not link the person to other records, and are not used to sign in. Take them from your verified login, never from the browser. Leave out medical information.

Login changes and renewal

After login or an account switch, call await window.SummerMessenger.refreshIdentity(). This method shuts down the previous widget session, clears its visible conversation, and boots the same configuration against the current host login. Handle a rejected refresh in your website UI.

For logout, call await window.SummerMessenger.shutdown() before clearing the host session. The result is { revoked: true } when Summer AI confirmed revocation, or { revoked: false } when it could not confirm it. In either case, the old frame and its local state are removed. Your logout flow should complete its own session invalidation and handle the unconfirmed widget revocation without claiming it succeeded.

shutdown() also clears the widget configuration. To show a visitor widget after logout, explicitly call window.SummerMessenger.boot(window.summerMessengerConfig) after the host logout completes. Do this only if your installation allows visitors. Calling refreshIdentity() after shutdown() fails because there is no active configuration to refresh.

The widget automatically requests fresh identity while open as its short session expires. Your endpoint must check the current login each time. A visitor widget also checks the callback again when reopened or when the website tab regains focus. If the host now returns an authenticated assertion, Summer AI starts a fresh verified session and loads that account's conversation. If the host still returns null, the prepared visitor chat and unsent form stay in place. Contact registration and follow-up forms appear only in visitor sessions; signed-in customers can message directly.

Rebody uses a reserved built-in adapter. Other companies use host-account; do not copy Rebody's namespace or endpoints.

UP NEXTClinician chat and account links →