pacmax beta

Alfred Pac by wrjlewis on GitHub

notion search

An Alfred workflow to search Notion with instant results

From their README

notion-search-alfred-workflow

An Alfred workflow to search Notion.so with instant results

img

ℹ️ Please only use the Alfred 5 version of this workflow, as found below. The Alfred4 version has not been updated with the latest bug fixes and will not receive these updates in future ℹ️

Alfred 5 version

Github Repository

Latest Download

Alfred 4 version

⚠️ The Alfred 4 version will not receive further updates.

Github Repository

Latest Download

Simply type your keyword into Alfred (default: ns) and provide a query to see instant search results from Notion that mimic the Quick Find function in the Notion webapp.

Pressing enter on a search result takes you to that page in Notion in your default web browser or notion app.

Hold Cmd + press enter on any search result to copy the url to your clipboard.

Additional features

  • Comes with pre-configured support for OneUpdater for automatic version updates.

  • The workflow also provides the ability to quickly see your recently viewed pages. Simply type the 'ns' keyword to start the workflow, as you would before you search, and your most recently viewed notion pages are displayed.

  • Open a new notion page by typing 'nsn', this only supports the web app currently, it's very handy!

img

Workflow Variables

  • cookie: Needed for your Notion token.
  • notionSpaceId: Your organisation identifier.
  • useDesktopClient: Defaults to False. Determines whether to open Notion links in the desktop client rather than the web app.

It's recommended to leave the following variables to their defaults, unless you're confident:

  • isNavigableOnly: Defaults to False. This settings allows you to search objects within a page, ie notion objects that cannot be found through the left hand side navigation pane. Setting to True only returns results that can be found through the left hand side navigation pane, but removes subtitles from Alred search results.
  • enableIcons: Defaults to True. This toggles support for Notion icons to be shown natively in Alfred search results, for a better design/UX experience. Custom Notion icons are downloaded on demand.
  • iconCacheDays: Defaults to the recommended value of 365 days for the best performance. Defines the number of days to cache custom icons. Min 0, max 365.
  • showRecentlyViewedPages: Defaults to True. This toggle determines if recently viewed pages should be shown when there is no query provided by the user and the user id is present in the supplied cookie (user id is needed for the api call to show recently viewed pages).

Install Steps

Install Python3

Many people will have Python3 already on their machine, if you haven't you can try to run python3 from a Terminal window and it should prompt you to install the Xcode CLI tools automatically (which include Python).

Otherwise you can read a more detailed guide on installing Python here.

Install cairosvg (optional)

Installing cairosvg will allow svg icons to be shown in Alfred search results, providing a more visually appealing experience. Open terminal and run the following command:

pip3 install cairosvg

Install cairosvgs's dependency, cairo. With Homebrew for example:

brew install cairo

If you haven't used homebrew before, you may want to skip this optional step or install homebrew (easy with a quick google search).

UPDATE: There seems to be an issue with cairosvg on apple silicon, use this fix at your own risk but this worked for me and now SVG icons show again:

brew install cairo pango gdk-pixbuf libxml2 libxslt libffi
sudo mkdir /usr/local/lib/
sudo ln -s /opt/homebrew/lib/libcairo-2.dll /usr/local/lib/libcairo-2.dll
sudo ln -s /opt/homebrew/lib/libcairo.so.2 /usr/local/lib/libcairo.so.2
sudo ln -s /opt/homebrew/lib/libcairo.2.dylib /usr/local/lib/libcairo.2.dylib

Get your workflow variables

I recommend using chrome to retrieve these values. If you can only use safari you can copy the 'token_v2' value by following the equivalent steps above and populating the cookie env variable in Alfred so it looks like this token_v2=XXXXXXXXXXXX (however this means the recently viewed pages feature will not work for you).

Visit the Notion webapp and use your browser developer tools to see the network requests being made when you type in anything to the quick find search bar. In Chrome select 'View' in the toolbar > Developer > Developer Tools. Then select the Network tab in the developer tools window.

Here you'll see a request called search, check the request headers to copy the cookie value and check the request payload to copy your notionSpaceId, as shown in the screenshots below.

