Jump to content

Notion.so Instant Search Workflow


Recommended Posts

38 minutes ago, wrjlewis said:

Can you copy everything after Cookie: in your screenshot, and use that as your cookie value to paste into the workflow environment variable

i have copied cookies and notionspaceid to environment,run

the workflow will turn to notion homepage ,when i search it showsFC5BAD1B-8ECD-49A9-AF10-E09A78884C66.thumb.jpeg.624ea57317b5d072d9919f2f5c3cb1fb.jpeg

Link to comment
  • 4 weeks later...
7 minutes ago, blastik said:

hello

im getting the same behaviour as other people after upgrading to your v0.5.1.

image.thumb.png.6fc34e748fc4a78f1e2b615c486f4c63.png

 

No traces of the certificate problem. I'm on a M1 which `Python 3.10.4` installed by asdf and set to the system global

Hi

 

was everything working on 0.5 or prior versions?

 

does any error appear in the search results itself in Alfred? When you type ns something 

 

thanks

Link to comment
23 hours ago, wrjlewis said:

Hi

 

was everything working on 0.5 or prior versions?

 

does any error appear in the search results itself in Alfred? When you type ns something 

 

thanks

yes it was working fine prior to 0.5

 

when i query notion on the web browser works fine

no other errors are shown in alfred

 

note that the python is installed via asdf and configured as global

 

which python
/Users/username/.asdf/shims/python

 

Edited by blastik
Link to comment
1 hour ago, blastik said:

yes it was working fine prior to 0.5

 

when i query notion on the web browser works fine

no other errors are shown in alfred

 

note that the python is installed via asdf and configured as global

 

which python
/Users/username/.asdf/shims/python

 

Looks like nothing is being returned at all.

Can you please try obtaining your cookie and space id again, and adding them to the workflow, if you haven't already? Sometimes Notion changes the token on their side and it needs updating in the workflow.

Link to comment
  • 2 weeks later...
  • 2 weeks later...

How might you modify the script if you wanted it to return a specific property from the page you select? My use case is that I have a database of old account codes for our company with corresponding new account codes (3,000+) and I wanted to be able to search from Alfred with the old code and have it return the new one.

 

Is this even possible?

Link to comment
16 hours ago, billyadams said:

How might you modify the script if you wanted it to return a specific property from the page you select? My use case is that I have a database of old account codes for our company with corresponding new account codes (3,000+) and I wanted to be able to search from Alfred with the old code and have it return the new one.

 

Is this even possible?

Hey

 

It is possible to do, but its way beyond the scope of making a few modifications to this script. This workflow searches pages, it doesn't get the contents of pages (or databases) and do things with it.

You would need a new workflow, new code, and different calls to Notion.

After a quick look, you'd want to make a call to https://www.notion.so/api/v3/queryCollection?  with the appropriate query parameters, the database contents will be within the response in recordMap - block - value - properties.. There you'd need to apply some logic to figure out which is the corresponding account code. Quite a lot of work to do, and for quite a custom use case.

Edited by wrjlewis
Link to comment
  • 2 weeks later...
On 9/20/2022 at 1:14 AM, wrjlewis said:

 

Welcome! It seems to be working as far I can tell. 

 

Have you got the latest version

I had the same issue as nd0 with the latest version of the workflow.


I debug it and found it's because there's a curly brace in my Notion cookie, but SimpleCookie stops parsing at the curly brace, which will lead to no notion_user_id in bakedCookie. Since your code only needs notion_user_id, I extract it with regex and it works for me now. 

 

I can pr the code if that's helpful. Thanks for this amazing workflow!

Edited by fskdjfn
Link to comment
On 12/31/2022 at 5:01 AM, fskdjfn said:

I had the same issue as nd0 with the latest version of the workflow.


I debug it and found it's because there's a curly brace in my Notion cookie, but SimpleCookie stops parsing at the curly brace, which will lead to no notion_user_id in bakedCookie. Since your code only needs notion_user_id, I extract it with regex and it works for me now. 

 

I can pr the code if that's helpful. Thanks for this amazing workflow!

 

Hey, thanks for posting your update, its incredibly helpful and allows me to improve the workflow further.

 

So were you getting the latin-1 codec error?

Interestingly I have curly braces in my cookie, so that seems standard, but I do not get an error. Any thoughts on why that might be?

Link to comment
10 hours ago, wrjlewis said:

 

Hey, thanks for posting your update, its incredibly helpful and allows me to improve the workflow further.

 

So were you getting the latin-1 codec error?

Interestingly I have curly braces in my cookie, so that seems standard, but I do not get an error. Any thoughts on why that might be?

My guess is the Python version. I have Python 3.9 installed. And you can see SimpleCookie stops at curly braces as well from this online IDE: https://tech.io/snippet/kh1JGkc and the Python version here is 3.11.1

Edited by fskdjfn
Link to comment
11 hours ago, fskdjfn said:

My guess is the Python version. I have Python 3.9 installed. And you can see SimpleCookie stops at curly braces as well from this online IDE: https://tech.io/snippet/kh1JGkc and the Python version here is 3.11.1

I'm using 3.9.13, by the way. I experience the same SimpleCookie silent parsing fail but the braces in my cookie are after all the information I need, I'm not sure what dictates the cookie key/value ordering but seems folk like me are currently getting lucky.

 

I did a bit of digging and thanks for your code snippet, it is the perfect example because it seems other have pointed out the same issue in Python due to google's oauth cookie implementation, which demonstrates the issue well.

 

Example isse: https://github.com/python/cpython/issues/92936

 

It looks like a fix has been merged but obviously won't be available in all but the latest version of Python (if thats been released since the merge, I'm not sure).

 

