slack-bot-api
slack-bot-api copied to clipboard
Cannot subscribe to the event when a user joins or leaves a channel
instead getting an error with this JSON in response {"type":"error","error":{"msg":"invalid message type: null","code":3,"source":"gs-bom-hhur"}}
I also keep getting this strange bot message to onMessage. Any clue why this might be ?
2019-08-20T15:21:24.460Z bot onMessage was called
2019-08-20T15:21:24.460Z bot msg:{"type":"error","error":{"msg":"invalid message type: null","code":3,"source":"gs-iad-4jhr"}}
2019-08-20T15:21:49.608Z bot onMessage was called
2019-08-20T15:21:49.608Z bot msg:{"type":"error","error":{"msg":"invalid message type: null","code":3,"source":"gs-iad-4jhr"}}
2019-08-20T15:22:14.460Z bot onMessage was called
2019-08-20T15:22:14.460Z bot msg:{"type":"error","error":{"msg":"invalid message type: null","code":3,"source":"gs-iad-4jhr"}}
2019-08-20T15:22:39.465Z bot onMessage was called
2019-08-20T15:22:39.465Z bot msg:{"type":"error","error":{"msg":"invalid message type: null","code":3,"source":"gs-iad-4jhr"}}
2019-08-20T15:23:04.461Z bot onMessage was called
2019-08-20T15:23:04.461Z bot msg:{"type":"error","error":{"msg":"invalid message type: null","code":3,"source":"gs-iad-4jhr"}}
2019-08-20T15:23:29.462Z bot onMessage was called
2019-08-20T15:23:29.462Z bot msg:{"type":"error","error":{"msg":"invalid message type: null","code":3,"source":"gs-iad-4jhr"}}
receiving same error many times too:
{ type: 'error', error: { msg: 'invalid message type: null', code: 3, source: 'gs-gru-3ydt' } }
Was anyone able to figure this out? I've been trying to subscribe to _join events and none appear to work. I am trying to capture when a user joins the general channel or others but never seems to trigger:
if (data.subtype !== 'bot_message') {
if (data.type === 'message') {
if (data.subtype == 'member_joined_channel') {
console.log('member join subtype');
console.log(data);
const params = {
icon_emoji: ':information_source:',
};
bot.postMessage(notifications_channel_id, 'NEW CHANNEL JOIN: member_joined_channel subtype triggered' , params);
}
if (data.subtype == 'team_join') {
console.log('member join team_join subtype');
console.log(data);
const params = {
icon_emoji: ':information_source:',
};
bot.postMessage(notifications_channel_id, 'NEW CHANNEL JOIN: team_join subtype triggered' , params);
}
if (data.subtype == 'channel_join') {
console.log('channel_join join subtype');
console.log(data);
const params = {
icon_emoji: ':information_source:',
};
bot.postMessage(notifications_channel_id, 'NEW CHANNEL JOIN: channel_join subtype triggered' , params);
}
.....................
Thank you!