Jump to content

[SOLVED] Alfred notification message

Recommended Posts

Hi everyone.


I have a workflow that I use to create tasks in Asana using Alfred. I have a notification that I'd like to show the task (Query) when it's done. It used to work, but now the notification shows as this:




Here's the setting:




Thanks in advance for any advice :)

Link to comment

Hi Paul,


I'm going to move this to the Workflow Help & Question forum. If you're not talking about your own workflow, then it probably really belongs in the actual workflow's thread, where people who know the workflow (not least its developer) can provide a proper answer.


The problem is that the workflow is sending a bunch of JSON to a Post Notification element. I can't possibly say more than that based on screenshots.



Link to comment
2 minutes ago, paulminors said:

Does this screenshot help?


Not in the slightest, I'm afraid. Please read and follow the "Reporting Problems with Workflows" I just linked.


As I said, you're seeing a bunch of JSON in the notification because your workflow is sending a bunch of JSON to the Post Notification element.


I can't possibly give you a more precise answer specific to the workflow you're talking about because I do not have the workflow you're talking about.

Link to comment

And what exactly do you want to see in the notification?


I think I just added a note or three called "deans-test" to your thing. I've tried messing with the URL/query, but it doesn't seem to make much difference to the API response.


From my reading of the API docs, however, a bad call should return a 4xx response.


I can't get it to, but you're not checking for failure in any case.


Changing your Run Script to the following should help (replace success with whatever you want to be shown in the notification body):

curl -sSL $ZAP_URL?note="{query}" >/dev/null
echo -n "success"


That sends whatever curl returns to /dev/null (i.e. a blackhole) and you'll only see what's echoed in the notification.


If that's okay for you, delete the above workflow from your Dropbox, so Internet randos can't spam your Zapier with stuff.

Edited by deanishe
Link to comment

To confirm, your tests came through to my account so they all worked fine.


Thanks, that seems to be working better. However, in the notification to show, I'd like the Alfred query to show. So the notification should be:


Task Created!


Edited by paulminors
Link to comment
  • vitor changed the title to [SOLVED] Alfred notification message
  • 8 months later...

Sorry to open this old thread up but @deanishe, I am trying to convert the post notification into a clickable notification so upon clicking, it would go to the newly created Asana task. 

But I've found that it can't be done as people have requested it as a feature.


So I resorted to using "Open URL" as output. All I have to do is put this as static: https://app.asana.com/0/45482574283XXX/{taskID} and take the taskid returned by the successful zapier run. Except I can't figure out how to get that return and put it in there.. using just the variable from Zapier doesn't work either.



Screen Shot 2019-09-30 at 6.01.07 AM.png

Link to comment
23 minutes ago, Yourname said:

Except I can't figure out how to get that return and put it in there.. using just the variable from Zapier doesn't work either.


You mean to get that number marked "id" from the webpage that opens? That's hard to do.


You're probably going about it the wrong way. Webpages are for humans, and APIs are for machines. So, if you want to use the Zapier data in your script, you should probably be using the API to run your Zap.


If there is no API, you'll need to open the URL in code and extract the ID from the HTML response.

Link to comment

Actually, sorry ... should have clarified @deanishe, but that's not a webpage. That's actually the return of zap. Pretty much the first screenshot posted by @paulminors above where the notification showed {"status: success", etc. 


That means the zap was sending the success message, along with ID back into the notification. It's just a matter of capturing it and turning it into a URL so the notification becomes an href. Hope this clarifies.. would love to see if we can do that, because this is 100% API.

Link to comment
7 hours ago, Yourname said:

but that's not a webpage.


What's the screenshot of, then?


7 hours ago, Yourname said:

would love to see if we can do that, because this is 100% API.


So, you do have a JSON response, then. I can't tell you exactly how to do it because I don't have Zapier or a test URL, but basically you need to open the URL in code and parse the response. In Python that would be something like:

from __future__ import print_function

import json
import os
from urllib import urlopen
import sys

# Get URL from workflow/environment variable
URL = os.getenv('ZAP_URL')

def log(s, *args, **kwargs):
    """Log to STDERR."""
    if args:
        s = s % args
    elif kwargs:
        s = s % kwargs
    print(s, file=sys.stderr)

    r = urlopen(URL)
    code = r.getcode()
    log('[%d] %s', code, URL)
    if code > 200:
        raise Exception('request failed')

    # Parse payload and print wanted data, which
    # passes it to the next workflow action
    data = json.load(r)
    print(data['id'], end='')

except Exception as err:


Link to comment

Thanks @deanishe! Python makes sense for parsing - didn't think of that at all. 


So when I realized there needs to be a parser, I realized I have Pushbullet on my Google Chrome, and on my phone. I ended up sending the newly created Asana task ID to Pushbullet instead, and now I get a clickable notification.


Now I can create a task, and click into it if I need to assign the task to a project, add context, etc.


Screen Shot 2019-10-01 at 4.57.53 AM.png

Screen Shot 2019-10-01 at 4.58.09 AM.png

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...