Get assistant to send text to multiple recipients. Project Share.

989 views
Skip to first unread message

Rich D

unread,
Mar 7, 2018, 3:39:41 PM3/7/18
to Tasker Google Groups Post

Hopefully someone will find this useful.. 

This project will allow you to create and send text messages to multiple recipients using the Google Assistant. 

This project requires the additional plug-in called "Contacts Task". Hopefully the next version will be plugin-free and include a tasker exported app. 


Here is the first working version. This actually works better than I thought it would. 

1. Make a new contact with the name Friends. Use your cell phone number for the mobile number. 

2. Say to the assistant..
"OK Google"
"Send a text message to friends"

3. The assistant will ask 'what's the message'?

4. Say...
"Bob Smith, Jim, Sally, message, whatever you want to say in your text message"

5. The assistant will send yourself   this text message and the Tasker profile will trigger because you received a text message with the word "Message" in it from yourself.

6. The Tasker task will check the individual names to see if there are any duplicates or if one of the names is a last name. If you have more than one 'Jim' in your contacts then Tasker will show you a menu and let you select the correct contact. 

7. After the task  checks to see if there are duplicate contacts it will send the text message to all the contacts. 


There is a task called 'set text size mt' . This is so you can easily set the text size in the menu for your particular device.
 Change the text size in the 'set' variable action within the task and run the task. 


*** You will need to run this task first before the menu will show correctly***


