Detecting when someone starts at the subject line & adding one if so

I like to make snippets I create as dynamic as possible. Sometimes people may be using it in a reply to an email or they're adding it to an email they have already started to draft, in both cases they likely have a subject line. Other times they may be starting with a blank email so often include an option that allows them to start at the subject line where the snippet will paste in the pre-written subject line and then the rest of the content will go into the body of the email. This is done by using the toggle feature (asking if the person is starting at the subject line) and the +tab feature (if they are starting at the subject line in order to paste text into the subject line first and then the body).

This workaround has been working pretty well for me but I feel it's easily missed by users (or just clutters up the notes/instructions of the snippet when there are other toggles included).

It would be great if Text Blaze could detect if someone is starting from the subject line and insert a pre-written one if so. If there is no pre-written one, it would just skip to the body or give the user a warning/reminder to add one themselves.

Hi @Vanessa_Assaro-Aluis ,
Welcome to Text Blaze community.

If you are using Gmail, then something like this should solve the problem using Gmail command pack
You have to assume subject is empty if the command pack returns "New Message". This is a limitation due to how Gmail is.

{if: len({gmail-subject})==0 or {gmail-subject} == "New Message"}Some subject{key: tab}{endif}Some email body

or you can use your own selector. You have to add a condition to your shortcut like I did for /do

{if: len({site: text; selector=[name="subjectbox"]})==0 or {site: text; selector=[name="subjectbox"]} == "/do"}Some subject{key: tab}{endif}Some email body

Hope this helps.


Trying to use your 2nd example to set up a snippet depending on where the snippet is inserted... but struggling to get my head around it. I don't suppose you can help guide me through the logic of this one?

Can you give me the information why the example is not working or where you are trying to use it.

Blimey... that was quick....I'm trying to do different behaviour depending on where I use the shortcut... But I don't think I'm reading your if statement correctly so not sure what parts I should replace with what... i.e the reference to the /do part.

@Rowan_Ward Vinod's example is specifically using the CSS selectors that map to Gmail's subject line field, so if you're trying to use his example snippet in another system, it won't work.

To break down what his snippet is doing:

  • opens an IF statement
  • the IF statement is evaluating 2 possible conditions, separated by the OR operator:
    -- len({site: text; selector=[name="subjectbox"]})=0: is the length of the text in the CSS selector called "subjectbox" 0?
    -- {site: text; selector=[name="subjectbox"])}="/do": alternatively, if there's text in the field called subjectbox, is it just the shortcut for this snippet ("/do")?
  • if either of those 2 conditions are true, then it adds "Some subject" and presses tab
  • otherwise, it just assumes you're in the body of the email and adds "Some email body"

You can recreate this snippet by updating the two {site: text} commands to use the CSS selectors that correspond to your system's subject field.

If you need any help with this, you've got my email and I think my scheduling link -- set up some time for us to talk live!


Perfecto... Thank you... It was the logic I was after... I will try and challenge myself to see if I can reuse this logic & if not, I will reach out. Thanks both :slight_smile:

All sorted... Thank you...I'll continue to play and tweak... But I flipped it to focus 1st on the body, and if else go to the "To" field.... A few more tweaks before I publish, but the logic helped me to work through my needs. Next steps is to see if the imported snippet can be dynamic, depending on the input, but enjoyed troubleshooting and learning this evening :grinning:

{if: len({site: text; selector=.email__message-editor})="Type the content of your email here" or {site: text; selector=.email__message-editor} = "/2rwtest"; trim=yes}{import: /req1; trim=left}{else}{import: /subjectline}{import: /req1}{endif}