forward sms if body begins with ... and contains "@"

1,653 views
Skip to first unread message

Polar

unread,
May 11, 2013, 11:25:55 AM5/11/13
to tas...@googlegroups.com
Hi,

I am trying to do this:

  1. If a SMS is received
  2. forward SMS to number ####
  3. with same body %SMSRB
  4. if %SMSRB < test
From the list from Condition Operators I can not define the operator I need. What I would need to have this working is:

  • %SMSRB begins with "test " (notice the extra space after the last letter)
  • a second test: %SMSRB contains "@"
Is this possible with the current available operators? If not, any suggestion for a work-around?

Matt R

unread,
May 11, 2013, 11:47:00 AM5/11/13
to tas...@googlegroups.com
Look at pattern matching in the user guide. Most importantly, an asterisk is a wildcard that matches anything.

Matt

Christopher Maisch

unread,
May 11, 2013, 12:01:21 PM5/11/13
to tas...@googlegroups.com
You've posted twice about similar problem not cool.

Anyway, what I think you want is: If %SMSRB ~ X(your defined text, remember to have "*" at the beginning and end of your text, send %SMSRB to X phone number. Don't use = because it means that the variable must equal a number and not a predefined text

Polar

unread,
May 11, 2013, 12:37:32 PM5/11/13
to tas...@googlegroups.com
Sorry for the double post. My first post did not show. I assumed I did not completed the post, and therefor posted again. It was only then both my posts became visible. It was unintentional...

Thank you both Matt R and Christoper Maisch. I just tested the pattern matching. I am having some issues here.

When I enter :

~ test : result = green
~ test* : result = green
~ test*@ : result = red
~ test*@* : result = red
~ test*a : result = red

So I used the examples from the user guide:

Matt R

unread,
May 11, 2013, 4:11:36 PM5/11/13
to tas...@googlegroups.com
What are you comparing it to? "test123"?

Matt

Bob Hansen

unread,
May 11, 2013, 5:17:09 PM5/11/13
to tas...@googlegroups.com
If I am understanding what you are doing, it looks like you are trying to look for the work 'test' and the '@' symbol both at the same time. 
I would suggest you do it in to separate checks, first one for starting with 'test ' and the second one to search for '@' anywhere in the message.
A1:  If %SMSRB ~ test
A2:    if %SMSRB ~ @
A3:    < forward sms >

In the above example this will forward the message, if "test" AND "@" occur anywhere in the message. 

If it is required that "test" be the very first word, the you would need to do a variable section to check the for the first word, so the actions would look like:

A1: Variable Set [ Name:%Tmp To:%SMSRB Do Maths:Off Append:Off ]
A2: If [ %Tmp ~ @ ]
    A3: Variable Section [ Name:%Tmp From:1 Length:5 Adapt To Fit:Off Store Result In: ]
    A4: If [ %Tmp ~ test ]
        A5: <forward msg>


Polar

unread,
May 11, 2013, 6:16:40 PM5/11/13
to tas...@googlegroups.com
@Bob Hansen:

Indeed, "test" is the first condition. I will be (as usual) receiving lots of SMS'es on my phone. But it is only in case I receive a message that begins with the word "test" (or any other word that I would wish to define) that I want this message to be forwarded in the same format as it came in. ("keyword" "second word that MUST  contain @") (PS: this will be an email address, so I actually need could optimize the second check to see if it has the valid "@somedomain.tld" format). But for now a check on "@" would be a good start.

What I don't get is if your suggested A2 is the "if" section that I see when creating A1, at the bottom of the screen. Because if so, when I store it and return to the TaskEdit screen, I see 1. Variable Set %Tmp, %SMSRB     if %Tmp ~ @           followed by a red mark (I assume this means "Houston we have a problem). If I remove the if mark, there is no color marker, not even a green one.

If the A2 "if" is a total seperate task, where in the menu can I find it then?

Thx for your time to take a look at this :o)

@Matt R: yes as described above.

Polar

unread,
May 11, 2013, 6:16:43 PM5/11/13
to tas...@googlegroups.com

Matt R

unread,
May 11, 2013, 10:16:59 PM5/11/13
to tas...@googlegroups.com
test*@* is what you want. Make sure what you are reading starts with test and contains @. It should show green. Were you still testing against test123? Because that obviously doesn't have an @ in it.

Matt

Message has been deleted

Bob Hansen

