Open chelming opened 1 year ago
aiight, I'm doing some solutioning here.
I think we can "make things better" through ~two~ three things:
x_snc_slackerbot_user
table to have a boolean for is_bot
and enable that via establish_userRemove the following two lines from the SRAPI SlackerBot Event Handler/Event
if (request.body.data.event.bot_id) return;
//gs.info('slackoff: ' + (request.body.dataString));
The first line is the only one that matters, but let's get rid of that comment anyway.
(From App Studio) Tables > User > Insert a new row... | Field | Value |
---|---|---|
Label | Is Bot | |
Type | True/False | |
Default Value | False |
Slacker script include > establish_user
Honestly, I think the easiest thing is to add a new param is_bot
on the function and set it from there since all we pass in via payload_user
is a string with the user_id.
We made it! Set a condition on the Parse chat business rule for user (show related fields) Is bot > is > True.
Points Party is currently a BR that scrapes the payload. This would likely have an adverse effect while it's in that state.
The event.message.subtype
for bot messages with URLs is message_changed
not bot_message
so I don't think bot_message
is the best place to look? Not sure, maybe it'd be good enough? We'd run in to some weird stuff if we stored that on the chats table and some bot messages had bot_message
and others didn't. It feels a little wrong.
Problem
If we want to search for a bot message we have to use CONTAINS queries on the Payloads table because they never get parsed into fields on the Chats table.
Reason it's not currently working
Bots aren't users! Well, obviously, right?
π±βπ€ NINJA EDIT π±βπ€ There's actually two issues and I think it comes down to messages with images "unfurling." By default, the SRAPI is dropping messages from bots, I believe to prevent the bots from triggering each other. It does this by checking for
event.bot_id
. The problem is that the event we are getting in the Payloads table doesn't have anevent.bot_id
, there's insteadevent.message.bot_id
andevent.previous_message.bot_id
. That "previous" is what's making me think it's due to unfurling being an event for a message "changing." (double ninja π±βπ€π±βπ€: event.subtype ismessage_changed
which solidifies my theory)back to our regularly scheduled programming... But here's where things are (edit: also π¬) going wrong... In the Convert to chat business rule we get the user using
var userSlackID = message.event.user;
. The problem is that bot information isn't stored there. We need another check specifically for bots formessage.event.message.bot_id
and then pass that intoestablish_user()
.Why do we care?
Well it's not awful but currently if we want to check if a bot message has already "triggered" we have to do all the contains queries. If we had the Chat records we could query the fields for the specific values that have already been parsed.