Converse converse.js

Namespace: chats

chats

The "chats" namespace (used for one-on-one chats)

Source:

Methods

(static) create(jid|jids, attrsopt)

Parameters:
Name Type Attributes Description
jid|jids string | Array.<string>

An jid or array of jids

attrs object <optional>

An object containing configuration attributes.

Source:

(static) create(jids, attrsopt, model)

Parameters:
Name Type Attributes Description
jids String | Array.<String>

A JID or array of JIDs

attrs Object <optional>

An object containing configuration attributes

model Model

The type of chatbox that should be created

Source:

(static) create(jid|jids, attrsopt)

Parameters:
Name Type Attributes Description
jid|jids string | Array.<string>

An jid or array of jids

attrs object <optional>

An object containing configuration attributes.

Source:

(static) create(jids, attrsopt, model)

Parameters:
Name Type Attributes Description
jids String | Array.<String>

A JID or array of JIDs

attrs Object <optional>

An object containing configuration attributes

model Model

The type of chatbox that should be created

Source:

(static) get(jids, attrsopt, createopt) → {Promise.<_converse.ChatBox>}

Retrieves a chat or all chats.

Parameters:
Name Type Attributes Default Description
jids String | Array.<string>

e.g. 'buddy@example.com' or ['buddy1@example.com', 'buddy2@example.com']

attrs Object <optional>

Attributes to be set on the _converse.ChatBox model.

create Boolean <optional>
false

Whether the chat should be created if it's not found.

Source:
Returns:
Type
Promise.<_converse.ChatBox>
Examples
// To return a single chat, provide the JID of the contact you're chatting with in that chat:
const model = await api.chats.get('buddy@example.com');
// To return an array of chats, provide an array of JIDs:
const models = await api.chats.get(['buddy1@example.com', 'buddy2@example.com']);
// To return all open chats, call the method without any parameters::
const models = await api.chats.get();

(static) get(jids)

Parameters:
Name Type Description
jids String | Array.<String>

A JID or array of JIDs

Source:

(static) get(jids, attrsopt, createopt) → {Promise.<_converse.ChatBox>}

Retrieves a chat or all chats.

Parameters:
Name Type Attributes Default Description
jids String | Array.<string>

e.g. 'buddy@example.com' or ['buddy1@example.com', 'buddy2@example.com']

attrs Object <optional>

Attributes to be set on the _converse.ChatBox model.

create Boolean <optional>
false

Whether the chat should be created if it's not found.

Source:
Returns:
Type
Promise.<_converse.ChatBox>
Examples
// To return a single chat, provide the JID of the contact you're chatting with in that chat:
const model = await api.chats.get('buddy@example.com');
// To return an array of chats, provide an array of JIDs:
const models = await api.chats.get(['buddy1@example.com', 'buddy2@example.com']);
// To return all open chats, call the method without any parameters::
const models = await api.chats.get();

(static) get(jids)

Parameters:
Name Type Description
jids String | Array.<String>

A JID or array of JIDs

Source:

(static) open(name, attrsopt, forceopt) → {Promise}

Opens a new one-on-one chat.

Parameters:
Name Type Attributes Default Description
name String | Array.<string>

e.g. 'buddy@example.com' or ['buddy1@example.com', 'buddy2@example.com']

attrs Object <optional>

Attributes to be set on the _converse.ChatBox model.

Properties
Name Type Attributes Description
minimized Boolean <optional>

Should the chat be created in minimized state.

force Boolean <optional>
false

By default, a minimized chat won't be maximized (in overlayed view mode) and in fullscreen view mode a newly opened chat won't replace another chat already in the foreground. Set force to true if you want to force the chat to be maximized or shown.

Source:
Returns:

Promise which resolves with the _converse.ChatBox representing the chat.

