Jump to content
frankspin

Slackfred: Interact with your Slack channels, groups and IMs

Recommended Posts

Attention: I am no longer actively working on this Workflow. I don't have the time to dedicate to it anymore and provide the kind of updates I'd like. If you want to fork and contribute back to it, please do so via GitHub. I appreciate all the support and kind words shown by users for making this.

 

slackfred
=========

Alfred workflow to interact, and perform various functions with the service Slack

 

Vy78c78.gif

Alfred workflow to interact, and perform various functions with the service [slack](http://slack.com/). Now with multi-team support!

I'm currently in the process of getting this updated to work with multiple organizations where possible, as well as adding some extra workflow options like private groups, stars and a few more things. Stay tuned!

## Getting started
1. Install slackfred by visiting the download page in Github or via the [Packal page](http://www.packal.org/workflow/slackfred)
2. Open alfred and type `slt`, then hold `cmd` (apple key) and press `enter`. This will open up the Slack API page. Then look for your team (make sure you're logged in) near the bottom. Next to your team name will be your token.
3. Launch alfred and re-run `slt` to enter your token.

##### Multi-team use instructions
In order to use the workflow with multiple organizations you will need to enter all of your keys as comma seperated strings with **no** spaces.  
Example: `team-org-api-token-1,team-org-api-token-2`

## Currently Available Functionality

* `slk`: Let's you switch easily between channels, groups and IMs. Thanks to buzali for getting this working with Slack's URL scheme.

* `slt`: Set your API Token
  * Open alfred and type `slt`, then paste your token. If you don't have a token, then hold `cmd` to open the API page to get one (look for your team near the bottom of the page).

* `slm`: Send messages to a channel

  * Open alfred and type `slm` to populate channels. Use your arrow keys to select a channel and hit TAB. Then you can enter your message and hit ENTER.

* `slf`: Search files
  * Open alfred and type `slf` to search files. Selecting a file opens it in your browser
* `slp`: Set your presence
  * Open alfred and type `slp active` or `slp away`
* `slc`: View, leave and join channels or private groups
  * Open alfred and type `slc` to display a searchable list of channels. Selecting a channel with `alt` leaves and `ctrl` lets you join. Currently only `alt` is functional with groups.
* `slclr`: Clear unread messages
  * This currently only marks Channels as read and not groups. Depending on the size of your organizations this can also take a few seconds to run.
* `slim`: Enter a users name to search for most recent DM messages
* `slr`: Search your starred items
  * Highlight a result and hitting enter opens the web client to that result
* `sls`: Perform a query across all your channels in your organizations
  * Highlight a result and hitting enter opens the web client to that result
  * Depending on the size of your organization this can take a few seconds to run

* `slz`: Snooze teams:

  * After finding a team hit TAB and enter the length of snooze in minutes

  * To turn off snooze to the above and enter 0
 

## To-do
* Create a smoother API key/token process
* Improve speed and performance

This workflow was created with the help of Dean Jackson's library.

Edited by frankspin

Share this post


Link to post

Hey, this is awesome, but two things:

 

First, any chance you could make it press return after entering the query in the cmd-k area?

Second, I'm using the new beta of slack with several organizations. Could this possibly switch to the right org?

 

Thanks so much for making this!

Share this post


Link to post

Hey, this is awesome, but two things:

 

First, any chance you could make it press return after entering the query in the cmd-k area?

Second, I'm using the new beta of slack with several organizations. Could this possibly switch to the right org?

 

Thanks so much for making this!

 

Question 1: Open Alfred preferences and double click on the action for 'Run NSAppleScript'. It should be attached to the keyword 'slk'. Replace the Applescript with this:

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)
	key code 36
end tell
end alfred_script

Question 2:

The Slack API is still in beta form and needs to authenticate against each organization. There is no larger API that returns everything you're associated with. I might be able to whip something up, I just need some time to think it through.

Share this post


Link to post

hey there

 

great workflow, have been using it for several weeks now! awesome!

 

+1 for automatic organization switch...

would be enough to add a function to switch to the connected organization before the actual command for each request.

Share this post


Link to post

I had issues getting Slack to display properly if it was minimized or hidden in the background. Recommend trying something like this: 

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

Share this post


Link to post

Bumping this for those of you asking for multi team support as it's now available. A few caveats though:

 

1. Speed isn't the best for certain workflow options. I'll be working to improve

2. Getting support for teams within the desktop client is tough. Since I have no way of knowing the order your teams were added it's hard for me to build that functionality in. Until Slack offers proper deep linking with the client I wont be able to move forward there.

3. With #2 stated, the command `slk` isn't terribly effective with multiple teams since it's using the client. I left it in there for those who are on single teams.

Share this post


Link to post

Hey,

 

Been using this for a few days, using mostly 'slk'. Very useful!

 

Few things:

 

1. Both 'slim' and 'sls' don't work for me, as soon as I type the command, after I hit space, it just reverts to searching the default search engines. Not sure if I'm supposed to type username or the query, but neither seemed to work.

 

2. Sometimes someone messages me and I just want to quickly reply 'ok' or '2 min', how feasible is it to just type the name and quick message and send, without ever activating slack? If not feasible directly, would it be possible to use applescript to mimic this? Switch to user like 'slk', type the message, hit enter and then cmd+tab back to wherever I was before?

 

Thanks! Great idea and execution!

 

 

Share this post


Link to post

Hey,

 

Been using this for a few days, using mostly 'slk'. Very useful!

 

Few things:

 

1. Both 'slim' and 'sls' don't work for me, as soon as I type the command, after I hit space, it just reverts to searching the default search engines. Not sure if I'm supposed to type username or the query, but neither seemed to work.

 

2. Sometimes someone messages me and I just want to quickly reply 'ok' or '2 min', how feasible is it to just type the name and quick message and send, without ever activating slack? If not feasible directly, would it be possible to use applescript to mimic this? Switch to user like 'slk', type the message, hit enter and then cmd+tab back to wherever I was before?

 

Thanks! Great idea and execution!

 

1. Try it but without hitting space after you enter a name or query. Admittedly what I'm doing isn't the fastest or most feasible solution so it can sometimes mess up or hang for a bit

 

2. Applescript is hard to use right now with multi-orgs since I cannot account for how they're set up. I asked the SlackAPI twitter about callback urls / deep linking in the desktop app and it's currently not there. Having it would make this kind of thing a lot easier to pull off. As for sending messages in general I want to eventually look into sending messages I just haven't had a ton of time to do so. I know it would be through Webhooks I just need to find sometime.

Share this post


Link to post

Has anyone made a workflow to take something from slack and send it to Things?

 

Working with: http://support.culturedcode.com/customer/portal/articles/1625470-creating-to-dos-with-a-launcher

 

You could probably add an additional modifier to the workflow that uses applescript. For example: if you use 'slf' you hold 'ctrl' while clicking a result you can have Applescript relaunch Alfred with '+' and paste in the result.

Share this post


Link to post

Great work, yet!

I like the idea of sending Messages directly without using the Slack client.

Instant Sending via API would be awesome! 

Share this post


Link to post

Can you open Alfred Preferences, go to the Slackfred workflow, turn on debugger and then run this. That may help me narrow down what is happening.

Hit the same problem. The issue is that the codebase is behind your GitHub code. The slackfred-search.py file attempts to import requests and then tries to use it once for a GET requests. The other time, you use the web.py module from the Alfred-Workflow library. Your GitHub code doesn't have this issue. All you need to do is update the Packal download with the up-to-date codebase.

 

- - -

 

PS. Nice workflow!

Edited by smarg19

Share this post


Link to post

Hit the same problem. The issue is that the codebase is behind your GitHub code. The slackfred-search.py file attempts to import requests and then tries to use it once for a GET requests. The other time, you use the web.py module from the Alfred-Workflow library. Your GitHub code doesn't have this issue. All you need to do is update the Packal download with the up-to-date codebase.

 

- - -

 

PS. Nice workflow!

 

Good catch! I just updated the workflow file to include the library. Can you give it another go? https://github.com/fspinillo/slackfred/blob/master/workflow/Slackfred.alfredworkflow

Share this post


Link to post

@frankspin - I tried with the updated file and still get the same problem. However today, I noticed that (sort of relevant) results flickered for a second before reverting back to default engine search (happened also before I updated). So it's doing something right before getting messed up (sls worked I think, not slim).

Edited by Maddog

Share this post


Link to post

@frankspin - I tried with the updated file and still get the same problem. However today, I noticed that (sort of relevant) results flickered for a second before reverting back to default engine search (happened also before I updated). So it's doing something right before getting messed up (sls worked I think, not slim).

 

Can you open the debug menu and run slim? I should clarify a bit more, but when using slim it should be used with their chat name and not their real name. So if your real name is John Doe but your chat name is Maddog, search for maddog.

Share this post


Link to post

Somehow workflow does not work for me. When I type "sl" alfred shows me many available Slack options. However, when I continue and add 'k' to have 'slk' then Alfred only provides me an option of searching 'slk' on google. Am I missing some setup step?

Share this post


Link to post

Somehow workflow does not work for me. When I type "sl" alfred shows me many available Slack options. However, when I continue and add 'k' to have 'slk' then Alfred only provides me an option of searching 'slk' on google. Am I missing some setup step?

 

 

Thanks. Somehow all the files got overwritten. I'm updating it now.

Share this post


Link to post

I'm using Slackfred and Things by Cultured Code. I want to publish a selected task with tag from Things into Slack after a shortcode. (cmd+shift+s) How to do this with AppleScript and Slackfred?

 

  1. I select a task in Things
  2. Shortcode (cmd+shift+s) will trigger Slackfred with custom code
  3. The task with tag(s) are published in Slack

 

Someone made this code for me, but he doesn't have Alfred Powerpack, so he can't make workflows.

tell application "Things"

set selectedToDo to the first selected to do

tell selectedToDo
set theToDoTitle to the name
set theToDoTags to name of tags
end tell

end tell

return {theToDoTitle, theToDoTags}

I have no experience as a developer. How to do this?

Share this post


Link to post

Hi there, this tool is great. Thanks for making it. I'm a total noob with scripts and such. How would I trigger the screensaver at the same time as setting my presence to "away"?

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...