Email flow with automatic response

Post Reply
rungew
Newbie
Posts: 1
Joined: Tue Nov 18, 2014 5:50 pm

Email flow with automatic response

Post by rungew »

hello,



I have the following scenario:



The customer sends an e-mail. The subject line is checked for two words. In this example, Abc and Def. Are these the subject of the customer, he receives a confirmation by mail. The responses are composed also of variables.



It happens that the subject of the customer varies in the spelling, e.g. small or big letters. The idea now was to convert everything to little letters.



After a long effort you can solve this with variables directly on the connection

[Email.Subject: Case = lower] contains VALUE



Previously I wanted to solve this case with regex. A /ABC/i would have been sufficient.



Unfortunately, I was unable to establish the relation to the subject at any point in any way.



So I took my JavaScript:



function jobArrived( s : Switch, job : Job )

{

var betreff = job.getVariableAsString("[Email.Subject]");

var klein = betreff.toLowerCase();

job.setPrivateData("[Email.Subject]", klein);

job.sendToSingle( job.getPath() );

}



Now my questions:



regex:

How can I make reference to the variable [Email.Subject]?

Where do I configure the regex?



Java Script:

How can I make reference to the variable [Email.Subject]?

How can I bring the changed subject again to the flow so that it can be used?



Thanks for your reply...



Regards

rungew
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Email flow with automatic response

Post by gabrielp »

rungew wrote: var klein = betreff.toLowerCase();

job.setPrivateData("[Email.Subject]", klein);


That's pretty confusing man. Don't set your privatedata key as a Switch variable name.



Use something like:

job.setPrivateData("ModifiedEmailSubject", klein);



A better practice is to actually add a flow element property called "EnterPrivateDatakey" or something so the user of your script can choose what they want the key to be. Then you would:



var PrivateDataKey = s.getPropertyValue( "EnterPrivateDatakey" );

job.setPrivateData(PrivateDataKey, klein);



Then (assuming your PD key is "ModifiedEmailSubject"), if the privatedata is set, you can access it in a script like this:

var klein = job.getPrivateData("ModifiedEmailSubject")



Or within Switch's custom variable definition screen:

[Job.PrivateData:Key=ModifiedEmailSubject]



Hope this helps
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
freddyp
Advanced member
Posts: 1023
Joined: Thu Feb 09, 2012 3:53 pm

Email flow with automatic response

Post by freddyp »

You are putting a Switch variable into private data. It is converted to lowercase, but what have you gained? Nothing, because you can use a variable in lowercase everywhere.



I am not completely certain what you want to do, but I think your solution could be in setting the operator of the condition to "Matches" instead of "Equal to". So, [Email.Subject} - Matches - "[Aa][Bb]Cc].*[Dd][Ee][Ff]" (or whatever regex it is you need). Then you can easily distinguish between mail subjects that have the correct content and mail subjects that do not.



Freddy
Post Reply