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:

const result = await SenlerWidget.ask({
  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"],
      },
    },
  ],
  text: "Describe what I can do with this order.",
  newDialog: true,
});
SenlerWidget.selectDialog(result.dialogId);
SenlerWidget.open();

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 belongs to this message and is preserved when retrying its send. Persistent page context remains available for later messages.

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

Selected Element Context

When sending from the composer, an element selected through features.element_selection is automatically added with the selected_element type. A programmatic ask() does not pick up the selected element from the chat UI: pass the required information explicitly in that request's 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.