Check emal for subject line if match -> run task.

Discuss RoboTask here
Post Reply
ryan
Posts: 14
Joined: Wed Aug 24, 2011 4:10 pm

Check emal for subject line if match -> run task.

Post by ryan »

I would like to reboot my raspberry pi by sending a email to a gmail account.
I already have the reboot task set up but can not figure out how to (or if it is possible) to have robotask

1: check a gmail account.
2: If subject = reboot1 -> run rebootpi task
3: delete emails
4: repeat...

Thanks,
Ryan
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Check emal for subject line if match -> run task.

Post by Oleg »

See example below.
It checks INBOX in Gmail server
If it encounter the message with subject "reboot1" it shows the notification and removes the message from server.
You can put the "Start task" action instead of (or after) the notification.

Save the text of the task into a file and use menu Task->import to import ino RoboTask.
Of course you have to specify yourown login parameters in 1-st step.
This task uses IMAP protocol. You have to be ensure that IMAP is turned on on your Gmail account.

Code: Select all

 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|317955339
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task372"
Hide=INTEGER|0
ID=INTEGER|1169879263
LogOnAsUser=INTEGER|1
Name=STRING|"Reboot if subject reboot1"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER

[Actions\Action1]
ActionID=STRING|"A_IMAP_OPEN"
Enabled=INTEGER|-1
Name=STRING|"IMAP Open"
Params=FOLDER

[Actions\Action1\Params]
folder=STRING|"INBOX"
host=STRING|"imap.gmail.com"
password=STRING|"2825928814293282984228557"
passwordmode=STRING|"1"
port=STRING|"993"
SSL=STRING|"1"
user=STRING|"mail.user@gmail.com"

[Actions\Action2]
ActionID=STRING|"A_IMAP_LOOP"
Enabled=INTEGER|-1
Name=STRING|"IMAP Mail loop"
Params=FOLDER

[Actions\Action2\Params]
number=STRING|"msgnum"
subj=STRING|"msgsubj"
usecc=STRING|"0"
usedate=STRING|"0"
useflags=STRING|"0"
usefrom=STRING|"0"
usesize=STRING|"0"
usesubj=STRING|"1"
useto=STRING|"0"

[Actions\Action3]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER

[Actions\Action3\Params]
case=STRING|"0"
operator=STRING|"0"
type=STRING|"0"
value1=STRING|"{msgsubj}"
value2=STRING|"reboot1"

[Actions\Action4]
ActionID=STRING|"A_ROBOTASK_ALERT"
Enabled=INTEGER|-1
Name=STRING|"Show Notification"
Params=FOLDER

[Actions\Action4\Params]
defh=STRING|"1"
defw=STRING|"1"
duration=STRING|"10"
height=STRING|"76"
icon=STRING|"1"
kind=STRING|"0"
message=STRING|"Reboot required"
position=STRING|"3"
title=STRING|"Reboot"
width=STRING|"330"

[Actions\Action5]
ActionID=STRING|"A_IMAP_SETFLAGS"
Enabled=INTEGER|-1
Name=STRING|"IMAP Set Message Flags"
Params=FOLDER

[Actions\Action5\Params]
answered=STRING|"2"
deleted=STRING|"1"
draft=STRING|"2"
flagged=STRING|"2"
msgnum=STRING|"{msgnum}"
recent=STRING|"2"
seen=STRING|"2"

[Actions\Action6]
ActionID=STRING|"A_IMAP_PURGE"
Enabled=INTEGER|-1
Name=STRING|"IMAP Delete Marked Messages"

[Actions\Action7]
ActionID=STRING|"A_LOOP_BREAK"
Enabled=INTEGER|-1
Name=STRING|"Break"

[Actions\Action8]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"

[Actions\Action9]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"

Oleg Yershov
ryan
Posts: 14
Joined: Wed Aug 24, 2011 4:10 pm

Re: Check emal for subject line if match -> run task.

Post by ryan »

Thank You So Much!
I will give this a shot tonight!
ryan
Posts: 14
Joined: Wed Aug 24, 2011 4:10 pm

Re: Check emal for subject line if match -> run task.

Post by ryan »

I imported it But it says no events.

I just copied the text into a notepad file and saved as a .tsk

Image

