paulminors Posted January 8, 2019 Share Posted January 8, 2019 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
deanishe Posted January 8, 2019 Share Posted January 8, 2019 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
paulminors Posted January 8, 2019 Author Share Posted January 8, 2019 Thanks for the response. This is my own workflow. Does this screenshot help? I'm triggering Zapier to create the Asana task. Link to comment
deanishe Posted January 8, 2019 Share Posted January 8, 2019 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
paulminors Posted January 9, 2019 Author Share Posted January 9, 2019 Ah sorry. Here you go, here is a link to download my workflow: https://www.dropbox.com/s/i8dlbj975m95sgo/Create Asana task.alfredworkflow?dl=0 I'm on the latest version MacOS/Alfred. Link to comment
deanishe Posted January 9, 2019 Share Posted January 9, 2019 (edited) 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 January 9, 2019 by deanishe Link to comment
paulminors Posted January 9, 2019 Author Share Posted January 9, 2019 (edited) 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! deans-test Edited January 9, 2019 by paulminors Link to comment
deanishe Posted January 9, 2019 Share Posted January 9, 2019 Change the echo line to echo -n "{query}" Link to comment
paulminors Posted January 9, 2019 Author Share Posted January 9, 2019 Thanks for that, it's working perfectly now. Weird though - when I put in {query} before, it wasn't working. I must have done something wrong. Thanks again! Link to comment
paulminors Posted January 10, 2019 Author Share Posted January 10, 2019 Ah sorry, just one more thing on this. I notice that with an Alfred Query that has spaces, the notification comes through encoded. Do you know how I would avoid this? Link to comment
deanishe Posted January 10, 2019 Share Posted January 10, 2019 7 hours ago, paulminors said: Do you know how I would avoid this? You're doing the encoding yourself in the workflow: That's not a good way to URL-encode a query: spaces aren't the only characters that need replacing. Here's a fixed version that shows the query in the notification and properly URL-encodes the query. Link to comment
paulminors Posted January 10, 2019 Author Share Posted January 10, 2019 This is great, thanks again for your support! Link to comment
Yourname Posted September 30, 2019 Share Posted September 30, 2019 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. Link to comment
deanishe Posted September 30, 2019 Share Posted September 30, 2019 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
Yourname Posted October 1, 2019 Share Posted October 1, 2019 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
deanishe Posted October 1, 2019 Share Posted October 1, 2019 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) try: 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: log(err) sys.exit(1) Link to comment
Yourname Posted October 1, 2019 Share Posted October 1, 2019 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. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now