Creating an Alfred Extension 101

This simple tutorial will help you create your first Alfred “Script Extension” to make your Mac speak. For this tutorial, you will need a Mac with Alfred installed, a Powerpack license and your hands.

The extension will work by showing Alfred and using the keyword ‘say’ followed by some text, for example:

say wow, extending Alfred is really easy!

Step 1 – Create the extension

Open up Alfred’s preferences to the Extension tab and click the Shell Script option on the welcome screen. This will begin the process for creating an extension.

Extension 101 - Create the new extension
Extension 101 - Create the new extension

Alternatively, you can click the + button in the bottom left of the Extensions preferences and select “Shell Script” on the popup menu.

Step 2 – Give your extension a name

We need to name our extension so we can recognise it later if we want to edit it. We can also set some metadata so that if we later share this extension, the credit goes to the creator.

Extension 101 - Give the extension a name and icon
Extension 101 - Give the extension a name and icon

I’ve called this extension ‘wordy’ and filled in my name and a URL. At this point, you can also drag an icon into the little image well to the left hand side of this panel.

Step 3 – Fill in the extension details

Firstly, we want to give the extension a Title and Description. These are the things we will see in Alfred’s results when typing the extension’s keyword. The description is shown in small text under the result, much like the file path is shown for a file result in Alfred.

Secondly, we want to give the script a keyword, in this case, ‘say’.

Finally, we want to add some bash script to perform the actual extension. The bash command we are going to use is ‘say’ and pass {query} which relates to the query you type into Alfred’s search box after typing ‘say’.

Extension 101 - Fill in the extension details
Extension 101 - Fill in the extension details

Note that for the title, we can insert a special {query} phrase which will be replaced out with the query we are typing. This gives good feedback to the users of this extension.

‘Silent’ is ticked by default which doesn’t mean “don’t make any noise”, it actually means run this command behind the scenes without showing Terminal.app – this is useful for building extensions which feel more native to the OS X user experience.

In summary, we are using the following:

      Title: say '{query}'
Description: Get your Mac to Speak 
    Keyword: say
    Command: say "{query}"

Step 4 – Save and Test

Click the save button and now show Alfred and type:

say Wow, I've created my first Alfred extension!

It’s as easy as that! The only thing now is to right [option] click on Wordy in the list and export this extension for all of your fellow Alfred users, which is exactly what I did…

Download the Wordy extension if you would like to have a play with the finished extension.

Cheers,
Andrew

2 thoughts on “Creating an Alfred Extension 101

  1. Thanks for this 101. I guess it’d be a little cliché to thank you once again for Alfred but hey I’ll try to play around and create an extension myself. Keep up the good work!

  2. Thank you for this blog post! This was my first extension that I did (but not the first that I installed in Alfred) and it was really cool! I didn’t even know that Macs could talk. Thank you very much for this post and for Alfred!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s