Reputation: 1002
Is it possible to send a direct message from my RocketChat Account to another account using RocketChat API (RocketChat Rest API)?
I've looked around the API documentation but I didn't find what I need.
Upvotes: 2
Views: 2410
Reputation: 1002
I used code below:
let RocketChat = require('rocketchat-nodejs').Client;
let Client = new RocketChat({
host: 'myHost',
port: 80,
scheme: 'http',
username: 'myUser',
password: 'myPass'
});
let Authentication = Client.Authentication();
let Users = Client.Users();
let Chat = Client.Chat();
Client.login().then(() => {
Authentication.me().then((result) => {
Users.list({ userId: 'muUser' }).then((result) => {
var list = result;
Chat.postMessage({ roomId: list.users[0]._id, text: 'test'})
.then((result) => {
})
});
});
}).catch((error) => {
console.log(error);
});
Upvotes: 2