Edit: I checked my robotask and i do not have Imap options. I am running 5.2.1.681 patch #2 for 5.2 I see Imap was added in 5.8 If i update will I still be ok? I think I tried to update to 6.0 but needed to update my lisence as well?
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Check emal for subject line if match -> run task.

Post by Oleg »

I imported it But it says no events.
You can simply attach Cyclic event with necessary period (for example 2-5 min)
... i do not have Imap options ...
I will write the example with POP3 actions a bit later. It should work.
I think I tried to update to 6.0 but needed to update my lisence as well?
I'm afraid that no. I can say more exact if you tell me your license information to oleg(at)robotask.com or to private message. I can't find your license by your nickname or email.
In any case you can purchase only "1 year of free updates" to use latest version (latest is 6.2 now) See here all payment options
Oleg Yershov
ryan
Posts: 14
Joined: Wed Aug 24, 2011 4:10 pm

Re: Check emal for subject line if match -> run task.

Post by ryan »

You do not need to update it to POP3 I will update the software. It is the least I can do!

ryan
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Check emal for subject line if match -> run task.

Post by Oleg »

Look at this example. Change authentication parameters to yours at 1-st step

Code: Select all

 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|1
CatID=INTEGER|317955339
Comment=STRINGLIST
ContinueOnError=INTEGER|0
Events=FOLDER
ExternalName=STRING|"Task1111"
Hide=INTEGER|0
ID=INTEGER|30082062
LogOnAsUser=INTEGER|1
Name=STRING|"Reboot if subject reboot1 (POP3)"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER

[Actions\Action1]
ActionID=STRING|"A_EMAIL_OPEN"
Enabled=INTEGER|-1
Name=STRING|"POP3 Open"
Params=FOLDER

[Actions\Action1\Params]
host=STRING|"pop.gmail.com"
password=STRING|"2825230356301013035729068"
passwordmode=STRING|"0"
port=STRING|"995"
SSL=STRING|"1"
user=STRING|"gmail.user@gmail.com"

[Actions\Action2]
ActionID=STRING|"A_EMAIL_LOOP"
Enabled=INTEGER|-1
Name=STRING|"POP3 Mail Loop"
Params=FOLDER

[Actions\Action2\Params]
number=STRING|"msgnum"
subj=STRING|"msgsubj"
usecc=STRING|"0"
usedate=STRING|"0"
usefrom=STRING|"0"
usesize=STRING|"0"
usesubj=STRING|"1"
useto=STRING|"0"

[Actions\Action3]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER

[Actions\Action3\Params]
case=STRING|"0"
operator=STRING|"0"
type=STRING|"0"
value1=STRING|"{msgsubj}"
value2=STRING|"reboot1"

[Actions\Action4]
ActionID=STRING|"A_EMAIL_DELETE"
Enabled=INTEGER|-1
Name=STRING|"POP3 Delete Email"
Params=FOLDER

[Actions\Action4\Params]
num=STRING|"{msgnum}"

[Actions\Action5]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""Reboot required"""
Params=FOLDER

[Actions\Action5\Params]
icon=STRING|"1"
msg0=STRING|"Reboot required"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action6]
ActionID=STRING|"A_LOOP_BREAK"
Enabled=INTEGER|-1
Name=STRING|"Break"

[Actions\Action7]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"

[Actions\Action8]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"

[Events]
Event1=FOLDER

[Events\Event1]
Enabled=INTEGER|-1
EventID=STRING|"E_GENERAL_CYCLIC"
Params=FOLDER
UnigueID=INTEGER|16445953

[Events\Event1\Params]
interval=STRING|"300"
notsatrtatactivation=STRING|"0"

Oleg Yershov
ryan
Posts: 14
Joined: Wed Aug 24, 2011 4:10 pm

Re: Check emal for subject line if match -> run task.

Post by ryan »

This worked good BUT did not delete the email. so it just keeps running and rebooting every time it runs.

Any ideas on why or how to delete the email.
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Check emal for subject line if match -> run task.

Post by Oleg »

I tested the task on my Gmail account. It deletes the message successfully.
Maybe you need to tune Gmail settings? See screenshot below
gmailset.png
gmailset.png (36.4 KiB) Viewed 33240 times
Oleg Yershov
ryan
Posts: 14
Joined: Wed Aug 24, 2011 4:10 pm

Re: Check emal for subject line if match -> run task.

Post by ryan »

That did it!1 Thanks!!
Post Reply