unread,
May 12, 2013, 1:53:31 AM5/12/13
to tas...@googlegroups.com

What I don't get is if your suggested A2 is the "if" section that I see when creating A1, at the bottom of the screen. Because if so, when I store it and return to the TaskEdit screen, I see 1. Variable Set %Tmp, %SMSRB     if %Tmp ~ @           followed by a red mark (I assume this means "Houston we have a problem). If I remove the if mark, there is no color marker, not even a green one.
The red mark indicates that this part of the if condition is currently false - it is not a problem. 
 
If the A2 "if" is a total seperate task, where in the menu can I find it then? <=== Found in Task > If

A1: Variable Set [ Name:%Tmp To:%SMSRB Do Maths:Off Append:Off ]
A2: If [ %Tmp ~ @ ]     <=== This checks for an @ character anywhere in the message.
    A3: Variable Section [ Name:%Tmp From:1 Length:5 Adapt To Fit:Off Store Result In: ]
          The line above will make Tmp equal to the first 5 characters for the %TMP.
    A4: If [ %Tmp ~ test ]    <=== This will check that the first 5 characters of the message are 'test '
        A5: <forward msg>    <=== Only if both If statements are true will this be executed.

The above is an example of nested if statements. These are very useful for checking a series of conditions and only if all are true does the final action execute. It is the same as If (test 1 is true) then if (test 2 is true) then <do something>. This is actually a kind of shortcut for programming because unnecessary endif & else statements are not included.
Maybe it would make more sense to you like this:
A1: Variable Set [ Name:%Tmp To:%SMSRB Do Maths:Off Append:Off ]
A2: If [ %Tmp ~ @ ]
    A3: Variable Section [ Name:%Tmp From:1 Length:5 Adapt To Fit:Off Store Result In: ]
A4: Then   If [ %Tmp ~ test ]
        A5: <forward msg>
A6: Endif
Both Tasks are identical. 

Polar

unread,
May 12, 2013, 6:57:33 AM5/12/13
to tas...@googlegroups.com
@Math R: test123 is only my way of pointing out that I am testing against something. Sorry, should be more clear. I was actually checking against test123, nothing else. But I also tested against *@*, hence changing my parameters :o)

@Bob Hansen: Now we are getting somewhere :o). But there is an issue with the following actions:

A2: If [ %Tmp ~ @ ]           => I changed it to  :  A2: If [ %Tmp ~ *@*.* ]. This because for starters it should not match @, but contain @. For more effiency I modified the matching pattern so it is capable to check if em...@address.com is included.(or at least something that resembles an email address)

A4: If [ %Tmp ~ test ]         => in A3 we say Tmp is 5 characters. In A4 we test the 5 first characters for "test" (only 4 long). I can type an additional space after the last "t". I see Tasker adds it. But when saving it and re-editing it, the space is gone and we are back to a 4 letter word. The setup "check for "test" in a 5 letter string is not working. But check for it in a 4 letter string (From:1 Length:4) works fine. However, it does not allow to filter out bad configured text messages like "testtM...@address.com" or "testM...@address.com" or "testabc MyE...@address.com".

Can it be Tasker can not deal with "spaces" in the variable?

While I was at it, I am looking into a way to send a message to the sender as a confirmation in case the task was successfully processed. And a message "Houston we have a problem, check your message for errors" in case A2 or A4 went wrong. Hey, why not conditional ? If A2 went sour: "Sorry, please check your email address." If A4 went wrong "Sorry, unknown code". Should that be placed right under A2? Like :

A1: Variable Set [ Name:%Tmp To:%SMSRB Do Maths:Off Append:Off ]
A2: If [ %Tmp ~ *@*.* ]     

A2.2: ! If [ %Tmp ~ *@*.* ] <== exlamation mark : if no email address is found, then do A2.3 which could be something like send message to %sendernumber with body "Sorry check email address".

A2.3: send SMS
    A3: Variable Section [ Name:%Tmp From:1 Length:5 Adapt To Fit:Off Store Result In: ]
     A4: If [ %Tmp ~ test ] 
A4.1 ! if [ %Tmp ~ test ]    <==  if code not recognized, send A4.2 sms to sender "sorry code unknown"
A4.2 send SMS
        A5: <forward msg>    <=== Only if both If statements are true will this be executed.

Sending these 2 additional messages is not really a must, but would be nice to have a system that is able to do it. The challenge will be how to organize it when managing multiple codes or key words, but I guess I can use A4
  • Magic/Yellow/testxx/ as long as I use equal long words that will fit my Tmp Length xx. 

