I'm working on slack bot that will generate some creds for users, so it must be asked and reply in direct messages only.
It works with message.im Slack event, but event is triggered twice - when user asks bot AND when bot replies:
I have a trap for second event in my code:
if "subtype" in SLACK_EVENT["event"]:
print('Ignore bot event..')
exit(0)
..but I'd like to get rid of that.
Can I somehow combine (add AND condition) message.im with app_mention?
So user will send IM to bot and only of bot was mentioned event will raise?
That is not possible. If you are only interested to a subset of message.im events you need to filter them out in your code as you suggested.
Related
i'm new to slack programing so bear with me.
In my company we have slack bot that users can use to alert other users, by posting an alert in one slack channel relevant user will get alerted in other channel. The problem is that user that was alerted don't know from which channel or thread the alert originated and have to manually search multiple channels.
The question is how can i accomplish this so that the user will get alerted and in addition get link to channel or thread where the alert was triggered from.
It depends on how users trigger alters, but you'll usually get a Channel ID in the payload from Slack.
When you're alerting the other users, if you include that channel ID in the message, but wrap it <#[channelid]> e.g. <#CHJ9HDXE1>, then the Slack clients will convert that into a link to the channel, or you could also use chat.getPermalink to convert a message_ts into a clickable link.
I am running the sample from
https://learn.microsoft.com/en-us/samples/officedev/microsoft-teams-samples/calling-and-meeting-bot-sample-v4/
Which allows Teams calls to be made to and from a BOT.
It all works fine and I can see there are /callback events firing for the state changes in the calls. For example a request to call a user results in the user being called at his Teams application, and the states of the call being updated in the BOT
from Establishing->Established and then to
Terminated when one end hangs the call up.
However the Participants collection of the call is not being set. There is no participant information in the callback JSON, and if I try to poll for participants using :
graphServiceClient.Communications.Calls[callid].Participants
.Request()
.GetAsync();
that collection comes back as null.
I need to put one of the call parties on Hold and cannot do this without a participant id.
What am I missing ?
Any suggestions please ?
When using the Events Webhook API, there is an event called group_close (also has im_close for im conversations). What does this mean? ie: what does it take on the Slack client to get this event to trigger? Slack's documentation on this is pretty minimal:
The group_close event is sent to all connections for a user when a private channel is closed by that user.
source: https://api.slack.com/events/group_close
I tried /close command and it just archives the group/im conversation. Is this an outdated event that is no longer relevant? I know it still gets called, but as far as I can tell, it's identical to archive.
The group_close events refers to a multi-person DM (this should be corrected in the documentation). You can close an MPDM and trigger the event by clicking the x next to the conversation on side bar or running the /close slash command like you did. This doesn't actually archive the channel just removes it from your sidebar. You should be able to re-open it.
When a slack user send my bot a message, my bot will reply with buttons. the button will utilize slack interactive message.
When user click on one of that buttons, the bot will replace the message with several texts and attachments.
my problem is that interactive message trigger scroll down to the end. how can I keep slack app not scrolling down when bot replying a message?
You can't.
You have very little control of how the Slack UI is rendering your message. And Slack will always render a new message at the bottom of a channel, which is why your updated message "scrolls down".
In general this is a feature, since Slack is made to be 100% platform agnostic and your apps will work just as well on e.g. browser, windows client or iPhone app.
I'm looking to have a user type something like
/makemeeting today # 4:00pm
this fires a outgoing webhook, which stores the info, then it fires a incoming webhook which would display a message in a channel saying meeting scheduled, and have two links
yes | no
Here's where I'm stuck. I can do everything up till this point. I'd love for any user to be able to click on one of those links and have it perform another outgoing webhook with the proper response.
I know I can just make those links point to a website, but I'd love to keep it all within slack without having to open a browser.
Is this possible? I swear I've seen yes|no, true|false replies before in other commands and bots, but I might be imagining that.
Any help would be appreciated...
thanks
This isn't supported yet but is on Slack's roadmap for the "near term".
https://trello.com/c/DVrJLbxX/12-interactive-messages
A work around is to add reactions to your message. When the user clicks the reaction (to bump up its count), an RTM event will be dispatched for you to handle: https://api.slack.com/events/reaction_added
An live example can be seen with the Meekan calendar app: https://meekan.com/slack/
So you could have two reactions: thumbs up and a thumbs down. And handle which reaction the user clicked.