Let's develop an assistant

Share and discuss your flows and ideas with other users.

Moderator: Martin

bulentcandan
Posts: 6
Joined: 09 May 2015 21:03

Let's develop an assistant

Post by bulentcandan » 20 Sep 2015 22:01

Hi,

I tried to make an assistant with combining some shared flows of others. And also thanks to Martin for his help.

Install a shortcut to your home screen, click the shortcut and say;

- "contact name in your phonebook" call.
Eg. "X call" to call X

- "contact name in your phonebook" send sms

- (New) "WhatsApp contact name" send message.

- "city" weather forecast
Eg. Istanbul weather forecast
( get a wunderground id as describe by syndromtr here: viewtopic.php?f=3&t=1853 )

- turn on flashlight / turn off flashlight

- wifi hotspot

- full screen brightness

- "something" search
Eg. Baris Manco search, Michael Jackson search

Let's develop this flow day by day and share again. As you can see it's very handy to turn on and off flashligt, call someone in your phonebook, open a wifi hotspot...
Attachments
flow_Assistant_20170316_161303.zip
(4.23 KiB) Downloaded 1534 times
Last edited by bulentcandan on 16 Mar 2017 14:01, edited 3 times in total.

bulentcandan
Posts: 6
Joined: 09 May 2015 21:03

Re: Let's develop an assistant

Post by bulentcandan » 18 Oct 2015 13:12

I updated Assistant flow, now "send text" voice command works.

In this flow, I tried to use "android.intent.action.SENDTO" intent action but could not succeed to send message to a specified whatsapp contact. First I used an expression;

groups = newList();
if(matches(value, "(.*) send text", groups))
{
aranacak_kelime = getElement(groups, 1);
}

matches( value, "{aranacak_kelime} send text")

Then I used a Query Content Provider action but I think I could not set it correctly.

Then I used an Activity Start action;

Action : Activity Start
action : android.intent.action.SENDTO
Data URI : {aranacak_kelime}
Data MIME type : text/plain
Explicit component : com.whatsapp.Conversation
Extras : putString("android.intent.extra.TEXT", {textcontent});

But it doesn't work.

How can I send a message to a whatsapp contact via voice without any interface?

bulentcandan
Posts: 6
Joined: 09 May 2015 21:03

Re: Let's develop an assistant

Post by bulentcandan » 16 Mar 2017 13:59

Hi,

Now, Assistant can send a 'speech-to-text' message to a specific WhatsApp contact.

For example;

You : John send message
Assistant : What is your message?
You : Hello
Assistant : Your message is Hello. Is it OK?
You : Yes

Then, Assistant sends message to John via WhatsApp.


In the Control UI action, Click("Send") can be different in your language. So, Control UI action script might be modified by using "Show Overlay Control".

sleep(2000);
click({aranacak_kelime});
sleep(1000);
click("Send");
sleep(1000);
click("Send");
sleep(1000);
back();
sleep(1000);
back();

User avatar
Autumn
Posts: 3
Joined: 20 Oct 2017 04:14
Contact:

Re: Let's develop an assistant

Post by Autumn » 22 Oct 2017 05:16

Tried to download your flow and upon opening I get an error that says...
Could not import flows/widgits.
The file is not valid.
Am I doing it wrong?

User avatar
Autumn
Posts: 3
Joined: 20 Oct 2017 04:14
Contact:

Re: Let's develop an assistant

Post by Autumn » 22 Oct 2017 18:01

Ohhhh....it's zipped. Silly me! Don't mind me...

pmgnt
Posts: 26
Joined: 15 Jul 2016 00:34

Re: Let's develop an assistant

Post by pmgnt » 25 Oct 2017 21:04

Can also use start activity action to open WhatsApp with prefilled text..

Action: android.intent.action.VIEW
Data uri: https://api.whatsapp.com/send?phone={nu ... eURL(text)}
Component: com.whatsapp

User avatar
Autumn
Posts: 3
Joined: 20 Oct 2017 04:14
Contact:

Re: Let's develop an assistant

Post by Autumn » 26 Oct 2017 02:24

Not sure if this could be done...