Profile: Receive My Text Mt (1001)
Event: Received Text [ Type:SMS Sender:9787583657 Content:*message* ]
Enter: Send Text Mt (996)
A1: Destroy Scene [ Name:show contacts mt Continue Task After Error:On ] 
A2: Create Scene [ Name:show contacts mt ] 
A3: Variable Set [ Name:%split To:%evtprm3 Recurse Variables:Off Do Maths:Off Append:Off ] 
A4: Variable Split [ Name:%split Splitter:message Delete Base:Off ] 
A5: Variable Set [ Name:%test_name To:%split1 Recurse Variables:Off Do Maths:Off Append:Off ] 
A6: Variable Split [ Name:%test_name Splitter: Delete Base:Off ] 
<Start>
A7: Variable Add [ Name:%index Value:1 Wrap Around:0 ] 
A8: Variable Set [ Name:%name_first To:%test_name(%index) Recurse Variables:Off Do Maths:Off Append:Off ] 
A9: Array Clear [ Variable Array:%ctnames ] 
A10: Query contacts [ Configuration:Search for *%name_first* Export false Timeout (Seconds):30 Continue Task After Error:On ] 
A11: Variable Set [ Name:%full_name_first To:%ctnames() Recurse Variables:Off Do Maths:Off Append:Off ] 
<Check for last name>
A12: If [ %ctnames(#) > 1 ]
A13: Variable Split [ Name:%full_name_first Splitter:, Delete Base:Off ] 
A14: Variable Set [ Name:%index_plus_one To:%index+1 Recurse Variables:Off Do Maths:On Append:Off ] 
A15: Goto [ Type:Action Label Number:1 Label:End of last name check ] If [ %index_plus_one > %test_name(#) ]
A16: Variable Set [ Name:%last_name To:%test_name(%index_plus_one) Recurse Variables:Off Do Maths:Off Append:Off ] 
A17: Array Clear [ Variable Array:%ctnames ] 
A18: Query contacts [ Configuration:Search for *%last_name* Export false Timeout (Seconds):30 ] 
A19: Variable Set [ Name:%full_name_second To:%ctnames() Recurse Variables:Off Do Maths:Off Append:Off ] 
A20: Variable Split [ Name:%full_name_second Splitter:, Delete Base:Off ] 
A21: Variable Set [ Name:%name_match To:1 Recurse Variables:Off Do Maths:Off Append:Off ] 
A22: For [ Variable:%name_a Items:%full_name_first() ] 
A23: For [ Variable:%name_b Items:%full_name_second() ] 
A24: If [ %name_a ~ %name_b ]
A25: Array Push [ Variable Array:%match Position:1 Value:%name_a Fill Spaces:Off ] 
A26: End If 
A27: End For 
A28: End For 
A29: If [ %match(#) = 1 ]
A30: Variable Add [ Name:%index Value:1 Wrap Around:0 ] 
A31: Array Push [ Variable Array:%final_names Position:1 Value:%match1 Fill Spaces:Off ] 
A32: Flash [ Text:Match
%final_names() Long:On ] 
A33: Array Clear [ Variable Array:%match ] 
A34: Goto [ Type:Action Label Number:1 Label:Bottom ] 
A35: Stop [ With Error:Off Task: ] 
A36: End If 
A37: Array Clear [ Variable Array:%match ] 
<End of last name check>
A38: End If 
A39: If [ %full_name_first(#) > 1 ]
A40: Show Scene [ Name:show contacts mt Display As:Activity, No Bar Horizontal Position:100 Vertical Position:100 Animation:System Show Exit Button:On Show Over Keyguard:On Continue Task Immediately:Off ] 
A41: Flash [ Text:%final_names(#) Long:On ] 
A42: Stop [ With Error:Off Task: ] If [ %final_names(#) = 0 ]
A43: End If 
<Bottom>
A44: Goto [ Type:Action Label Number:1 Label:Start ] If [ %index < %test_name(#) ]
A45: Flash [ Text:%final_names() Long:On ] 
A46: Perform Task [ Name:Names To Numbers Mt Priority:%priority Parameter 1 (%par1):%final_names() Parameter 2 (%par2): Return Value Variable:%nums_to_send Stop:Off ] 
A47: Flash [ Text:%nums_to_send Long:Off ] 
A48: Send SMS [ Number:%nums_to_send Message:%split2 Store In Messaging App:On Continue Task After Error:On ] 



 

Set Text Size Mt (1005)
A1: Variable Set [ Name:%Text_size To:5 Recurse Variables:Off Do Maths:Off Append:Off ] 

Menu Tap Mt (1003)
A1: Array Push [ Variable Array:%final_names Position:1 Value:%tap_label Fill Spaces:Off ] 
A2: Destroy Scene [ Name:show contacts mt ] 

Names To Numbers Mt (1004)
A1: Variable Set [ Name:%names_to_split To:%par1 Recurse Variables:Off Do Maths:Off Append:Off ] 
A2: Variable Split [ Name:%names_to_split Splitter:, Delete Base:Off ] 
A3: For [ Variable:%cont_name Items:%names_to_split() ] 
A4: Query contacts [ Configuration:Search for %cont_name Export false Timeout (Seconds):30 ] 
A5: Array Push [ Variable Array:%cont_num Position:1 Value:%ctphones() Fill Spaces:Off ] 
A6: End For 
A7: Return [ Value:%cont_num() Stop:On ] 


Travis Jansen

unread,
Mar 7, 2018, 8:24:43 PM3/7/18
to Tasker
Awesome. I'll try this out when I get some free time. If this works, it'll be awesome!

Rich D

unread,
Mar 7, 2018, 9:02:39 PM3/7/18
to Tasker Google Groups Post

Awesome. I'll try this out when I get some free time. If this works, it'll be awesome!

It is currently working for me. I would imagine there will be a few bugs to iron out. Let me know how it goes. 

You can of course change the keyword "message"  if you think another word or additional words might make getting the names into the message more intuitive for you. For example we could change it to "Send to, bill, frank, jim, the following message, I am out of the office today. "

The method I chose just seemed easy for me to remember and kept it as simple as possible. And of course we could always add other search criteria to accommodate several different methods. 

Aditya Pratap Singh

unread,
Mar 8, 2018, 3:45:03 AM3/8/18
to Tasker
Juat a small advice:Instead of sending an SMS to self, we could intercept the command directly from Google Assistant using AutoInput.

Rich D

unread,
Mar 8, 2018, 5:45:23 PM3/8/18
to Tasker Google Groups Post

Juat a small advice:Instead of sending an SMS to self, we could intercept the command directly from Google Assistant using AutoInput.


Could you elaborate on how this would work with autovoice ? Not looking for the code.   Just exactly what you would need to ask the assistant and how auto voice would handle making the text message. 

Travis Jansen

unread,
Mar 8, 2018, 6:40:38 PM3/8/18
to Tasker
Being new to Tasker, I'm guessing I paste that code in a script area of some sort inside the profile?

Travis Jansen

unread,
Mar 8, 2018, 6:48:20 PM3/8/18
to Tasker
I found this video in my searches, btw. Would this work to combine your your methods?

https://youtu.be/mkR3i3Eigng

Rich D

unread,
Mar 8, 2018, 7:11:12 PM3/8/18
to Tasker Google Groups Post

Being new to Tasker, I'm guessing I paste that code in a script area of some sort inside the profile?


1. Be sure you have disabled beginner mode In tasker preferences  (menu -> preferences.  

2. Download  the project file.  

3. In the main tasker UI you should  see a home icon in the lower right. This is a project tab. Long press the home project tab -> import. This will bring you to the tasker file browser. Tap the up arrow and browse to find your download folder. You should see the downloaded project in there.   Tap on it to import. 

4. Tap  on the multi text project tab.

5. Tap the the tasks tab -> tap the 'set text size mt' task name -> tap the play button in  the  lower right.  This will set the text size for the menu. 

6. Follow instructions in the first post. 

Rich D

unread,
Mar 8, 2018, 9:30:40 PM3/8/18
to Tasker Google Groups Post

I found this video in my searches, btw. Would this work to combine your your methods?

https://youtu.be/mkR3i3Eigng

That uses autovoice recognize. I believe that will only work with the old Google now and not the assistant.  As I noted above when I try to use autovoice with the assistant on my pixel 2 xl it will prevent the assistant from turning the screen on when activated. 

It is possible to just have the assistant trigger a Tasker task then have Tasker ask for the contact names and the text data as in the video (this does not require a plug in. This would avoid having to use your text string to populate the sms message.

Rich D

unread,
Mar 9, 2018, 5:35:41 AM3/9/18
to Tasker Google Groups Post

This might have just got a whole lot better. When I tested IFTTT before with a command like 'send a text to jim, Bob and frank' It just seemed to confuse the assistant and the assistant would try to find a contact by that name of just use the first contact name in the list.

However I just tried it again and now this seems to work without a issue. IFTTT will completely take over that command without confusing the assistant. So it appears we will be able to say 'Send a text to bill, bob and jim' then send that to tasker (I like to use pushbullet for this) and then have Tasker ask "what is the message". I think I will have it use a scene to display the message so you can manually edit it or just say send it. 

Rich D

unread,
Mar 11, 2018, 3:45:42 PM3/11/18
to Tasker Google Groups Post
I have explored and built several different methods to get this to work. To include using exclusively auto voice and tasker. There seems to be a google bug with populating autovoice variables that make using auto voice a not so good option. Any other attempt to get the data from the assistant to tasker seems to take too much time. In addition even if I get the assistant to send the contact names to tasker the project I set up with autovoice continuous to get the text body worked well (better then I expected) However it still is not as seemless as using the text string approach. Using the text string is also by far the fastest way I have found to get the data into tasker. I will keep looking at other methods but for now the project I posted earlier still seems the best approach. 
Reply all
Reply to author
Forward
0 new messages