Could you please post the patch, or PR, with the fix you made? At least we can fix it locally for now. Thanks.

Link to comment
14 hours ago, wrjlewis said:

I'm using 3.9.13, by the way. I experience the same SimpleCookie silent parsing fail but the braces in my cookie are after all the information I need, I'm not sure what dictates the cookie key/value ordering but seems folk like me are currently getting lucky.

 

I did a bit of digging and thanks for your code snippet, it is the perfect example because it seems other have pointed out the same issue in Python due to google's oauth cookie implementation, which demonstrates the issue well.

 

Example isse: https://github.com/python/cpython/issues/92936

 

It looks like a fix has been merged but obviously won't be available in all but the latest version of Python (if thats been released since the merge, I'm not sure).

 

Could you please post the patch, or PR, with the fix you made? At least we can fix it locally for now. Thanks.

Thanks for sharing the digging!

I tried PR but got denied from GitHub. So here's the notion.py I updated: https://tech.io/snippet/0TmWuss.

Link to comment
  • 1 month later...

@wrjlewis this workflow is fantastic! Much more sophisticated than my puny little workflow hehe.

 

Question: with your workflow, is it possible to have pages open in a new window? I've gotten your workflow to work, but it seems to only be able to open pages in the existing window, which isn't as useful since I can already do that with Cmd + K.


Am I using it wrong? Is there functionality that has evaded me? If not, how difficult would it be to modify your workflow to open the pages in a new window rather than an already open window?

 

Really really awesome job. Thank you so much man!

 

Tommy

Link to comment
On 2/5/2023 at 10:45 AM, eupraxia said:

@wrjlewis this workflow is fantastic! Much more sophisticated than my puny little workflow hehe.

 

Question: with your workflow, is it possible to have pages open in a new window? I've gotten your workflow to work, but it seems to only be able to open pages in the existing window, which isn't as useful since I can already do that with Cmd + K.


Am I using it wrong? Is there functionality that has evaded me? If not, how difficult would it be to modify your workflow to open the pages in a new window rather than an already open window?

 

Really really awesome job. Thank you so much man!

 

Tommy

 

Hey

 

Glad you're enjoying the workflow.

 

So the workflow operates by sending the URL to Alfreds Open URL action. This will be notion:// (if you're using the desktop app) + the object id of the page.

 

I'm not sure if there is anything thet can be added to this URL in order to ensure that the page is opened in a new tab when using the desktop app, would be happy to make a change if someone knows.

When using the web app, it always opens in a new tab.

Link to comment
  • 3 weeks later...

Hi, excited to try this out!

I'm getting the same behaviour as others: "No results, empty query, or error"

I've gone through the last few pages in this thread but not 100% sure where my issue lies. I'll recap my steps:

 

- installed the workflow.

- pasted the cookie vars notion_browser_id into Cookie , token_v2 into Space ID(I think this is what your instructions are pointing to, but sometimes the language used sounds like you're saying to copy the entire chunk of text that comes after "cookie: " which for me is several lines with multiple vars and ; delineators)

- Alfred gave errors ("No results, empty query, or error") so I installed python via homebrew.

- Alfred error still persisted

- Back in Terminal, despite having just installed python, it tells me
 

WARNING: You are using pip version 21.2.4; however, version 23.0.1 is available.
You should consider upgrading via the '/Library/Developer/CommandLineTools/usr/bin/python3 -m pip install --upgrade pip' command.


So I ran that command and it gives me this

WARNING: The scripts pip, pip3 and pip3.9 are installed in '/Users/***/Library/Python/3.9/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

 

I don't know if that's even the issue.  I checked out the StackOverflow post you linked, but I'm not sure what to do because I don't have Python in my Apps folder.  

On 11/3/2022 at 9:04 AM, wrjlewis said:


Maybe I wasn't supposed to install python via homebrew?
Or is it a case of adding the Python scripts into PATH?  (I don't know what that even is)

Or something else altogether?

Sorry, not super familiar with all this stuff but I'm a longtime tinkerer, so can only get so far.

 

Thanks in advance

 

DT

 

 

Link to comment

Hi!

 

Quote

sounds like you're saying to copy the entire chunk of text that comes after "cookie: " which for me is several lines with multiple vars and ; delineators

 

Thats correct, you need to paste the whole thing into 'cookie'.

 

You are also pasting the wrong thing into space id, you need to get the 'spaceId', not the browser id. The readme on the github page should give you everything you need to know on where to find this value, the pictures are particularly good. 

Link to comment
11 minutes ago, wrjlewis said:

Hi!

 

 

Thats correct, you need to paste the whole thing into 'cookie'.

 

You are also pasting the wrong thing into space id, you need to get the 'spaceId', not the browser id. The readme on the github page should give you everything you need to know on where to find this value, the pictures are particularly good. 

Ah gotcha, ok. Yeah I went through that readme a few times. Ok I'll grab the whole chunk.
For spaceId, I can't actually find it anywhere in Chrome's headers. I copied the entire page (General, Response Headers, Request Headers), pasted into bbedit... "space" doesn't come up.  That's why I assumed it was browserID, since it's the only variable that matches the format.  Am I looking in the wrong place? I must be misreading something.

Link to comment

I just screengrabbed the contents of Chrome's headers. Redacted private data but made sure to keep all var definitions intact.... I wonder if this is due to Notion's Team functionality that others have mentioned, being that there's is no spaceId anymore? Excuse my ignorance, just spitballing.

EDIT: I tried copying notion_user_id into Alfred, just in case. No change.

 

EDIT 2: 

Found it! My bad.

Didn't realize spaceID is under the Payload tab, not Headers. 

It's there and it just started working! Thanks so much.
Just saved myself probably 15min per day with this workflow :)

 

Edited by dterranova
solved!
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...