Parsing a six digit number from a text and sending back to sender?

321 views
Skip to first unread message

dkhu...@gmail.com

unread,
Apr 11, 2018, 8:32:23 PM4/11/18
to Automate
Hi, total noob here trying to get an idea if I am able to do this with the Automate app. 

I receive multifactor authentication texts that require me to text back a number, that is given in the sent text, so that I am able to login. 
The sender number is one of those five digits numbers and is not always the same. However, the number I need to text back is always a six digit number. 

So what I was thinking was if it would be possible for the flow to check if there is a six digit number within the text. If so, then take that number and send it back to the sender. If there is no six digit number, then don't do anything.  

thanks in advance for your thoughts and help! 

 

Henrik "The Developer" Lindqvist

unread,
Apr 12, 2018, 12:20:46 AM4/12/18
to Automate
  1. SMS received; (output variable) message: msg
  2. Variable set; variable: num, value: matches(msg, ".*(\\d\{6}).*")[1]
  3. Expression true; expression= num
  4. SMS send; (input argument) message= num

dkhu...@gmail.com

unread,
Apr 12, 2018, 6:26:15 AM4/12/18
to Automate
Thank you Henrik!

It's getting an error on the SMS send. Looks like it needs the phone number, which is whoever the original sender is.
And I should also mention that the text also contains text in addition to the six digit number. Not sure if that matters or not with what you gave me.

Here is the log.

2018-04-12 06:09:58.318 INFO 4@1: Flow beginning
2018-04-12 06:09:58.320 INFO 4@2: SMS received
2018-04-12 06:11:06.823 INFO 4@5: Variable set
2018-04-12 06:11:06.824 INFO 4@6: Expression true?
2018-04-12 06:11:06.825 INFO 4@7: SMS send
2018-04-12 06:11:06.826 FAIL 4@7: com.llamalab.automate.RequiredArgumentNullException: phoneNumber
2018-04-12 06:11:06.827 INFO 4@7: Stopped by failure

Thank you!

Henrik "The Developer" Lindqvist

unread,
Apr 12, 2018, 12:59:52 PM4/12/18
to Automate
Assign a variable name, e.g. pn, to the "Sender phone number" output variable of the SMS received block, then use is as input variable in the SMS send block.

dkhu...@gmail.com

unread,
Apr 12, 2018, 1:39:21 PM4/12/18
to Automate
Thanks! That fixed the error, but looks like it is stopping at the expression and the text isn't being sent out. Not sure if there is a way for me to attach the .flo here.

2018-04-12 13:28:05.876 INFO 11@1: Flow beginning
2018-04-12 13:28:05.876 INFO 11@2: SMS received
2018-04-12 13:28:37.902 INFO 11@5: Variable set
2018-04-12 13:28:37.903 INFO 11@6: Expression true?
2018-04-12 13:28:37.904 INFO 11@0: Stopped at end

dkhu...@gmail.com

unread,
Apr 12, 2018, 1:43:20 PM4/12/18
to Automate
Privileges to make phone calls and send SMS messages and access SMS messages, call log, and phone state are all checked. 

Henrik "The Developer" Lindqvist

unread,
Apr 12, 2018, 2:17:30 PM4/12/18
to Automate
Reply all
Reply to author
Forward
0 new messages