Preact API
API reference
@nlxai/chat-preact
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
Name | Type | Description |
---|---|---|
config | Config | The configuration object for the chatbot. |
Returns
the hook object containing the chat state and methods.
Defined in
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
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
setInputValue
• setInputValue: (val
: string
) => void
Modify the value of the chat input field.
Type declaration
▸ (val
): void
Parameters
Name | Type | Description |
---|---|---|
val | string | The new value of the input field. |
Returns
void
Defined in
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
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.