ruLog in to Senler

Message Context

Use contextItems for one question. For the current page, pass page context.

Pass only data this visitor is allowed to see. Do not include secrets, tokens, or payment data. Context does not grant permission to perform actions.

Add the Object for This Question

Pass contextItems when opening chat for a specific entity or action:

SenlerWidget.open({
  contextItems: [
    {
      id: "order:123",
      kind: "order",
      role: "business_context",
      display: {
        label: "Order #123",
        subtitle: "Open card",
      },
      ref: {
        entity_type: "order",
        entity_id: "123",
        route: "/orders/123",
      },
      snapshot: {
        status: "awaiting_payment",
        total: "$49.00",
      },
      payload: {
        available_actions: ["pay", "cancel"],
      },
    },
  ],
  message: {
    text: "Describe what I can do with this order.",
    startNewDialog: true,
    autoSend: true,
  },
});

In this example, the visitor sees an “Order #123” chip, while the order ID, route, state, and available actions are included with the question. These are data for the answer, not permission to perform payment or cancellation. One-time context is cleared only after a successful send. Persistent page context remains available for later messages.

Object fields and merging rules are listed in the context item format.

Selected Element Context

An element selected through features.element_selection is added as an ordinary item with the selected_element type. Do not pass it again through contextItems.

Add data-ai-* attributes to page elements so the context has a clear label, purpose, and documentation link. See Site Element Markup and Highlighting and Actions.