Developers

React API

API reference

@nlxai/chat-react

Interfaces

References

default

Renames and re-exports useChat

Functions

useChat

useChat(config): ChatHook

A custom hook used to create fully custom chat widgets for web and mobile.

Parameters

NameTypeDescription
configConfigThe configuration object for the chatbot.

Returns

ChatHook

the hook object containing the chat state and methods.

Defined in

index.ts:53

Interfaces

Interface: ChatHook

Created by useChat.

Properties

conversationHandler

conversationHandler: ConversationHandler

Contains the full conversation handler object from the the @nlxai/chat-core package. This is mostly used for the send* methods like sendText or sendStructured, as the response subscription is handled by the hook automatically.

Defined in

index.ts:22


inputValue

inputValue: string

Hold the value of the chat input field, which is auto-cleared whenever a message is sent.

Using this field is optional and you can hold input state separately.

Defined in

index.ts:28


setInputValue

setInputValue: (val: string) => void

Modify the value of the chat input field.

Type declaration

▸ (val): void

Parameters
NameTypeDescription
valstringThe new value of the input field.
Returns

void

Defined in

index.ts:33


responses

responses: Response[]

The reactive full history of the chat messages. It contains the type: "user" | "bot" field and an associated payload. Please refer to the type definitions for a complete structure.

Defined in

index.ts:39


waiting

waiting: boolean

A reactive value that is true whenever a response from the bot is in progress, used to render a message bubble with loading dots.

Defined in

index.ts:44