Jump to content

[Request] Slack Workflow


Recommended Posts

We just started using the Slack app at work. I love the quick "command + t" keyboard shortcut in the app to switch between users/channels. I was wondering if anyone had developed an Alfred workflow to emulate that function right from Alfred using Slack's API?

 

I've created a rather simplistic version of this using Applescript, which sort-of works, but it's not ideal and I'm sure it could be done more efficiently.

Link to comment

I don’t use the app, so I won’t be of much help building it, but I suggest you post your workflow here, anyway. You’ll get more answers showing what you have and asking for help, than simply asking to have it done.

 

My workflow is a poorly written Applescript that basically calls the app to the front and pastes in the query from Alfred. :) It doesn't always work, but it's not exactly what I'm hoping to accomplish. What frankspin says below is more along the lines of what I mean... Appreciate the comment though. What I've done is on my work machine, so I'll have to post what I have, for what it's worth, tomorrow.

 

So are you looking to full replicate the way this works in Alfred? IE you launch Alfred, type Slack and it shows you all the users and rooms which you can filter? Looking throughe the API it appears you can list the people and groups but only join a group. Not sure if that means switching to the channel though. https://api.slack.com/methods

 

Basically, yes - I want to type "Slack Something" to see a list of users and people that match "Something". Selecting one and hitting enter would ideally launch the Slack app in said view. I looked through the API too, but APIs are a bit beyond my understanding at this time. I did find this: https://github.com/tylerhall/AlfredSlackSearch which is close, but not quite what I want. It makes me think it might be feasible, though. 

 

I'm hoping someone either knows of a workflow that does the above, or could maybe school me a bit on how to build something myself via the API - though I realize that may be asking too much as I don't really understand the scope of the work I'm trying to find/do!

Link to comment

As I said, based on the API documentations I'm not sure if the methods for interacting with rooms and people will join them or just simply display who they are. Additionally this likely interact with the website and may require some extra work to have it interact with the desktop application. Actually I'm fairly confident it will only interact with the website. So in the end you will still need to use Apple script to trigger interactions with the desktop client.

 

Maybe someone can prove me wrong here but based on the API and the way other workflows work (like David's Rdio one) the situation you want wont be any fast or better than what you're using now.

Link to comment

As I said, based on the API documentations I'm not sure if the methods for interacting with rooms and people will join them or just simply display who they are. Additionally this likely interact with the website and may require some extra work to have it interact with the desktop application. Actually I'm fairly confident it will only interact with the website. So in the end you will still need to use Apple script to trigger interactions with the desktop client.

 

Maybe someone can prove me wrong here but based on the API and the way other workflows work (like David's Rdio one) the situation you want wont be any fast or better than what you're using now.

 

Remember that Slack is in very active development, so those of you who have a clear idea of what you'd like to achieve with Slack's API could drop them a line with an explanation of what you're trying to do so that they can be made aware of what their users want. They're nice people so I'm sure they'll be interested in hearing your views (regardless of whether or not the additions to the API are possible).

Link to comment

As I said, based on the API documentations I'm not sure if the methods for interacting with rooms and people will join them or just simply display who they are. Additionally this likely interact with the website and may require some extra work to have it interact with the desktop application. Actually I'm fairly confident it will only interact with the website. So in the end you will still need to use Apple script to trigger interactions with the desktop client.

 

Maybe someone can prove me wrong here but based on the API and the way other workflows work (like David's Rdio one) the situation you want wont be any fast or better than what you're using now.

 

I appreciate the more detailed insight. As I mentioned before, the API is a bit beyond my current desktop coding skills, so your comments above are helpful - thank you!

 

Remember that Slack is in very active development, so those of you who have a clear idea of what you'd like to achieve with Slack's API could drop them a line with an explanation of what you're trying to do so that they can be made aware of what their users want. They're nice people so I'm sure they'll be interested in hearing your views (regardless of whether or not the additions to the API are possible).

 

A very good point - perhaps I'll reach out to their team and see what they have to say. Thanks for the idea!

 

And, for what it's worth, here's the script I am currently using - patched together by my basic understanding of Applescript and a few Google searches. If anyone has any recommendations for improving it, I'd love to hear them. Thank you!

 

tell application "Finder"
activate
set the clipboard to "{query}"
end tell

tell application "Slack"
activate

tell application "System Events"
	keystroke "k" using {command down}
	keystroke "v" using {command down}
	keystroke space
end tell

end tell
Link to comment

I think you can simplify this a bit:

on alfred_script(q)
tell application "Slack" to activate
tell application "System Events"
	keystroke "k" using {command down}
	tell process "Slack" to keystroke (q as string)
end tell
end alfred_script
Edited by frankspin
Link to comment

Remember that Slack is in very active development, so those of you who have a clear idea of what you'd like to achieve with Slack's API could drop them a line with an explanation of what you're trying to do so that they can be made aware of what their users want. They're nice people so I'm sure they'll be interested in hearing your views (regardless of whether or not the additions to the API are possible).

 

Totally. It depends if they support callback-urls/deep linking/urlscehemes. If you can do slack:// and have it trigger the app it will smooth things out.

Edited by frankspin
Link to comment

 

I think you can simplify this a bit:

on alfred_script(q)
tell application "Slack" to activate
tell application "System Events"
	keystroke "k" using {command down}
	tell process "Airmail" to keystroke (q as string)
end tell
end alfred_script

 

Thanks - Though I'm guessing the 3rd line from the bottom shouldn't be "tell process "Airmail" to...". Should that be "Slack" instead?

Link to comment

Thanks - Though I'm guessing the 3rd line from the bottom shouldn't be "tell process "Airmail" to...". Should that be "Slack" instead?

 

Ha, yeah. Sorry, I was working off an existing Workflow I have using Applescript.

 

By the way, I reached out to Slack to find out if they support URL Schemes for their desktop client. If they do I can probably throw something together for you.

Link to comment

Ha, yeah. Sorry, I was working off an existing Workflow I have using Applescript.

 

By the way, I reached out to Slack to find out if they support URL Schemes for their desktop client. If they do I can probably throw something together for you.

 

Awesome - that script works much more efficiently than my original one. It's a decent solution for now, but I appreciate you reaching out to Slack too. I also sent them a message, but didn't think to ask about URL schemes. I'd love to know what you find out from them. Thanks again!

Link to comment

Awesome - that script works much more efficiently than my original one. It's a decent solution for now, but I appreciate you reaching out to Slack too. I also sent them a message, but didn't think to ask about URL schemes. I'd love to know what you find out from them. Thanks again!

 

Decided to get creative tonight. Here is a very early version of Alfred interacting with Slack: http://d.pr/f/15qMv

 

It currently does two things: 1. searches rooms and members, passes your selection to clipboard and runs the applescript above 2. search all uploaded files, passes your selection into the browser to view said file

 

Let me know how you like it and if there is anything else you think might be good. Other stuff I'm planning to add:

Leaving a channel

Joining a channel

Set presence

Search messages

Search everything (messages and files)

And anything else I think I can pull off with the API

Edited by frankspin
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...