Converse opening a chat from API
by JC Brand
HTML
<script src="https://cdn.conversejs.org/dist/converse.js"></script>
<link rel="stylesheet" href="https://cdn.conversejs.org/css/converse.min.css">
JavaScript
converse.plugins.add('myplugin', {
initialize: function() {
var _converse = this._converse;
Promise.all([
_converse.api.waitUntil('rosterContactsFetched'),
_converse.api.waitUntil('chatBoxesFetched')
]).then(function() {
// Note, [email protected] must be in your contacts roster!
_converse.api.chats.open('[email protected]');
});
}
});
converse.initialize({
bosh_service_url: 'https://conversejs.org/http-bind/',
show_controlbox_by_default: true,
whitelisted_plugins: ['myplugin'],
debug: true
});