I am using converse.js to provide chat functionality. I am looking for a way to send some messages thru the API based on other buttons in the rest of the system.
var chat = converse.chats.open(jid);
chat.open();
chat.sendMessage(message);
chat.sendMessage() fails because the chatbox that has been returned only has limited functionality. https://conversejs.org/docs/html/development.html#the-chats-grouping
Should I override the wrappedChatBox functionality or is there a cleaner way to send a message? https://github.com/jcbrand/converse.js/blob/0746f2aa682b3a03a5c04a94570352e6921cde86/src/converse-core.js#L273
This is probably a bit more lower-level than you'd like, but you can send message stanzas via converse.send(stanza);
So, to send a chat message:
var msg = converse.env.$msg({
from: 'juliet@example.com/balcony',
to:'romeo@example.net',
type:'chat'
});
converse.send(msg);
That said, I think the wrapper can be extended to add a send
method there as well (check in next release).