Page 1 of 1

Email flow with automatic response

Posted: Tue Nov 18, 2014 6:39 pm
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

Email flow with automatic response

Posted: Tue Nov 18, 2014 7:39 pm
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

Email flow with automatic response

Posted: Tue Nov 18, 2014 9:24 pm
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