Is there a way to make a simple chat bot to give it some personality to go along with the commands? Like greetings for example, have the speech input trigger iterate through a list of variables ( hello, hi, hey) it can cat through trying to find match for value and then when a match is found it can reply appropriately by picking a greeting from another, different list of variables (greetings, salutations, pleasantries)...

Does that make sense?

It sounds simple when you say it fast.

pmgnt
Posts: 26
Joined: 15 Jul 2016 00:34

Re: Let's develop an assistant

Post by pmgnt » 26 Oct 2017 12:27

Yes something like that can be done and its not even hard. On non rooted device would still need some Control Ui actions, not very reliable in my opinion. However, on rooted device can use root commands to read/write to whatsapp database files.(requires sqlite)

I have posted some codes in other WhatsApp posts..

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Let's develop an assistant

Post by Desmanto » 26 Oct 2017 13:52

pmgnt wrote:Can also use start activity action to open WhatsApp with prefilled text..

Action: android.intent.action.VIEW
Data uri: https://api.whatsapp.com/send?phone={nu ... eURL(text)}
Component: com.whatsapp
Thanks for the whatsapp API. It is much faster now to send message to certain people. I used to use Intent.SEND, and then use Control UI to select search field, set the text, tap the person name and set the text again to the field and finally tap send. Now it is only single API + tap send.

The downside is it only works for single contact. This doesn't work for groups. Still need old method to send to groups

Control UI is quite reliable at most of my phones, much more reliable than autoinput. Yes sometimes it failed, but it is because I set the delay too short. In case you can't determine the time delay needed, we can add while() command to loop over checking certain element. Something like here : viewtopic.php?f=6&t=6894 Using root to read/write directly to the database will require to force stop whatsapp. It is too long to reopen it again, probably more than 5 seconds. While this Control UI only need about 1 - 1,5 seconds, and no root needed.
Autumn wrote:Not sure if this could be done...

Is there a way to make a simple chat bot to give it some personality to go along with the commands? Like greetings for example, have the speech input trigger iterate through a list of variables ( hello, hi, hey) it can cat through trying to find match for value and then when a match is found it can reply appropriately by picking a greeting from another, different list of variables (greetings, salutations, pleasantries)...

Does that make sense?

It sounds simple when you say it fast.
I am not a fan of voice command. Nice for showing off, but not practical for me. I would rather use gesture command which has latency of hundred of miliseconds (compared to several seconds for voice command).

But you can still make a huge variation of the respond you want. You need to feed the data first though. It can be achieved using multi map + list value. You need to construct something like

Code: Select all

reply = newMapFromValues(
"hi", newList("Hi hi","Hi there","Hi baby"),
"hello", newList("Hello stranger","Good Morning","Anything I can help?"),
"hey", newList("What's up?","What?","Hey there?") );
 
response = reply[toLowerCase(value)];
empty = isEmpty(response);

if(!empty)
  message = getRandomElement(response)
The key is the map, the "hi", "hello", "hey". The newList() defined what possible response it will use when matching the key. You wanna pick a random one everytime it matches. From the recognize value you will convert it to lower case and find the map value. The result is the list of response matched. If it recognize "Hi", it will changed to "hi" and match the first list ("Hi hi","Hi there","Hi baby"). It will then check if there is a match from the map. If yes, empty will false, if no match, empty will true.

When it matches, it will pick random element, so the response can be different everytime you speak to it. The if() is there is to make sure if no element is matched then it won't do anything. You need to add an expression to check for {empty}. If it is empty (true), loop over to the Input Speech to retake a new voice command, make a notif (beep sound or vibrate) to let you know the recognition failed. If not empty (false), then continue to the start activity and send the message via the API + Control UI.

The painful part is you need to feed all possible answers and the key to match. This is what an AI deep learning machine do most of the time.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

pmgnt
Posts: 26
Joined: 15 Jul 2016 00:34

Re: Let's develop an assistant

Post by pmgnt » 27 Oct 2017 23:54

if you know the 'jid' of the group you can use something like..

android.intent.action.MAIN
com.whatsapp
com.whatsapp.Conversation
extra: putString("jid", "49xxxxx-xxxxxx@g.us")
...

to open group chat. Not sure if possible to open up with prefilled text by using putString or putUri..

Regards

Post Reply