Type
Promise
Examples
// To open a single chat, provide the JID of the contact you're chatting with in that chat:
converse.plugins.add('myplugin', {
    initialize: function() {
        const _converse = this._converse;
        // Note, buddy@example.org must be in your contacts roster!
        api.chats.open('buddy@example.com').then(chat => {
            // Now you can do something with the chat model
        });
    }
});
// To open an array of chats, provide an array of JIDs:
converse.plugins.add('myplugin', {
    initialize: function () {
        const _converse = this._converse;
        // Note, these users must first be in your contacts roster!
        api.chats.open(['buddy1@example.com', 'buddy2@example.com']).then(chats => {
            // Now you can do something with the chat models
        });
    }
});

(static) open(name, attrsopt, forceopt) → {Promise}

Opens a new one-on-one chat.

Parameters:
Name Type Attributes Default Description
name String | Array.<string>

e.g. 'buddy@example.com' or ['buddy1@example.com', 'buddy2@example.com']

attrs Object <optional>

Attributes to be set on the _converse.ChatBox model.

Properties
Name Type Attributes Description
minimized Boolean <optional>

Should the chat be created in minimized state.

force Boolean <optional>
false

By default, a minimized chat won't be maximized (in overlayed view mode) and in fullscreen view mode a newly opened chat won't replace another chat already in the foreground. Set force to true if you want to force the chat to be maximized or shown.

Source:
Returns:

Promise which resolves with the _converse.ChatBox representing the chat.

Type
Promise
Examples
// To open a single chat, provide the JID of the contact you're chatting with in that chat:
converse.plugins.add('myplugin', {
    initialize: function() {
        const _converse = this._converse;
        // Note, buddy@example.org must be in your contacts roster!
        api.chats.open('buddy@example.com').then(chat => {
            // Now you can do something with the chat model
        });
    }
});
// To open an array of chats, provide an array of JIDs:
converse.plugins.add('myplugin', {
    initialize: function () {
        const _converse = this._converse;
        // Note, these users must first be in your contacts roster!
        api.chats.open(['buddy1@example.com', 'buddy2@example.com']).then(chats => {
            // Now you can do something with the chat models
        });
    }
});

chats

The "chats" namespace (used for one-on-one chats)

Source:

Methods

(static) create(jid|jids, attrsopt)

Parameters:
Name Type Attributes Description
jid|jids string | Array.<string>

An jid or array of jids

attrs object <optional>

An object containing configuration attributes.

Source:

(static) create(jids, attrsopt, model)

Parameters:
Name Type Attributes Description
jids String | Array.<String>

A JID or array of JIDs

attrs Object <optional>

An object containing configuration attributes

model Model

The type of chatbox that should be created

Source:

(static) create(jid|jids, attrsopt)

Parameters:
Name Type Attributes Description
jid|jids string | Array.<string>

An jid or array of jids

attrs object <optional>

An object containing configuration attributes.

Source:

(static) create(jids, attrsopt, model)

Parameters:
Name Type Attributes Description
jids String | Array.<String>

A JID or array of JIDs

attrs Object <optional>

An object containing configuration attributes

model Model

The type of chatbox that should be created

Source:

(static) get(jids, attrsopt, createopt) → {Promise.<_converse.ChatBox>}

Retrieves a chat or all chats.

Parameters:
Name Type Attributes Default Description
jids String | Array.<string>

e.g. 'buddy@example.com' or ['buddy1@example.com', 'buddy2@example.com']

attrs Object <optional>

Attributes to be set on the _converse.ChatBox model.

create Boolean <optional>
false

Whether the chat should be created if it's not found.

Source:
Returns:
Type
Promise.<_converse.ChatBox>
Examples
// To return a single chat, provide the JID of the contact you're chatting with in that chat:
const model = await api.chats.get('buddy@example.com');
// To return an array of chats, provide an array of JIDs:
const models = await api.chats.get(['buddy1@example.com', 'buddy2@example.com']);
// To return all open chats, call the method without any parameters::
const models = await api.chats.get();

(static) get(jids)

Parameters:
Name Type Description
jids String | Array.<String>

A JID or array of JIDs

