When Context Is Sent to the Agent

Last updated: August 11, 2026

Dynamic Context is attached when Docket creates a new conversation. Set or reset context before that request begins.

Context Lifecycle

Stage

What happens

setContext()

The widget validates the object, encrypts it, and stores the pending payload in the browser.

Conversation creation

The widget includes the pending encrypted payload as dynamic_context.

Successful acknowledgement

Docket stores the new conversation ID and clears the pending browser buffer.

Failed conversation request

The widget keeps the pending buffer so the request can be retried.

Active conversation

Calling setContext() does not alter the conversation already in progress. The new payload is available to a later conversation.

Correct Sequence

const result = await window.AISeller.setContext({
  name: "Jordan",
  company: "Northstar Labs"
});

if (result.success) {
  window.AISeller.showAndConnect();
} else {
  console.warn(result.message);
}

Wait for setContext() to finish and confirm success: true before starting the conversation.

Common Timing Patterns

Scenario

When to set context

Logged-in visitor

After identity data is available and before the visitor starts the agent.

Form submission

After successful field validation and before showAndConnect().

Standalone or iframe URL

Include ctx_ parameters in the URL before loading the agent page.

Visitor logout

Call resetContext() before another visitor can start a conversation.

Single-page application route change

Set the complete new context object before starting the next conversation.

Verify the Timing

  1. Open the deployed experience in a private browser window.

  2. Call setContext() and inspect the resolved result.

  3. Confirm success is true before starting the conversation.

  4. Start the conversation and verify the expected value is used.

  5. Call setContext() again during the active conversation and confirm it does not rewrite that conversation's starting context.

  6. Start a new conversation and confirm the new payload is used.

Related Articles