lemikeone Posted January 9, 2021 Share Posted January 9, 2021 Hi everyone, I love using Alfred every day, and one of my favourites' functionalities are the snippets. One thing that make me stick to Gorgias Templates, is the possibility to use Gmail recipient's name in templates by using {{to.first_name}}. That looks like this : https://streamable.com/dn0vsx I know that it is not possible to do that with the basic Snippet functionality in Gorgias, but I just discovered the Snippet Triggers, so I was thinking that it could be feasible with it. Do you have any idea how I could use recipient's name in Gmail in my Alfred snippets using a workflow element? Thanks in advance! Link to comment
deanishe Posted January 9, 2021 Share Posted January 9, 2021 7 minutes ago, lemikeone said: Do you have any idea how I could use recipient's name in Gmail in my Alfred snippets using a workflow element? I'm afraid this isn't possible without some fairly serious scripting. Gorgias is an extension running inside your browser, so it can easily read the page you're looking at. Alfred (or any other external application) can’t just reach inside your browser like that. It is probably possible to do, but varies from tricky to very difficult depending on which browser you're using. And it will probably break the next time Google changes Gmail. lemikeone 1 Link to comment
lemikeone Posted January 9, 2021 Author Share Posted January 9, 2021 Thanks a lot for taking the time to answer Deanishe ! Let's hope someone will find a solution one day Link to comment
deanishe Posted January 9, 2021 Share Posted January 9, 2021 Just now, lemikeone said: Let's hope someone will find a solution one day Not if you don't tell us which browser you're using… Link to comment
lemikeone Posted January 9, 2021 Author Share Posted January 9, 2021 Sorry about that, I am using Chrome on Mac ! Link to comment
deanishe Posted January 9, 2021 Share Posted January 9, 2021 This AppleScript should return the contents of the To: field if you're composing a Gmail message in the active browser tab in Chrome. tell application "Google Chrome" tell active tab of window 1 to return execute javascript "document.querySelector('div.aDm>span').innerText" end tell Execute it in a Run Script action with Language = "/usr/bin/osascript (AS)". lemikeone 1 Link to comment
lemikeone Posted January 9, 2021 Author Share Posted January 9, 2021 (edited) Wow that works ! Thanks ! I just need to find a way to use only the part before the first space, to use only the surname Edited January 9, 2021 by lemikeone Link to comment
deanishe Posted January 9, 2021 Share Posted January 9, 2021 Just now, lemikeone said: I just need to find a way to use only the part before the first space I know. I thought that would be an interesting exercise for you now the tricky part is done lemikeone 1 Link to comment
lemikeone Posted January 9, 2021 Author Share Posted January 9, 2021 You're right I'll try to find a solution, and I'll publish it here if I do. Thanks, Link to comment
lemikeone Posted January 9, 2021 Author Share Posted January 9, 2021 I found a solution using the utilities "Split Arg to Vars" ! Thanks again for the precious help. deanishe 1 Link to comment
lemikeone Posted January 10, 2021 Author Share Posted January 10, 2021 As the workflow could be helpful for some other users, I just published it on Github : https://github.com/lemikeone/alfred-recipient-name I added a capitalization of the first letter in it. If anyone wants to contribute in any way, do not hesitate! Link to comment
deanishe Posted January 10, 2021 Share Posted January 10, 2021 49 minutes ago, lemikeone said: I just published it on Github Bear in mind that it's very likely to break as soon as Google changes anything in Gmail. You'll need to know CSS selectors and how to use your browser's inspector if you want to be able to fix it. Link to comment
lemikeone Posted January 10, 2021 Author Share Posted January 10, 2021 Of course, I should be able to update the CSS selectors in the script if needed. Thanks, 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