Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface IProps<T>

Type parameters

  • T

Hierarchy

  • object
  • object
    • IProps

Index

Properties

Optional SuggestionsComponent

SuggestionsComponent: SuggestionsComponent

A component that renders at the bottom of the list, above the user input. Can be used to provide suggested inputs values. Defaults to the Suggestions component. Can be used to insert custom elements at the end of the chat.

Optional autoBlur

autoBlur: undefined | false | true

Automatically blurs the input when not prompting for a response

Optional autoDisable

autoDisable: undefined | false | true

Automatically disables the input between prompts. This prevents users from sending messages when the bot is not prompting

Optional autoFocus

autoFocus: undefined | false | true

Automatically focusses the input when prompted for a response

Optional autoHide

autoHide: undefined | false | true

Automatically hides the input when not prompting for a response. This will also hide the input when there are suggestions available.

bot

bot: string | IGuidImmutable

The unique user identification value for the chat bot

Optional initialMessages

initialMessages: MessagesImmutable<T>

A set of initial messages to populate the chat view with. Changing this after mounting will do nothing.

iterable

iterable: IAsyncIterable<T>

The chat bot iterable. Determines how to talk to bots.

Optional pauseDuration

pauseDuration: MillisecondsAccepted

Determines the length of time to pause between chat bot messages

Optional suggestionsDelay

suggestionsDelay: MillisecondsAccepted

Delays the setting of the suggestions by a time period. This will cause a delayed render if set. By default, the suggestions are rendered at the same time as the incoming message which only causes one render of the new items

Methods

Optional onData

  • onData(data: T): T
  • Invoked when a data has been received from the chat bot. Can be used modify the rendered data

    example
    Common Implementation ```ts private readonly handleData = (data: string): string => { // modify data here return data; } ```

    Parameters

    • data: T

      the data that has been received from the chat bot iterator

    Returns T

    the data to display as a message

Optional onDone

  • onDone(): Promise<void>

onInput

  • onInput(input: IInputImmutable): Promise<T>
  • Converts the incoming input into the correct data type

    Parameters

    • input: IInputImmutable

      the raw input from the user

    Returns Promise<T>

    the converted data

Optional onIteratorError

  • onIteratorError(error: Error): Promise<void>
  • Invoked when an error occurs in the iterator

    Parameters

    • error: Error

    Returns Promise<void>

Optional onLoad

  • onLoad(id: string | IGuidImmutable | undefined): Promise<MessagesImmutable<T>>
  • Invoked when previous messages should be loaded. Most recent message should be first.

    Parameters

    • id: string | IGuidImmutable | undefined

      the current oldest loaded message

    Returns Promise<MessagesImmutable<T>>

    an array of previously stored messages in historical time order

Optional onMessage

  • onMessage(message: IMessageImmutable<T>): void
  • A hook to determine when a new message has been created. Can be used to attach metadata to the message in a WeakMap. Use onSave to save new messages.

    parma

    message the message that has been created, either by the bot or user.

    Parameters

    • message: IMessageImmutable<T>

    Returns void

Optional onSave

  • onSave(messages: MessagesImmutable<T>, bot: string | IGuidImmutable): Promise<void>
  • Invoked when a message should be saved. It is assumed that the initialMessages are already saved and will never be provided to this function

    Parameters

    • messages: MessagesImmutable<T>

      the messages to save

    • bot: string | IGuidImmutable

      the current bot property

    Returns Promise<void>

Optional onSuggestions

  • onSuggestions(suggestions: SuggestionsImmutable | undefined): SuggestionsImmutable | undefined
  • Invoked when the bot has suggested answer(s). Can be used to hook into the suggestions that are rendered. The suggestions array can even be modified. This is useful to filter suggestions, client side.

    Parameters

    • suggestions: SuggestionsImmutable | undefined

      the suggested responses for the current data

    Returns SuggestionsImmutable | undefined

    the suggestions that should be rendered