Jump to content
Dreamisdead

Script Filter Contact Output

Recommended Posts

Hey!

My workflow parses query result from web request to internal database of employees to quickly find the right person.

 

Thing is I want to output person like a contact - to quickly compose mail or message or call that person, based on retrieved info.

 

1. So I get query result from api,

 

Like this: 1648694393_2019-05-1116_52_11.png.1df33b544ee1b4c2c28d5fbc10e0dbbd.png

 

 

2. Then when I press enter on the right result I want to get full contact info (same as default contacts search in alfred)

Like this: contacts-viewer-address.png

 

 

Script Search filter only allow to specify file or default in json.

What can I do to achieve result like this? Is this possible?

Share this post


Link to post
6 minutes ago, Dreamisdead said:

What can I do to achieve result like this?

 

Add a second Script Filter downstream from your first one that lists the selected contact's details.

 

As you say, you can't return items of type "contact", so you can't use Alfred's contact viewer with your own data. Your only option is to create your own viewer based on a Script Filter. That or integrate your employee directory into Contacts.app.

Share this post


Link to post
12 minutes ago, deanishe said:

 

Add a second Script Filter downstream from your first one that lists the selected contact's details.

 

As you say, you can't return items of type "contact", so you can't use Alfred's contact viewer with your own data. Your only option is to create your own viewer based on a Script Filter. That or integrate your employee directory into Contacts.app.

 

Thank you for reply, I’m using your python lib btw, very impressed! Awesome job!

 

So it should not be too difficult to replicate “contacts like” viewer using second script filter ?

Share this post


Link to post
Posted (edited)
40 minutes ago, Dreamisdead said:

Awesome job!

 

Thanks!

 

40 minutes ago, Dreamisdead said:

So it should not be too difficult to replicate “contacts like” viewer using second script filter ?

 

Not really. Pass the details to the second Script Filter via variables or arg (perhaps as JSON-encoded data), or read them from cache. After that, it mostly depends which actions you want to connect the contacts to. For phone and email, I think you can just tell Alfred to open a tel: or mailto: URL respectively. Message/IM might be a bit trickier (dunno; never tried it).

Edited by deanishe

Share this post


Link to post

I don't know if I get it right, but if you want to search for a contact and get the output like the default contact search of Alfred, then you can search your address book database using a File Filter based on your contact name that you get from your first script filter and send the found contact to open in Alfred (if Alfred is set to "Open Contacts in Alfred").

 

What I mean is:

[Your Script Filter] -> {query is now your contact name} -> [The File Filter that gives you a list of matches] -> [Open the match in Alfred]

 

Here is an example: https://d.pr/f/yIPU1v

 

Just change the "ys" keyword object to your Script Filter

 

If you Employee name is always the first in the list then you can rapidly press a second Enter to go directly to the Alfred Contact Viewer (or automate this second Enter key press)

 

It could be done by using a second Script Filter, but if you want to access your contacts database directly then I think using the File Filter could be an easy way

 

To give credits, my File Filter that search the Address Book database is a modified version of @Vero workflow that you can find here: 

 

Share this post


Link to post
Posted (edited)

@GuiB Step one:

 

1 hour ago, Dreamisdead said:

1. So I get query result from api,

 

I don't think the contacts are in the Contacts.app database.

Edited by deanishe

Share this post


Link to post

I work at large company with a pretty good staff database api, but strange thing is our carddav integration is very broken, so I can’t query macOS contacts app directly.

 

And using web is just not as fast as Alfred search. I also prefer to have single place where I store my important contacts (one address book).

 

I think I will just append filter item to add person I found using workflow and api to contacts if I really need to.

 

Anyway, thanks for answers guys!

I’ll be coding now :)

Share this post


Link to post

@deanishe, yes, it wasn't clear if it was possible to retreive the contact information from the api, so I gave an alternative if @Dreamisdead could only get the name of the contact and have the contact information from is own Address Book database... But yes, if everything is inside your API, then yes it shouldn't be too difficult to write a script filter to extract the full contact information from the API.

 

Also, a little tip, if you want to access the email or phone or something directly from your first Script Filter, you can make use of your modifier keys to access them directly. For example: CMD+Enter to get the email address and put it in your clipboard directly or opening a new email with this address directly... it's up to you!

 

Happy coding! :)

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...