Tasker: Read SMS Full Message

This is a very long task that I use when I'm driving. When an incoming text is received, the task will tell me the name (or number) of the sender and then ask if I want to read the message. If I say "yes", then the message is read and then I'm asked if I want to reply to the message. At this point I can say "auto" and a "I'm driving" message will be sent to the sender. Or I can reply with my voice (speaking my message). If I speak the message, it's read back to me (for confirmation) and sent when everything sounds right.

There's a lot of logic and jumping around in this task. One of the things I found out with the Goto statement is that you can go to an action number (the default) or an action label. If you specify a number, then any changes to your code might require a change to all the action numbers. If you specify a label, then you can add or remove lines all you want, as long as you don't remove the label. But you can't see the actual label in the Tasker interface. They show up here on the output, but not in the list of tasks. But I found something that works for me. I set a variable ("where_am_i" -- all lower case so it's local and not global) to the name of the label, and then add a label to that statement. So I can easily tell where the labels are and where my Goto statements will jump to. The variable is never used - just set to the different labels throughout the code and never read. But it makes things easier in the Tasker interface.

Here's the very complex Tasker task for reading and replying to text messages hands free in the car:

Read SMS Full Message (8)
A1: Variable Set [ Name:%needtorestartav To:%AVCONTINUOUS Do Maths:Off Append:Off ] 
A2: AutoVoice Continuous [ Configuration:
Stopping continuous voice recognition  Package:com.joaomgcd.autovoice Name:AutoVoice Continuous Timeout (Seconds):0 ] If [ %AVCONTINUOUS eq true ]
A3: Perform Task [ Name:Get Nickname From Number Priority:%priority Parameter 1 (%par1):%SMSRF Parameter 2 (%par2): Return Value Variable:%name Stop:Off ] 

A4: Variable Set [ Name:%where_am_i To:ask_to_read_message Do Maths:Off Append:Off ] 
A5: If [ %name eq %SMSRF ]
A6: Perform Task [ Name:Phone Number To Text Priority:%priority Parameter 1 (%par1):%SMSRF Parameter 2 (%par2): Return Value Variable:%number Stop:Off ] 
A7: Perform Task [ Name:Get Voice Command Priority:%priority Parameter 1 (%par1):You have a new text message from %number. Do you want me to read the message? Parameter 2 (%par2): Return Value Variable:%cmd Stop:Off ] 
A8: Else 
A9: Perform Task [ Name:Get Voice Command Priority:%priority Parameter 1 (%par1):You have a new text message from %name. Do you want me to read the message? Parameter 2 (%par2): Return Value Variable:%cmd Stop:Off ] 
A10: End If 
A11: Goto [ Type:Action Label Number:%readmessage Label:read_message ] If [ %cmd eq yes ]
A12: If [ %cmd eq cancel | %cmd eq no | %cmd eq no_input_detected ]
A13: Say [ Text:Cancel detected. Engine:Voice:default:default Stream:5 Pitch:5 Speed:5 Respect Audio Focus:Off Network:Off Continue Task Immediately:Off ] If [ %cmd eq cancel ]
A14: Goto [ Type:Action Label Number:%endoftask Label:end_of_task ] 
A15: End If 
A16: Goto [ Type:Action Label Number:%asktoreadmessage Label:ask_to_read_message ] If [ %cmd eq repeat ]
A17: Say [ Text:Command %cmd not recognized. Engine:Voice:default:default Stream:5 Pitch:5 Speed:5 Respect Audio Focus:Off Network:Off Continue Task Immediately:Off ] 
A18: Wait [ MS:250 Seconds:0 Minutes:0 Hours:0 Days:0 ] 
A19: Goto [ Type:Action Label Number:%asktoreadmessage Label:ask_to_read_message ] 

A20: Variable Set [ Name:%where_am_i To:read_message Do Maths:Off Append:Off ] 
A21: Say [ Text:Message is: %SMSRB Engine:Voice:default:default Stream:5 Pitch:5 Speed:5 Respect Audio Focus:Off Network:Off Continue Task Immediately:Off ] 

A22: Variable Set [ Name:%where_am_i To:ask_to_reply Do Maths:Off Append:Off ] 
A23: Wait [ MS:250 Seconds:0 Minutes:0 Hours:0 Days:0 ] 
A24: Perform Task [ Name:Get Voice Command Priority:%priority Parameter 1 (%par1):Reply to the text? Parameter 2 (%par2): Return Value Variable:%cmd Stop:Off ] 
A25: Goto [ Type:Action Label Number:%readmessage Label:read_message ] If [ %cmd eq repeat ]
A26: Goto [ Type:Action Label Number:%replytotext Label:reply_to_text ] If [ %cmd eq yes ]
A27: If [ %cmd eq auto ]
A28: Send SMS [ Number:%SMSRF Message:I am currently driving. I will respond as soon as I can. (automatic message) Store In Messaging App:Off ] 
A29: Say [ Text:Automatic message sent. Engine:Voice:default:default Stream:5 Pitch:5 Speed:5 Respect Audio Focus:Off Network:Off Continue Task Immediately:Off ] 
A30: Goto [ Type:Action Label Number:%endoftask Label:end_of_task ] 
A31: End If 
A32: If [ %cmd eq cancel | %cmd eq no | %cmd eq no_input_detected ]
A33: Say [ Text:Cancel detected. No message sent. Engine:Voice:default:default Stream:5 Pitch:5 Speed:5 Respect Audio Focus:Off Network:Off Continue Task Immediately:Off ] If [ %cmd eq cancel ]
A34: Goto [ Type:Action Label Number:%endoftask Label:end_of_task ] 
A35: End If 
A36: Say [ Text:Command %cmd not recognized. Engine:Voice:default:default Stream:5 Pitch:5 Speed:5 Respect Audio Focus:Off Network:Off Continue Task Immediately:Off ] 
A37: Goto [ Type:Action Label Number:%asktoreply Label:ask_to_reply ] 

A38: Variable Set [ Name:%where_am_i To:reply_to_text Do Maths:Off Append:Off ] 
A39: Perform Task [ Name:Compose Text Message (Known Recipient) Priority:%priority Parameter 1 (%par1):%SMSRF Parameter 2 (%par2): Return Value Variable:%message Stop:Off ] 

A40: Variable Set [ Name:%where_am_i To:end_of_task Do Maths:Off Append:Off ] 
A41: AutoVoice Continuous [ Configuration:
Starting continuous voice recognition without headset
Persistent Notification: true
Notification Title: AutoVoice Continuous 
Notification Text: Listening for commands... Package:com.joaomgcd.autovoice Name:AutoVoice Continuous Timeout (Seconds):0 ] If [ %needtorestartav eq true ]

Comments

Popular posts from this blog

Tasker: Get Voice Command

Blackjack Streak House Advantage

Picking 87 NCAA Basketball Games