Client

forsta.messenger. Client

The Forsta messenger client class.

Constructor

new Client(el, auth, optionsopt)

Source:
Example
const client = new forsta.messenger.Client(document.querySelector('#myDivId'),
                                           {orgEphemeralToken: 'secret'});
Parameters:
Name Type Attributes Description
el Element

Element where the messenger should be loaded. https://developer.mozilla.org/en-US/docs/Web/API/Element

auth ClientAuth

Auth configuration for Forsta user account.

options ClientOptions <optional>
Fires:

Methods

addEventListener(event, callback)

Source:

Add an event listener.

Parameters:
Name Type Description
event string

Name of the event to listen to.

callback function

Callback function to invoke.

Source:

Expand or collapse the navigation panel.

Parameters:
Name Type Attributes Description
collapse bool <optional>

Force the desired collapse state.

removeEventListener(event, callback)

Source:

Remove an event listener.

Parameters:
Name Type Description
event string

Name of the event to stop listening to.

callback function

Callback function used with addEventListener.

(async) threadAddMember(id, userId) → {TagExpression}

Source:

Add a user ID to a thread's distribution.

Parameters:
Name Type Description
id ThreadID

The thread ID to alter.

userId UserID

User ID to add to the thread's distribution.

Returns:
  • The updated tag expression.
Type
TagExpression

(async) threadAmendDistribution(id, expression) → {TagExpression}

Source:

Amend the distribution of a thread by adding tag expressions to it.

Parameters:
Name Type Description
id ThreadID

The thread ID to alter.

expression TagExpression

Snip of valid tag expression to add to the thread.

Returns:
  • The updated tag expression.
Type
TagExpression

(async) threadArchive(id)

Source:

Archive a thread.

Parameters:
Name Type Description
id ThreadID

The thread ID to archive.

(async) threadDestroyMessages(id)

Source:

Delete local copy of messages for a thread.

Parameters:
Name Type Description
id ThreadID

The thread ID to delete messages from.

(async) threadEnsure(expression, attrsopt) → {string}

Source:

Ensure that a thread exists matching the expression argument.

Parameters:
Name Type Attributes Description
expression TagExpression

The thread distribution to match on or create.

attrs ThreadAttributes <optional>

Optional attributes to be applied to the resulting thread.

Returns:

The thread ID created or matching the expression provided.

Type
string

(async) threadExpunge(id)

Source:

Expunging a thread deletes it and all its messages forever.

Parameters:
Name Type Description
id ThreadID

The thread ID to expunge.

(async) threadGetAttribute(id, attr) → {*}

Source:

Get the value of a thread attribute.

Parameters:
Name Type Description
id ThreadID

The thread ID to update.

attr string

The thread attribute to get.

Returns:
  • The value of the thread attribute.
Type
*

(async) threadLeave(id)

Source:

Leave a thread. I.e. remove yourself from a thread's distribution.

Parameters:
Name Type Description
id ThreadID

The thread ID to alter.

(async) threadList() → {Array.<string>}

Source:

List threads known to this client.

Returns:
  • List of thread IDs.
Type
Array.<string>

(async) threadListAttributes(id) → {Array.<string>}

Source:

List the attributes of a thread.

Parameters:
Name Type Description
id ThreadID

The thread ID to update.

Returns:
  • List of thread attibutes.
Type
Array.<string>

(async) threadMake(expression, attrsopt) → {string}

Source:

Make a new thread.

Parameters:
Name Type Attributes Description
expression TagExpression

The thread distribution to create.

attrs ThreadAttributes <optional>

Optional attributes to be applied to the resulting thread.

Returns:

The thread ID created or matching the expression provided.

Type
string

(async) threadOpen(id)

Source:

Open a thread by its ID.

Parameters:
Name Type Description
id string

The thread ID to open.

(async) threadRemoveMember(id, userId) → {TagExpression}

Source:

Remove a user ID from a thread's distribution.

Parameters:
Name Type Description
id ThreadID

The thread ID to alter.

userId UserID

User ID to remove from the thread's distribution.

Returns:
  • The updated tag expression.
Type
TagExpression

(async) threadRepealDistribution(id, expression) → {TagExpression}

Source:

Repeal a subset of a thread's distribution.

Parameters:
Name Type Description
id ThreadID

The thread ID to alter.

expression TagExpression

Snip of valid tag expression to repeal from the thread.

Returns:
  • The updated tag expression.
Type
TagExpression

(async) threadRestore(id)

Source:

Restore an archived thread to normal status.

Parameters:
Name Type Description
id ThreadID

The thread ID to restore from the archives.

(async) threadSendControl(id, data, attachmentsopt, optionsopt) → {string}

Source:

Send a control message to a thread.

Parameters:
Name Type Attributes Description
id ThreadID

The thread ID to send a message to.

data Object

Object containing the control information. Read external:ExchangePayload for more information on control messages.

attachments Array <optional>

Array of attachment objects.

options Object <optional>

Send options.

Returns:
  • The ID of the message sent.
Type
string

(async) threadSendMessage(id, plainText, htmlopt, attachmentsopt, attrsopt, optionsopt) → {string}

Source:

Send a message to a thread.

Parameters:
Name Type Attributes Description
id ThreadID

The thread ID to send a message to.

plainText string

Plain text message to send.

html string <optional>

HTML version of message to send.

attachments Array <optional>

Array of attachment objects.

attrs Object <optional>

Message attributes.

options Object <optional>

Send options.

Returns:
  • The ID of the message sent.
Type
string

(async) threadSendUpdate(id, updates, optionsopt)

Source:

Send a thread update to members of a thread.

Parameters:
Name Type Attributes Description
id ThreadID

The thread ID to send a message to.

updates Object

Object containing the update key/value pairs. See the threadUpdate section of external:ExchangePayload for details.

options Object <optional>

Options for the thread update.

(async) threadSetAttribute(id, attr, value)

Source:

Set the value of a thread attribute.

Parameters:
Name Type Description
id ThreadID

The thread ID to update.

attr string

The thread attribute to update.

value *

The value to set.

(async) threadSetExpiration(id, expiration)

Source:

Set the expiration time for messages in a thread. When this value is set to a non-zero value, messages will expire from the thread after they are read. Set this value to 0 to disable the expiration behavior.

Parameters:
Name Type Description
id string

The thread ID to update.

expiration number

Expiration time in seconds. The expiration timer starts when the message is read by the recipient.

(async) threadStartWithExpression(expression, attrsopt) → {string}

Source:

Select or create a thread. If the tag expression argument matches an existing thread it will be opened, otherwise a new thread will be created.

Parameters:
Name Type Attributes Description
expression TagExpression

The thread distribution to match on or create.

attrs ThreadAttributes <optional>

Optional attributes to be applied to the resulting thread.

Returns:

The thread ID that was opened or created.

Type
string