Actually PIN a message to top or bottom of Slack channel - slack-api

As our company uses Slack for many things, it seemed like it might be a great place to have a company wide message always appear to users. It seems odd to me, that Slack does not seem to support such a thing anywhere. I'd welcome any input on how I can use the API to update a message that always appears at the top (or bottom) of the Slack application for our users.
I've tried using the chat.postMessage, followed by pins.add. But all this does is add a message to a list of other pins. It doesn't actually cause the message to appear at the top or bottom of a given channel. It eventually gets lost in the stream, unless someone specifically clicks the pins button.
I've also tried to figure out a way to do a chat.update, to modify the timestamp of a post so it would appear at the bottom of the list on some set interval. But it doesn't appear that you can modify the timestamp of a post.
I'm contemplating just occasionally posting new status updates. But that feels much more intrusive as it will show up as a new message, as opposed to just being a message at the top/bottom of the feed.
Any ideas/options that might work as I'm describing?

Related

How do you save the Slack modal view ID for future updates?

I'm using Slack's modals + their new BlockKit interactive actions. I have a modal dialog with several section's that include select menu accessories. When one of those accessories changes (ex: user preference goes from Yes -> No), I want to update the modal's view to reflect the change in some contextual text.
The docs outline two ways to update a model. Because I'm not using the traditional modal inputs, I have to update the modal via the API and not via response_action. Proof: I don't even receive a view_submission payload at all... I receive a blockkit_action payload.
The docs conflict a bit. In the above link they say that to update a view you must pass in the returned ID of the view when it was opened:
Remember the view.id that was included in the success response when
you used views.open earlier? We hope you kept it, because you can now
use it to update that view.
But when you look at the docs for the views.open and views.update, it appears there is a second option: external_id. The views.update docs say this:
A unique identifier of the view set by the developer. Must be unique
for all views on a team. Max length of 255 characters. Either view_id
or external_id is required.
Initially I got everything working really nicely by choosing an external ID of myapp-mymodal-[userID]. But as soon as I tried opening the modal simultaneously on my Desktop + Mobile client, I started getting internal_error responses and have been unable to open the modal since!
So I started looking into saving the view ID, per the first quote. My problem is: that ID changes every time the modal opens. I don't understand how I am expected to possibly keep track of the 0-2 "active" view IDs that might be taking place across a user's Desktop + Mobile clients (or more than 2 if they have an iPad, a second laptop, etc).
I tried to look for some sort of unique client ID that I could either use to include in the external_id or in my view_id persistence logic, but given that Slack's API appears to be sesssion-less I couldn't find any such thing.
How do others solve this problem?
Try using the private_metadata field in the View
I initially did the same thing you did, which worked, but I wanted to avoid that edge case if possible. What I figured out, is that I could pass the external_id that I created when opening the view into the view's metadata, and then retrieve it when I receive an interaction.
When I set the external_id I set it to the userID + the current time (so it's always unique, even if the user opens the modal from different devices)
externalID := UserID + time.Now().String()
and pass that both as the external_id for the view, and as a string into the private_metadata.
PrivateMetadata string `json:"private_metadata"`
When the user interacts with one of my blocks and Slack sends me the interactive message, I retrieve the metadata like this:
Request.Payload.View.PrivateMetadata
I wrote my Slack app in Go, but I tried to make it clear for any language. Let me know if anything is unclear or needs expanding on - this is my first time giving back to the Stackoverflow community.

Is there a way to setup permissions so that a viewer can only view issues he is monitoring

I have been given a requirement to allow our sales team to view all of the issues that we are in the process of investigating/fixing that their customers are experiencing.
We've added a custom column that contains a list of all of our customers so that we can filter by customer.
We are going to add viewer accounts for everyone on our sales team.
On every issue we were going to add the relevant sales guy as a viewer. That way the sales guy will get an email whenever a customer's issue is resolved, moved to feedback, etc.
Here is the question:
We want the sales guy to be able to log into Mantis and on his "View Issues" page have a filter already setup that displays all of the issues he is monitoring, and only his issues (to avoid confusion). Is that possible?
We don't really care if he can see all of the resolved issues, unassigned issues, recently modified, etc on the "my view" page. This isn't really a security thing, it is a usability thing. I want to be able to send a link to the sales guy and tell him to bookmark it and it will contain a continually updating list of the issues that pertain to him.
This may be a workable solution, but it is still a little clunky.
If I send out a URL like this:
<SERVER ADDRESS>/print_all_bug_page.php?filter=<XX>
Where the XX is the corresponds to the value of "myself" on the monitored by box. For me it is 52, not sure if that will change as I play with the columns.
Therefore the link right now is:
<SERVER ADDRESS>print_all_bug_page.php?filter=52
What's clunky is: If the user clicks any of the column headings on this page for sorting the query string isn't included in the new URL and all of the issues are then displayed again.

Gmail action buttons *inside* emails?

Gmail actions seem like a really cool feature, but their placement at the far right of the subject line means I invariably miss them, even when I know they exist (i.e. for a MailChimp confirmation email).
It would make a lot more sense to me to place these buttons inside the email, as part of the regular content. Is this supported by the current API? Or are there any plans to support it in the future?
There are plans to show more interactive cards like the ones currently used for flight reservations, but for the moment actions will only be shown on the subject line.
There are no plans for the API to add buttons inside the email as part of the content, as the content is HTML defined by the sender and HTML already supports buttons.

Passing message to another window

I would like to write an application which passes every message it receives to another window. For example, I have an application where user can press some keys, move mouse over it, etc. and I want all these messages passed to, for example, MS Paint.
How do I do this? Any ideas? As far as I know, there may be a problem with sending key strokes to another window, so please advice as well.
EDIT
Okay, maybe I will give you more description of what I'm looking for.
My applications displays a window of another application on the form. Now I would like to control the other window using messages sent to my application's form (like key downs, mouse moves, etc.).
I have been thinking of passing all the messages my form receives to the window of the application I'm kind of 'embedding' into my own. By 'embedding' I mean making the application window display on my form.
Maybe there's another solution to my problem. Please advice.
Thank you for your time.
Some messages (i.e. input messages) arrive through the message queue and the rest are delivered straight to the recipient windows. What you are asking to do therefore requires you to do all of the following:
Implement a top level message loop that retrieves messages from the queue and sends them to the other app.
Reimplement all modal window loops to pass all messages on.
Replace the window procedure for all windows in your process with one that passes all messages on to the other app.
Look for other opportunities for messages to arrive that I have not covered.
I can't imagine that this is really going to be the solution to your problem, whatever that problem is.
Forwarding the messages is definitely possible and easy, but it likely won't do what you are expecting. Take a look here.
Override the form's DefaultHandler() and post every message it gets to the other form. If there are any explicit message handlers in the form or even some controls then you may not see those messages in DefaultHandler().

How can I make something similar to that cool bar on the top of stackoverflow that pops up when you get a new badge?

When you get a new badge on stackoverflow.com, a bar appears at the top of the screen informing you of your achievement. It sticks around until the user closes it.
I rather like that system of informing the user about new news related to the site or their account. It's fairly unintrusive, but still clearly communicates the information. Even if all users receive a notification this way, it sticks around for each user until they have acknowledged seeing it.
I'm running a system using Ruby on Rails on a PostGres database. What's the best way to implement a similar system on my setup?
Edit: Just to clarify, I'm interested both in the server side and client side of the setup.
The effect can be accomplished with jQuery and the slideDown method (http://api.jquery.com/slideDown/). Set an onClick event to make the element slideUp, hide, or hit an AJAX call to let you know that the user got the message and dismissed it.
You could set the contents of the element (I'd go with a div) via an AJAX call, or you could simply populate the div with the appropriate message when generating your page, start the div off as hidden, and then kick off the slideDown method when the page load is complete via a $(document).ready definition (http://think2loud.com/jquery-document-ready-howto/).
You could use something like the jquery popup bubble extension: http://www.farmcode.org/post/2009/04/06/jQuery-popup-bubble-extension.aspx

Resources