Source:

(static) get(jids, attrsopt, createopt) → {Promise.<_converse.ChatBox>}

Retrieves a chat or all chats.

Parameters:
Name Type Attributes Default Description
jids String | Array.<string>

e.g. 'buddy@example.com' or ['buddy1@example.com', 'buddy2@example.com']

attrs Object <optional>

Attributes to be set on the _converse.ChatBox model.

create Boolean <optional>
false

Whether the chat should be created if it's not found.

Source:
Returns:
Type
Promise.<_converse.ChatBox>
Examples
// To return a single chat, provide the JID of the contact you're chatting with in that chat:
const model = await api.chats.get('buddy@example.com');
// To return an array of chats, provide an array of JIDs:
const models = await api.chats.get(['buddy1@example.com', 'buddy2@example.com']);
// To return all open chats, call the method without any parameters::
const models = await api.chats.get();

(static) get(jids)

Parameters:
Name Type Description
jids String | Array.<String>

A JID or array of JIDs

Source:

(static) open(name, attrsopt, forceopt) → {Promise}

Opens a new one-on-one chat.

Parameters:
Name Type Attributes Default Description
name String | Array.<string>

e.g. 'buddy@example.com' or ['buddy1@example.com', 'buddy2@example.com']

attrs Object <optional>

Attributes to be set on the _converse.ChatBox model.

Properties
Name Type Attributes Description
minimized Boolean <optional>

Should the chat be created in minimized state.

force Boolean <optional>
false

By default, a minimized chat won't be maximized (in overlayed view mode) and in fullscreen view mode a newly opened chat won't replace another chat already in the foreground. Set force to true if you want to force the chat to be maximized or shown.

Source:
Returns:

Promise which resolves with the _converse.ChatBox representing the chat.

Type
Promise
Examples
// To open a single chat, provide the JID of the contact you're chatting with in that chat:
converse.plugins.add('myplugin', {
    initialize: function() {
        const _converse = this._converse;
        // Note, buddy@example.org must be in your contacts roster!
        api.chats.open('buddy@example.com').then(chat => {
            // Now you can do something with the chat model
        });
    }
});
// To open an array of chats, provide an array of JIDs:
converse.plugins.add('myplugin', {
    initialize: function () {
        const _converse = this._converse;
        // Note, these users must first be in your contacts roster!
        api.chats.open(['buddy1@example.com', 'buddy2@example.com']).then(chats => {
            // Now you can do something with the chat models
        });
    }
});

(static) open(name, attrsopt, forceopt) → {Promise}

Opens a new one-on-one chat.

Parameters:
Name Type Attributes Default Description
name String | Array.<string>

e.g. 'buddy@example.com' or ['buddy1@example.com', 'buddy2@example.com']

attrs Object <optional>

Attributes to be set on the _converse.ChatBox model.

Properties
Name Type Attributes Description
minimized Boolean <optional>

Should the chat be created in minimized state.

force Boolean <optional>
false

By default, a minimized chat won't be maximized (in overlayed view mode) and in fullscreen view mode a newly opened chat won't replace another chat already in the foreground. Set force to true if you want to force the chat to be maximized or shown.

Source:
Returns:

Promise which resolves with the _converse.ChatBox representing the chat.

Type
Promise
Examples
// To open a single chat, provide the JID of the contact you're chatting with in that chat:
converse.plugins.add('myplugin', {
    initialize: function() {
        const _converse = this._converse;
        // Note, buddy@example.org must be in your contacts roster!
        api.chats.open('buddy@example.com').then(chat => {
            // Now you can do something with the chat model
        });
    }
});
// To open an array of chats, provide an array of JIDs:
converse.plugins.add('myplugin', {
    initialize: function () {
        const _converse = this._converse;
        // Note, these users must first be in your contacts roster!
        api.chats.open(['buddy1@example.com', 'buddy2@example.com']).then(chats => {
            // Now you can do something with the chat models
        });
    }
});