Back to Whatsapp Web Js

whatsapp

docs/Chat.html

1.34.76.8 KB
Original Source

Properties

archivedidisGroupisLocked

isMutedisReadOnlylastMessagemuteExpiration

namepinnedtimestampunreadCount

Methods

addOrEditCustomerNote(note)archive()changeLabels(labelIds)clearMessages()clearState()delete()fetchMessages(searchOptions)getContact()

getCustomerNote()getLabels()getPinnedMessages()markUnread()mute(unmuteDate)pin()sendMessage(content[, options])sendSeen()

sendStateRecording()sendStateTyping()syncHistory()unarchive()unmute()unpin()

new Chat()

ExtendsBase

Properties

archived boolean

Indicates if the Chat is archived

id object

ID that represents the chat

isGroup boolean

Indicates if the Chat is a Group Chat

isLocked boolean

Indicates if the Chat is locked

isMuted boolean

Indicates if the chat is muted or not

isReadOnly boolean

Indicates if the Chat is readonly

lastMessage Message

Last message fo chat

muteExpiration number

Unix timestamp for when the mute expires

name string

Title of the chat

pinned boolean

Indicates if the Chat is pinned

timestamp number

Unix timestamp for when the last activity occurred

unreadCount number

Amount of messages unread

Methods

async

addOrEditCustomerNote(note) → Promise containing void

Add or edit a customer note

Parameter

NameTypeOptionalDescription

note

|

string

|

|

The note to add

|

See alsohttps://faq.whatsapp.com/1433099287594476Returns

Promise containing void

async

archive()

Archives this chat

async

changeLabels(labelIds) → Promise containing void

Add or remove labels to this Chat

Parameter

NameTypeOptionalDescription

labelIds

|

Array of (number or string)

|

| |

Returns

Promise containing void

async

clearMessages() → Promise containing boolean

Clears all messages from the chat

Returns

Promise containing boolean

result

async

clearState()

Stops typing or recording in chat immediately.

async

delete() → Promise containing Boolean

Deletes the chat

Returns

Promise containing Boolean

result

async

fetchMessages(searchOptions) → Promise containing Array of Message

Loads chat messages, sorted from earliest to latest.

Parameters

NameTypeOptionalDescription

searchOptions

|

Object

|

|

Options for searching messages. Right now only limit and fromMe is supported.

Values in searchOptions have the following properties:

NameTypeOptionalDescription

limit

|

Number

|

Yes

|

The amount of messages to return. If no limit is specified, the available messages will be returned. Note that the actual number of returned messages may be smaller if there aren't enough messages in the conversation. Set this to Infinity to load all messages.

| |

fromMe

|

Boolean

|

Yes

|

Return only messages from the bot number or vise versa. To get all messages, leave the option undefined.

|

|

Returns

Promise containing Array of Message

async

getContact() → Promise containing Contact

Returns the Contact that corresponds to this Chat.

Returns

Promise containing Contact

async

getCustomerNote() → Promise containing {chatId: string, content: string, createdAt: number, id: string, modifiedAt: number, type: string}

Get a customer note

See alsohttps://faq.whatsapp.com/1433099287594476Returns

Promise containing {chatId: string, content: string, createdAt: number, id: string, modifiedAt: number, type: string}

async

getLabels() → Promise containing Array of Label

Returns array of all Labels assigned to this Chat

Returns

Promise containing Array of Label

async

getPinnedMessages() → Promise containing Array of Message

Gets instances of all pinned messages in a chat

Returns

Promise containing Array of Message

async

markUnread()

Mark this chat as unread

async

mute(unmuteDate) → Promise containing {isMuted: boolean, muteExpiration: number}

Mutes this chat forever, unless a date is specified

Parameter

NameTypeOptionalDescription

unmuteDate

|

Date

|

|

Date when the chat will be unmuted, don't provide a value to mute forever

Value can be null.

|

Returns

Promise containing {isMuted: boolean, muteExpiration: number}

async

pin() → Promise containing boolean

Pins this chat

Returns

Promise containing boolean

New pin state. Could be false if the max number of pinned chats was reached.

async

sendMessage(content[, options]) → Promise containing Message

Send a message to this chat

Parameters

NameTypeOptionalDescription

content

|

(string, MessageMedia, or Location)

|

| | |

options

|

MessageSendOptions

|

Yes

| |

Returns

Promise containing Message

Message that was just sent

async

sendSeen() → Promise containing Boolean

Sets the chat as seen

Returns

Promise containing Boolean

result

async

sendStateRecording()

Simulate recording audio in chat. This will last for 25 seconds.

async

sendStateTyping()

Simulate typing in chat. This will last for 25 seconds.

async

syncHistory() → Promise containing boolean

Sync chat history conversation

Returns

Promise containing boolean

True if operation completed successfully, false otherwise.

async

unarchive()

un-archives this chat

async

unmute() → Promise containing {isMuted: boolean, muteExpiration: number}

Unmutes this chat

Returns

Promise containing {isMuted: boolean, muteExpiration: number}

async

unpin() → Promise containing boolean

Unpins this chat

Returns

Promise containing boolean

New pin state