But first things first. "test " with space after the last letter. That is the issue. Could the hex code for "space" do the trick? I guess Tasker looks at the letter, rather then interpreting a hex code.

Regards, and enjoy your weekend :o)

Polar

Bob Hansen

unread,
May 12, 2013, 11:08:19 AM5/12/13
to tas...@googlegroups.com

A2: If [ %Tmp ~ @ ]           => I changed it to  :  A2: If [ %Tmp ~ *@*.* ]. This because for starters it should not match @, but contain @. For more effiency I modified the matching pattern so it is capable to check if em...@address.com is included.(or at least something that resembles an email address)

Good point about the %Tmp ~ *@* 
Does your new A2 do exactly what you want it to do?
Did you test it?

My goal is help YOU do this. I want to help you learn some of my troubleshooting methods.
I would test this by making a Test Task which would simply be 

Test Task (57)
A1: Variable Set [ Name:%Tmp To:My test song @email.com Do Maths:Off 
Append:Off ]
A2: If [ %Tmp ~ *@*.* ]
A3: Flash [ Text:It matches Long:On ]
A4: Else
A5: Flash [ Text:No match Long:On ]

Use the task "play" button to force the task to run and observe the results. 
Change the test text in the Variable Set to try different possibilities.

A4: If [ %Tmp ~ test ]         => in A3 we say Tmp is 5 characters. In A4 we test the 5 first characters for "test" (only 4 long). I can type an additional space after the last "t". I see Tasker adds it. But when saving it and re-editing it, the space is gone and we are back to a 4 letter word. The setup "check for "test" in a 5 letter string is not working. But check for it in a 4 letter string (From:1 Length:4) works fine. However, it does not allow to filter out bad configured text messages like "testtM...@address.com" or "testM...@address.com" or "testabc MyE...@address.com".

You're right in your analysis of that check. Quite frankly, I'm not sure how to resolve this at the moment.

Can it be Tasker can not deal with "spaces" in the variable? <=== Good news, No it can't be!

There is always a way, you just have to find it.
Her is what I did. I created a another Test Task like this:

Test Task (57)
A1: Variable Set [ Name:%Tmp To:Test hkjh Do Maths:Off Append:Off ]
A2: Variable Section [ Name:%Tmp From:1 Length:6 Adapt To Fit:Off Store 
Result In: ]
A3: Flash [ Text:%Tmp Long:On ]
A4: If [ %Tmp ~ Test * ]
A5: Flash [ Text:It matches Long:On ]
A6: Else
A7: Flash [ Text:No match Long:On ]

This works, so instead of checking for "Test", we can check for "Test *". The addition of the space and * forces a check for a space character :>)

Oh NO! It begins - wandering requirements - the bane of all developers ;>)

While I was at it, I am looking into a way to send a message to the sender as a confirmation in case the task was successfully processed. And a message "Houston we have a problem, check your message for errors" in case A2 or A4 went wrong. Hey, why not conditional ? If A2 went sour: "Sorry, please check your email address." If A4 went wrong "Sorry, unknown code". Should that be placed right under A2? Like :

A1: Variable Set [ Name:%Tmp To:%SMSRB Do Maths:Off Append:Off ]
A2: If [ %Tmp ~ *@*.* ]     

A2.2: ! If [ %Tmp ~ *@*.* ] <== exlamation mark : if no email address is found, then do A2.3 which could be something like send message to %sendernumber with body "Sorry check email address".

A2.3: send SMS
    A3: Variable Section [ Name:%Tmp From:1 Length:5 Adapt To Fit:Off Store Result In: ]
     A4: If [ %Tmp ~ test ] 
A4.1 ! if [ %Tmp ~ test ]    <==  if code not recognized, send A4.2 sms to sender "sorry code unknown"
A4.2 send SMS
        A5: <forward msg>    <=== Only if both If statements are true will this be executed.
 
 
Sending these 2 additional messages is not really a must, but would be nice to have a system that is able to do it. The challenge will be how to organize it when managing multiple codes or key words, but I guess I can use A4
  • Magic/Yellow/testxx/ as long as I use equal long words that will fit my Tmp Length xx. 

Ok.... after everything else is working :>) 
 
But first things first. "test " with space after the last letter. That is the issue. Could the hex code for "space" do the trick? I guess Tasker looks at the letter, rather then interpreting a hex code.
There's more than one way to skin a cat! (You ever wonder where the heck that phrase came from?... kinda creepy.) 

