The SmartSnippet controller lets you display the excerpt of a document that would be most likely to answer a particular query.

Example: smart-snippet.fn.tsx

interface SmartSnippet {
    state: SmartSnippetState;
    beginDelayedSelectInlineLink(link: InlineLink): void;
    beginDelayedSelectSource(): void;
    cancelPendingSelectInlineLink(link: InlineLink): void;
    cancelPendingSelectSource(): void;
    closeFeedbackModal(): void;
    collapse(): void;
    dislike(): void;
    expand(): void;
    like(): void;
    openFeedbackModal(): void;
    selectInlineLink(link: InlineLink): void;
    selectSource(): void;
    sendDetailedFeedback(details: string): void;
    sendFeedback(feedback: SmartSnippetFeedback): void;
    subscribe(listener: () => void): Unsubscribe;
}

Hierarchy (View Summary)

Methods

  • Prepares to select a link inside the answer after a certain delay, sending analytics if it was never selected before.

    In a DOM context, we recommend calling this method on the touchstart event.

    Parameters

    Returns void

  • Prepares to select the source after a certain delay, sending analytics if it was never selected before.

    In a DOM context, we recommend calling this method on the touchstart event.

    Returns void

  • Cancels the pending selection caused by beginDelayedSelectInlineLink.

    In a DOM context, we recommend calling this method on the touchend event.

    Parameters

    Returns void

  • Cancels the pending selection caused by beginDelayedSelectSource.

    In a DOM context, we recommend calling this method on the touchend event.

    Returns void

  • Allows the user to signal that they no longer wish to send feedback about why a particular answer was not relevant.

    Returns void

  • Collapse the snippet.

    Returns void

  • Allows the user to signal that a particular answer was not relevant.

    Returns void

  • Expand the snippet.

    Returns void

  • Allows the user to signal that a particular answer was relevant.

    Returns void

  • Allows the user to signal that they wish to send feedback about why a particular answer was not relevant.

    Returns void

  • Selects a link inside the answer, logging a UA event to the Coveo Platform if it was never selected before.

    In a DOM context, we recommend calling this method on all of the following events:

    • contextmenu
    • click
    • mouseup
    • mousedown

    Parameters

    Returns void

  • Selects the source, logging a UA event to the Coveo Platform if the source wasn't already selected before.

    In a DOM context, we recommend calling this method on all of the following events:

    • contextmenu
    • click
    • mouseup
    • mousedown

    Returns void

  • Allows the user to send detailed feedback about why a particular answer was not relevant.

    Parameters

    • details: string

      A personalized message from the end user about the relevance of the answer.

    Returns void

  • Allows the user to send feedback about why a particular answer was not relevant.

    Parameters

    Returns void

  • Adds a callback that's invoked on state change.

    Parameters

    • listener: () => void

      A callback that's invoked on state change.

    Returns Unsubscribe

    A function to remove the listener.

Properties

The state of the SmartSnippet controller.