Let's develop an assistant
Moderator: Martin
-
- Posts: 6
- Joined: 09 May 2015 21:03
Let's develop an assistant
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...
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 1547 times
Last edited by bulentcandan on 16 Mar 2017 14:01, edited 3 times in total.
-
- Posts: 6
- Joined: 09 May 2015 21:03
Re: Let's develop an assistant
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?
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?
-
- Posts: 6
- Joined: 09 May 2015 21:03
Re: Let's develop an assistant
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();
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();
Re: Let's develop an assistant
Tried to download your flow and upon opening I get an error that says...
Am I doing it wrong?Could not import flows/widgits.
The file is not valid.
Re: Let's develop an assistant
Ohhhh....it's zipped. Silly me! Don't mind me...
Re: Let's develop an assistant
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
Action: android.intent.action.VIEW
Data uri: https://api.whatsapp.com/send?phone={nu ... eURL(text)}
Component: com.whatsapp
Re: Let's develop an assistant
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.
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.
Re: Let's develop an assistant
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..
I have posted some codes in other WhatsApp posts..
Re: Let's develop an assistant
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.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
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.
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).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.
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)
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.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Re: Let's develop an assistant
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
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