Regards, and enjoy your weekend :o)

Polar

Thanks. You enjoy yours too.  

Polar

unread,
May 12, 2013, 2:46:50 PM5/12/13
to tas...@googlegroups.com


On Sunday, May 12, 2013 5:08:19 PM UTC+2, Bob Hansen wrote:


Good point about the %Tmp ~ *@* 
Does your new A2 do exactly what you want it to do?
Did you test it?
Yep, and it works. "test my@emailcom" is flagged. 

My goal is help YOU do this. I want to help you learn some of my troubleshooting methods.
I appreciate this. Did some basic prg and old school cobol in the old days, but that is ages ago :o)
 
This works, so instead of checking for "Test", we can check for "Test *". The addition of the space and * forces a check for a space character :>)


Cute, now why didn't I think of this ??
 
Oh NO! It begins - wandering requirements - the bane of all developers ;>)

While I was at it, I am looking into a way to send a message to the sender as a confirmation in case the task was successfully processed. And a message "Houston we have a problem, check your message for errors" in case A2 or A4 went wrong. Hey, why not conditional ? If A2 went sour: "Sorry, please check your email address." If A4 went wrong "Sorry, unknown code". 

I think I did it :o) See below...
 

A1: Variable Set [ Name:%TmpBody To:%SMSRB Do Maths:Off Append:Off ]
A2: Variable Set [ Name:%TmpFrom To:%SMSRF Do Maths:Off Append:Off ] 
A3: If [ %TmpBody ~ *@*.* ]     
A4: else 
A5: Send SMS [ number: %TmpFrom Message: "Sorry check email address".]
A6: End if
A7: Variable Section [ Name:%TmpBody From:1 Length:6 Adapt To Fit:Off Store Result In: ]
A8: If [ %TmpBody ~ test * ] 
A9: Send SMS [ number: %555 55 555 Message: "%SMSRB".]
A10: Else
A11: Send SMS [ number: %TmpFrom Message: "Sorry unknown code".]

Not sure if I need a End If here, but it works :o) !!! One thing that remains is a full proof check on the "test em...@address.com". The used procedure "test *" is close, but it leaves opening for typos by the user. If the user sends an SMS containing "test e em...@address.com" the mail server is going to have a problem. So I should look into how to check for blanks in the email address. An even more foul proof method of testing would be do to a lookup of the domain name. I doubt if Tasker can handle this, but I found some info on using java in Tasker. Not likely I will be able to pull that of, but if anyone wants to take the challenge? Nothing as boring as a subscriber that subscribes to a newsletter or promotion, and never hears again from the promoter. Just because the system could not check if the e-mail address was correct. (j...@gmail.com vs j...@gnail.con). Just an idea for improvement ;o)

The challenge will be how to organize it when managing multiple codes or key words, but I guess I can use A4
  • Magic/Yellow/testxx/ as long as I use equal long words that will fit my Tmp Length xx. 

Next step could be to build a nice interface around this. But that is another story ;o)

Thank all for the input and support. Looking forward to your comments!

Polar

unread,
May 13, 2013, 11:28:29 AM5/13/13
to tas...@googlegroups.com
Did some cleaning up. I found that every message was filtered. A keyword check for "test" was not sufficient, because "Hey Joe, let's grab a beer" would be considered as "wrong keyword". So the only way to have a reasonable way to filter out private messages from those that need to go through the script was to include a special sign as signature. I chose "#" as the first sign in a key word : "#test#.

Other then that I found that I needed to tell the script to STOP after completing check#1. If there is an error, just let the sender know, and then nothing more is to be done. If condition #1 is OK, but #2 is wrong, let the sender know and stop there. Etc. So, here is the new version, tested and up and running:

