Is there any way to send a message automatically, I found a sendMessage trigger but it doesn't work, maybe I am doing wrong something
export const msgUser = (viewerChannelCredentials: any) => {
const {username, channel} = viewerChannelCredentials;
window.converse.plugins.add('msg-user', {
dependencies: [],
initialize: async function () {
const _converse = this._converse;
return _converse.api.trigger('sendMessage', {
chatbox: _converse.ChatBox | _converse.ChatRoom,
message: 'abc',
});
},
});
};
Another solution found that also doesn't work, it throws an error which Cannot read properties of undefined (reading '$msg')
export const msgUser = (viewerChannelCredentials: any) => {
const {username, channel} = viewerChannelCredentials;
window.converse.plugins.add('msg-user', {
dependencies: [],
initialize: async function () {
const _converse = this._converse;
var msg = _converse.env.$msg({
from: 'juliet@example.com/balcony',
to: 'romeo@example.net',
type: 'chat',
});
_converse.send(msg);
},
});
};