Known issue: Some users have experienced issues with copying these values directly from developer tools, but have seen success by copying and pasting the values into TextEdit or a different text editor first, this probably "strips out" or removes any problematic formatting.

img

Get your cookie headers They should look something like this

notion_browser_id=1bcfbfb9-e98c-9f03; logglytrbckingsession=eb1c82cb-fd; bjs_bnonymous_id=%22bdbf1088-b33c-9bdb-b67c-1e; _fbp=fb.1.12821; intercom-id-gpfdrxfd=b61ec62d-; token_v2=b39099...

img

Get your spaceId It should look something like this

celcl9aa-c3l7-7504-ca19-0c985e34ll8d

img

Install the Notion Alfred worflow

Download and double click the latest release for your version of Alfred, following the links at the top of this page.

Add these values to the Notion Alfred workflow

In the Alfred worfklow in the upper right corner click the [x] icon and add the values from above to the corresponding value field

img

Troubleshooting

The script may fail due to an SSL error. If the script isn't working, turn on debugging by clicking on the little cockroach in the alfred workflow screen. If you see an error like:

[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: .....

Run this from the terminal app:

sudo '/Applications/Python 3.9/Install Certificates.command'

The single quotes are required. If this file doesn't exist, run "python --version" to find out what version you have and update the directory accordingly.

Tips

  • If you prefer using the Mac app of Notion, set the useDesktopClient environment variable in Alfred to True.
  • If you experience performance issues or slow searches, you may wish to set enableIcons to false. This changes the search results design so icons are in line with the title, it also disables the downloading of any Notion custom icons that you come across whilst searching.

Download:

Follow the links at the top of this page.

Forum topics:

https://www.alfredforum.com/topic/14451-notionso-instant-search-workflow/ https://www.reddit.com/r/NotionSo/comments/f58u1y/notionso_instant_search_workflow_for_alfred/

Latest release

  • 0.6-alfred43 years ago, 4.2 MBDownload
    • Type ‘nsn’ for the option to quickly open a new page in Notion. Very handy! (Only supports the web app currently)

    • https://github.com/wrjlewis/notion-search-alfred-workflow/issues/83 - Fixed a bug that would cause an error and no more results to be displayed, relating to new Notion projects and icons.

    • Update readme with:

      • new notion page functionality
      • new cairo instructions for those on apple silicon, use at your own risk but they work for me and svg icons now appear in search results.
14 earlier releases
  • 0.5.3-alfred43 years ago, 4.2 MBDownload

    Includes fix for the recent breaking change on Notions side to their internal search api

    https://github.com/wrjlewis/notion-search-alfred-workflow/issues/80

  • 0.5.2-alfred43 years ago, 4.2 MBDownload
  • 0.5.1-alfred44 years ago, 4.2 MBDownload

    Fixes an infinite loop in the new subtitle builder logic

  • 0.5-alfred44 years ago, 4.2 MBDownload

    ** Alfred 5 update now available here! **

    (automatic updates will resume as usual once you've upgraded to the new workflow)

    For folk on Alfred 4, you do not need to do anything, and updates will continue as usual:

    Christmas is coming and I hope you all enjoy this awesome major update.

    • Subtitles are much much better. I've implemented the same logic that Notion does in it's quick find module to properly show where in the navigation tree the search result lives, helping you find exactly the page you're looking for. You'll now see 'Company / Hiring / Interview Process / Interview' rather than previously showing one continous string 'Company Hiring Interview Process Interview' Fixed a bug here where subtitles were not shown at all for some search results. Note, subtitles will not be shown if the page exists at the top of the navigation tree, ie when the page has no parent pages.

    • SVG Icon support! Notion recently introduced support for (SVG) icons. Alfred does not support SVG icons so you would have been seeing an empty icon for these results. This workflow now converts the svg file to png and displays it as an icon to the relevant search result. Simply install cairosvg in terminal (pip3 install cairosvg) for this feature to work.

    • Caching The slowest part of any Notion search is the bit that downloads icons or images in the page title. Previously this was happening on each query that included such pages. Now it doesn't re-download icons or images if the workflow has already downloaded it before and it hasn't been downloaded more than a year ago. You can change the cache duration in environment variables but 365 days is recommended. The workflow knows if the page icon or image has changed in which case it will redownload and cache it.

    • Better error handling Errors are now shown on screen as a search result so you don't have to open the alfred workflow debug console in the majority of cases. The error is shown in addition to any successful search results that the workflow is able to find. Previously an error would stop the workflow from operating completely.

    Compatible with Alfred 4 and Alfred 5. Note: an Alfred 5 only version is available and you can download that here, I will hope to maintain both versions for the forseeable future.

  • 0.4.34 years ago, 4.2 MBDownload

    +Support for korean and other languages +Much improved logging +Oneupdater script has been updated to latest

  • 0.4.24 years ago, 4.2 MBDownload

    Notion recently changed their API which broke this workflow. These changes have now been reflected in the workflow. Thanks @amrael for your contribution!

    I've also noticed that the subtitles in the search results do not appear now if you set isNavigableOnly to True, this is a change made on Notions side. For this reason I have set the parameter to default to False. You can still set this to True but you will lose subtitles in your Alfred search results.

  • 0.4.14 years ago, 4.2 MBDownload

    Performance improvements. Added env variable toggle showRecentlyViewedPages to toggle the self entitled feature, added in the previous release, and described in the readme.

  • 0.4.04 years ago, 4.2 MBDownload
    • ** Recently Viewed Pages ** Your most recently viewed notion pages are shown when triggering the workflow. Simply type the 'ns' keyword to start the workflow, as you would before you search, and your most recently viewed notion pages are displayed.

    • The workflow has been migrated to Python3 - ensuring compatibility with future versions of MacOS: "Python 2.7 was removed from macOS [12.3]. Developers should use Python 3 or an alternative language instead. (39795874)"

    • Fixed issue with no results in certain circumstances with collections/dbs

    • Fixed issue with null highlight on non-page elements - thanks to ymszzq

    • Fixed issue retrieving and displaying notion icons in results, due to change in internal notion APIs

    • Fixed issue where externally hosted icons wouldn't show in results

    • Slightly better error handling when no results are returned

    • Results returned from Notion will now be shown in the original order, bypassing Alfred's learning algorithm.

    (Unfortunately this workflow is not using the public notion api yet, which means you still have to retrieve your cookie/token manually. The public notion api is still in beta and I believe it doesn't have the same functionality compared to the internal api, but it is improving month on month. If anyone would like to give it a go adapting this workflow to use the api, I'll gratefully review any PRs).

  • 0.3.36 years ago, 4.2 MBDownload

    Fixes an issue where certain unicode characters are not being handled properly (https://github.com/wrjlewis/notion-search-alfred-workflow/issues/19)

  • 0.3.26 years ago, 4.2 MBDownload

    Support for OneUpdater (https://github.com/vitorgalvao/alfred-workflows/tree/master/OneUpdater)

    This means the workflow should update itself when new versions are available 🙌

  • 0.3.16 years ago, 4.2 MBDownload

    Removes dependency on requests library

  • 0.36 years ago, 4.2 MBDownload

    This is a big (and awesome) change.

    Notion icons are now displayed in Alfred search results natively rather than in-line with the title. This improves the look and usability of the search results drastically.

    Support for custom icons. These are also shown in Alfred search results natively.

    Limitations known so far:

    • Custom icons uploaded as SVG files to Notion, are not properly displayed in Alfred search results
    • Certain emoji variances (ie some gender or skin colour variances) are not supported since I could not obtain the image files for each of the different permutations.
  • 0.26 years ago, 239 KBDownload
    • returns 9 search items from notion to match the number that can be displayed at once in Alfred
    • refactored into a separate python script to allow for easier diffs and version control. Now using the releases feature in GitHub.
    • Option to change the 'isNavigableOnly' search filter via the 'isNaviagableOnly' env variable. I personally prefer only to search notion objects that can be navigated to, as I have a large workspace which would clutter the results, but the default search in notion has this option as false, so including this as an env variable.
    • Option to switch support for the notion web app or the notion desktop app using the useDesktopClient env variable.
  • 0.16 years ago, 239 KBDownload