new Chat()

Extends
Base

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

isMuted  number

Indicates if the chat is muted or not

isReadOnly  boolean

Indicates if the Chat is readonly

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

archive()

Archives this chat

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

Name Type Optional Description

searchOptions

Object

 

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

Values in searchOptions have the following properties:

Name Type Optional Description

limit

Number

Yes

The amount of messages to return. 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.

Defaults to 50.

Returns

Promise containing Array of Message 

async

getContact() → Promise containing Contact

Returns the Contact that corresponds to this Chat.

Returns

Promise containing Contact 

async

getLabels() → Promise containing Array of Label

Returns array of all Labels assigned to this Chat

Returns

Promise containing Array of Label 

async

markUnread()

Mark this chat as unread

async

mute(unmuteDate)

Mutes this chat until a specified date

Parameter

Name Type Optional Description

unmuteDate

Date

 

Date at which the Chat will be unmuted

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

Name Type Optional Description

content

(string, MessageMedia, or Location)

 

options

MessageSendOptions

Yes

Returns

Promise containing Message 

Message that was just sent

async

sendSeen() → Promise containing Boolean

Set the message 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

unarchive()

un-archives this chat

async

unmute()

Unmutes this chat

async

unpin() → Promise containing boolean

Unpins this chat

Returns

Promise containing boolean 

New pin state