A1: Variable Set [ Name:%TmpBody To:%SMSRB Do Maths:Off Append:Off ]  => remember the text body
A2: Variable Set [ Name:%TmpFrom To:%SMSRF Do Maths:Off Append:Off ]  => remember the senders phone number
A3: If [ %TmpBody !~ #* ]  => If the body does not begin with #
A4: Stop => stop right here, this is most likely an ordinary SMS, not for me to work with.
A5: End If
A6: If [ %TmpBody !~ *@*.* ]  => If A3 was not triggered, this is the next check. Is the body missing something that resembles an email address?
A7: Send SMS [ number: %TmpFrom Message: "Sorry check email address".] => If so, warn the sender about this.
A8: Stop => and stop right here, no further action required.
A9: End If
A10: Variable Section [ Name:%TmpBody From:1 Length:7 Adapt To Fit:Off Store Result In: ]  => If A6 was not triggered, let's focus on the first 7 letters.
A11: If [ %TmpBody ~ #test * ]  => if the text body begins with "#test *"
A12: Send SMS [ number: %555 55 555 Message: "%SMSRB".] => ... we have a winner :o). This messages needs to be forwarded.
A13: Else
A14: Send SMS [ number: %TmpFrom Message: "Sorry unknown Keyword".]  => If A11 was not true, then the keyword most likely contains a typo. Inform the sender about it.

Polar

unread,
May 15, 2013, 10:30:29 AM5/15/13
to tas...@googlegroups.com
So it's time to experiment some more. The tasks I have entered are working nicely. I want to make a scene so I can make my very fist app :o)...

The results I got from googling for "tasker scenes data entry" made it not very clear for me if I could store the entered data as a "Variable Set %TmpKeyWord" or "Variable Set %TmpSmsTo". The intention is that the app screen invites to enter the values required to work, and that they are stored. At any given moment it should then be a breeze to add or change a keyword, or change the SmsTo number via the scene.

Can scenes be used this way?

Matt R

unread,
May 15, 2013, 2:44:30 PM5/15/13
to tas...@googlegroups.com
Yes.

Matt

Polar

unread,
Oct 20, 2013, 2:01:22 PM10/20/13
to tas...@googlegroups.com
Hello boys and girls ! With regards to my task as presented below, I was wondering if it is possible to filter a certain part of the body and reuse it in a new message. Let me explain.

If I have an incoming message like this

SMSRF = 555 55 555
SMSRB = some_code some_...@address.com

I would like to create an action that does this:

Send SMS, Number = TmpFrom, Message = some_text_URL/?some_...@address.com

I've seen it done in perl, but I have no clue how to do this with Tasker. Please your advice.

Many thanks in advance.

Polar

unread,
Oct 21, 2013, 4:27:07 AM10/21/13
to tas...@googlegroups.com
I've been tinkering with the variable settings, and doing some reading at http://www.pocketables.com/2012/10/beginners-guide-to-tasker-part-7-variable-arrays.html. Looks like this is the way to go. What I am trying to figure out is this:

I know that in "A10: Variable Section [ Name:%TmpBody From:1 Length:7 Adapt To Fit:Off Store Result In: ]  => If A6 was not triggered, let's focus on the first 7 letters." the first 7 letters are selected. Since I don't know how long the email address is going to be in the received SMS, what is best practice to look at ALL text? As a test I have now marked the check box "adapt to fit". What does this option do actually? 

Next I modified the outgoing message to:

Send SMS, Number = TmpFrom, Message = some_text_URL/?%arr(<)  => the last argument in my variable should be in theory the email address (SMSRB = some_code some_...@address.com).

But this is not working well... The new message that I received on SMS send looks like this: "some_text_URL/?%arr0"

Any suggestions pls?

On Sunday, October 20, 2013 8:01:22 PM UTC+2, Polar wrote:

If I have an incoming message like this

SMSRF = 555 55 555
SMSRB = some_code some_...@address.com

I would like to create an action that does this:

Send SMS, Number = TmpFrom, Message = some_text_URL/?some_email@address.com

Polar

unread,
Oct 21, 2013, 5:30:26 AM10/21/13
to tas...@googlegroups.com
I changed the code in A10 : "A10: Variable Section [ Name:%TmpBody From:1 Length:9 Adapt To Fit:Off Store Result In: ]  => If A6 was not triggered, let's focus on the first 9 letters. Nine letters because my SomeCode is 1234567 plus one blank = 8, plus some_email_address. Only 9 just to test if it at least would pick up the first character of the email address, or if "adapt to fit" would change the length"

Then:

A13: Send SMS [ number: %TmpFrom Message: "Thank you for your SMS".] => ... Let the sender know that the SMS was OK and accepted.
A14: Stop => ... End of the line
A15: Else
A16: If %TmpBody ~ #234567 * => ... If the received SMS begins with #234567_blank_*
A17: Variable Set, Name %TmpEmail To %arr(<) => ... put everything after the blank (or more correctly, everything after the last blank) into %TmpEmail
A18: Send SMS, Number = TmpFrom, Message = "some_text_URL/?%TmpEmail" => ... Send SMS back to sender in format "http://URL/?the_received_email_address
A19: Stop => ... End of the line
A20: Else => ... in case none of the above conditions were met
A21: Send SMS, Number = TmpFrom, Message = "Sorry, wrong code, try again" => ... Let the sender know that the SMS was not OK
A22: Stop => ... End of the line
A23: End If => ... End of task

The SMS I receive from A18 still looks like this : "some_text_URL/?%arr0" (no email address, just the text arr0)

Brandon Horwath

unread,
Oct 21, 2013, 5:33:42 AM10/21/13
to tas...@googlegroups.com
Okay, first let me say I have NO idea what you want to achieve, let alone why. I'm not even going to speculate.

But, I did catch one part.

Since I don't know how long the email address is going to be in the received SMS, what is best practice to look at ALL text?

That is easily done by tasker using regex.

I think this would be:

^[A-z0-9._%+-]+@(?:[A-z0-9-]+\.)+[A-z]{2,4}$

Test that out. Let me know if it errors and on what. I will try and re-evaluate.

Brandon Horwath

unread,
Oct 21, 2013, 5:45:27 AM10/21/13
to tas...@googlegroups.com
Send SMS, Number = TmpFrom, Message = some_text_URL/?%arr(<) => the last argument in my variable should be in theory the email address (SMSRB = some_code some_...@address.com).

But this is not working well... The new message that I received on SMS send looks like this: "some_text_URL/?%arr0"

Any suggestions pls?

You never created an array.

Your task should be (basically):

If %SMSRB ~R ^[A-z0-9._%+-]+@(?:[A-z0-9-]+\.)+[A-z]{2,4}$
Set %regex to ^[A-z0-9._%+-]+@(?:[A-z0-9-]+\.)+[A-z]{2,4}$
Set %smsrb to %SMSRB
Split %smsrb splitter:optional
Set %forward to %smsrb(?#%regex)
Send SMS, content: %smsrb(%forward)

Polar

unread,
Oct 21, 2013, 7:33:49 AM10/21/13
to tas...@googlegroups.com
@Brandon Horwath: Thank you for your input. I gave it a try, but no SMS is going out when using this setup. Just so you have an idea what I am doing here: I use this to let people subscribe to a mailing list by SMS. (code #test). Required SMS format is "#CODE email". 

By subscribing they get a free downloadable offer (pdf, mp3, ...). The download link is in the email that they will receive. To offer them a download directly to their cell phone, I enable in tasker a new SMS code (#test123). In the email they receive after subscribing is a comment informing them "want to download the digital file to mobil? Send SMS with "#test123 your_email_address" to <my mobil number>. ".  This sms will contain the direct link (URL) combined with their email address (hence http://URL/?email_address) for automatic authentication purpose.

I do some testing along the way, to check if the incoming SMS starts with "#". If not, treat it like an ordinary SMS, nothing to follow up, only for me to read. If it starts with "#" then it must be a short code SMS, and so the second requirement is the email address, so let's check if it has something like " *@*.* ". If not, return an SMS with an error "check email address".

Check if the code is in my list (first on my list is #TEST), if a match, forward the entire SMS to my mailing list SMS gateway provider + send SMS to sender to confirm "ALL GOOD". If the code is #test123 followed by email_address (that last condition is already checked and OK), that is where your suggested change of code would apply.Tasker then finds the email address and returns an SMS telling where to download the file (http://URL/?email_address)

If the receive #code is not in my list, send SMS "wrong code, try again".

All the other scenarios are working. But the http://URL/?email_address feature I am struggling with... No URL_SMS is being sendt. This is what the modified script looks like starting from A16 with your suggested regex solution.

A16: If %TmpBody ~ #test123 * => ... If the received SMS begins with #test123_blank_*
A17: If %SMSRB ~R ^[A-z0-9._%+-]+@(?:[A-z0-9-]+\.)+[A-z]{2,4}$
A18: Variable Set, Name %regex to ^[A-z0-9._%+-]+@(?:[A-z0-9-]+\.)+[A-z]{2,4}$
A19: Variable Set, Name Set %smsrb to %SMSRB
A20: Variable Split, Name %smsrb
A21: Variable Set, Name %forward to %smsrb(?#%regex)
A22: Send SMS, Number TmpFrom, Message %smsrb(%forward)
A23: Stop => ... End of the line
A24: End If => closes A17 If
A25: Else => ... in case none of the above conditions were met
A26: Send SMS, Number = TmpFrom, Message = "Sorry, wrong code, try again" => ... Let the sender know that the SMS was not OK
A27: Stop => ... End of the line
A28: End If => ... End of task , closes A16 If

Polar

unread,
Oct 21, 2013, 10:35:41 AM10/21/13
to tas...@googlegroups.com

@Brandon Horwath: I realy like the foul proof method og using regex. But I am kind of having a hard time getting it to work. So I implemented an easier way, that looks like to be doing the trick right now:

If %TmpBody ~ #test123 *
Variable Set, Name Set %smsrb to %SMSRB
Variable Split, Name %smsrb
Send SMS, Number %TmpFrom, Message "Here is the download link http://some_URL/%smsrb(2)"
Stop

Looking forward to test your regex solution as soon as you can comment on why it possibly is not working the way I used it.

Regards! 

Brandon Horwath

unread,
Oct 21, 2013, 12:43:28 PM10/21/13
to tas...@googlegroups.com
Honestly, that should work.

I used a regex checker and EVERY variation of email address I could think of proved to be a match. Anything that wouldn't resemble an email address does not.

However, I don't believe I considered the possibility of an underscore. That might be the issue.

Let me look into that when I can and get back to you.

Brandon Horwath

unread,
Oct 21, 2013, 12:58:36 PM10/21/13
to tas...@googlegroups.com
Oh, wait... I think I see the issue. I have a modifyer looking ONLY for an email address.

The IF statement should be:

[\#]....... [A-z0-9._%+-]+@(?:[A-z0-9-]+\.)+[A-z]{2,4}$

Thus will match #(any seven characters) email address

But the variable set %regex should still be the same.

I'm still learning regex so as I know more I can be more help to you.

Is there a SPECIFIC format conformity for CODE after #?

Polar

unread,
Oct 21, 2013, 1:24:10 PM10/21/13
to tas...@googlegroups.com
You wrote : "Thus will match #(any seven characters) email address". I assume you mean any 7 characters (for the code) and then followed by an email address.
You wrote : "Is there a SPECIFIC format conformity for CODE after #?". The answer is "Still thinking on how to organize this". The thing is, it started of with a 5 character code, preceeded of a # sign. But then I wanted to offer a free MP3 recording, so the keyword was #MP3 and only 4 long. Then I wanted to offer the request feature for getting the download link by SMS, thus #MP3MOB was born, with 7 long. This makes it a bit harder to code A10 where I define the first xx characters that we need to take a look at. But it gets more challenging with your 7 dots. How do you handle that? Can you use a wildcard "*" ?

Brandon Horwath

unread,
Oct 21, 2013, 7:41:08 PM10/21/13
to tas...@googlegroups.com
The wildcard IS the seven dots.

Represents ANY character, including whitespace.

Polar

unread,
Oct 22, 2013, 1:35:01 AM10/22/13
to tas...@googlegroups.com
I see :). Will this include f.ex. 4,5 and 6 char codes, whitespace and email? Not familiar with this kind of wildcard :)

Brandon Horwath

unread,
Oct 22, 2013, 8:09:35 AM10/22/13
to tas...@googlegroups.com
I see :). Will this include f.ex. 4,5 and 6 char codes, whitespace and email? Not familiar with this kind of wildcard :)

It should!

Oh, and I checked and I did account for an underscore in the email :-)

Polar

unread,
Oct 31, 2017, 2:59:32 PM10/31/17
to Tasker
Hi all. It has been a while, and have been using this tasker script daily. A big thank you to everyone who helped me putting this together.

I'm interested in trying to add the use of a database. After doing some reading I am still a tad confused about how to implement this.

If I understand it correctly SQLite is default installed on Android. So the first question would be: do I need to install something like a Sqlite editor/manager?

I found an app that does just about what I am looking for, but is missing a few ingredients. Among other things are some subscribe commands in English, and can not be translated. This makes it less interesting to use for me. Also the option to store other information beside email,name and phone numbers is missing. I contacted the programmer, but he was not interested in adding these changes.

So I hope Tasker can come to the rescue :). Not sure.it would be more appropriate to start a new topic, so I'll start here first.

Can this be done with Tasker? Do I need additional software/apps?

Thank you for reading this:).

Reply all
Reply to author
Forward
0 new messages