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.