Chat

Overview

The Chat component is an interface element designed for communicating within an application. It provides users with the ability to exchange messages with chatbots in real time.

Properties

Name
Type
Description

name

string

Component name

messages

chatMessage[]

Full array of chat messages with metadata

lastUserMessage

string

Last message entered by the user

briefMessages

briefMessage[]

Simplified message list with only role and content . Useful for integrating with ChatGPT and similar APIs.

Methods

Name
Parameters
Returns
Description

setMessages

value: { role: string; content: string; created_at: Date; id?: string; avatar?: string }[]

void

Set messages

addMessage

value: { role: string; content: string; id?: string; avatar?: string }

void

Add a new message to the messages array

upsertLastMessage

value: { role: string; content: string; id?: string; avatar?: string }

void

Insert or append to last message

updateLastMessage

value: { role: string; content: string; id?: string; avatar?: string }

void

Insert or update last message

startReceiving

-

void

Start receiving messages

stopReceiving

-

void

Stop receiving messages

Triggers

Name
Description

On Init

Triggered when the component is initialized

On Message Sent

Triggered when the user sends a message

On Stop Receiving

Triggered when message receiving is stopped

Last updated

Was this helpful?