NEWCKEditor AI on your premises: Hook your LLM and register MCP tools. Webinar coming soon!
Sign up (with export icon)

AIChatInteractionAPI

Api-interface iconinterface

An API allowing to manipulate the AI Chat interaction while it is being streamed in the chat.

This set of helpers is dedicated to be used and available only inside AIToolEventCallback.

Properties

  • Chevron-right icon

    clearLoadingMessage : () => void

    Clears the currently displayed AI chat loading message. No text will be shown.

  • Chevron-right icon

    insertCustomElement : ( element: string | HTMLElement, id: string ) => Promise<AIChatFeedCustomElementView>

    Inserts a custom element into the AI chat feed. The element can be provided as a HTML string or as a HTMLElement.

    Passing an id is optional. When passed, it is added to the wrapping HTML element as data-cke-ai-id attribute, allowing to query it later with native DOM methods.

    Note, that the element is not immediately inserted into the UI when this method is called. Insertions are queued to ensure the element is rendered after currently processed content.

    Returns a promise which is resolved after the element is finally attached to the DOM. You can use this promise to further manage the displayed content, for example, fetch asynchronous data and display it inside the inserted element.

  • Chevron-right icon

    insertTextReply : ( content: string, id: string ) => AIReply

    Creates a new reply in the current interaction. The created reply becomes the current reply of the interaction.

    Passing an id is optional. When passed, it is added to the wrapping HTML element as data-cke-ai-id attribute, allowing to query it later with native DOM methods.

    This method allows adding custom text replies to the AI chat feed. You can pass plain text or Markdown-formatted text as the content parameter. Markdown is automatically converted to proper HTML formatting when rendered in the chat feed.

    Note, that the text reply is not immediately inserted into the UI when this method is called. Insertions are queued to ensure the reply is rendered after currently processed content.

    Note also, that the content of the reply is visually streamed in the chat feed (word by word), so it will appear gradually.

  • Chevron-right icon

    setLoadingMessage : ( message: string ) => void

    Sets the currently displayed AI chat loading message.