You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently building a bot and i'm trying to handle a message event, such that when there is a message on a channel which includes a help string the bot sends a message to a user.
I have being trying to achieve this using bot.postMessageToUser('username', 'hello i am bot', params) and it's not working 😄
I saved that expression in a variable like:
const postToUser = bot.postMessageToUser(
'hic',
'hello i am dionysus',
params
);
I used an if statement to check if it actually works:
if(postToUser){
console.log("Posted to the User");
}
Unexpectedly it logs Posted to User When it actually does not on slack
Please how can i resolve this or still achieve my goal? I'd really appreciate all the help i can get
I'm using "slackbots": "^1.2.0"
The text was updated successfully, but these errors were encountered:
I have the same problem. bot.postMessageToUser(user, message) doesn't work.
My code:
bot.on('message', data => {
if (data.type !== 'message' || data.subtype === 'bot_message') {
return;
}
handleMessage(data);
});
function handleMessage(data) {
let user = data.user; // I tried also user data.client_msg_id
console.log(`user`, user); // it shows somethings like `user UP23WKQXX`
let message = data.text;
if (message.includes(' help')) {
runHelp(user);
}
}
function runHelp(user) {
bot.postMessageToUser(user, `message`);
}
bot.postMessageToUser(user, message) doesn't work. It gives error Assertion failed: user not found.
I'm currently building a bot and i'm trying to handle a message event, such that when there is a message on a channel which includes a
help
string the bot sends a message to a user.I have being trying to achieve this using
bot.postMessageToUser('username', 'hello i am bot', params)
and it's not working 😄I saved that expression in a variable like:
I used an if statement to check if it actually works:
Unexpectedly it logs
Posted to User
When it actually does not on slackPlease how can i resolve this or still achieve my goal? I'd really appreciate all the help i can get
I'm using
"slackbots": "^1.2.0"
The text was updated successfully, but these errors were encountered: