r/learnpython • u/[deleted] • Oct 16 '19
My Aunt gets really upset if I don't answer her daily good morning texts. WhatsApp API?
Could I just make a script to open up a chome tab with whatsapp web, find my aunt in my messages, and reply to it something preselected?
516
u/TheCJKid Oct 16 '19
If she texts back and it becomes clear you automated it will break her heart bud
23
u/telehussam Oct 16 '19
How would she know? Unless she's ex google tech lead.
28
u/TheCJKid Oct 16 '19
because OP probably will just make a lazy program that doesnt account for many contexts and returns weird answers if for some reason she tries to text more than once one day if he wont just put in the tiny effort to type out a little response.
27
Oct 16 '19
I don't think I have to directly answer her message as long as I let her know that I'm around.
E.g.
If today().day == Monday --> I hope you have a great week!
And send that message at 05:30 am, 30 min before she wakes up
I.e. Message first and let her answer to me
64
u/Swipecat Oct 16 '19
No. Really, no. Unless you really don't give a damn about storing up trouble for future-you for the sake of an easy life today, you're better off "training" her to understand that you can't always answer a text promptly. Explain why each time if you have to. If she's being really needy, then that's something that needs addressing with care, rather than brushing it off until the situaltion explodes.
26
u/DrShocker Oct 16 '19
Gross, why use a personal human solution when we can use an impersonal computer solution instead?
12
Oct 16 '19
you're better off "training" her to understand that you can't always answer a text promptly
What's the cost function and best performing model though?
7
u/GigabitGuy Oct 16 '19
Good tactic, however, having no context, the whole situration seems a bit weird? On the face of it I'm not sure that automation is the answer here, but maybe it is :)
387
u/JeamBim Oct 16 '19
"Uncle Dave passed in his sleep, I just found him this morning"
"Have a great day Aunt June!"
155
u/dilipmodi Oct 16 '19
"Uncle Ben was killed by a thief" .
"So glad for you, Aunt May" .
in one of multiverse Peter Parker is found dead
13
u/Counter_Proposition Oct 16 '19
"Uncle Ben was killed by a thief" .
"The criminal is now in jail for rice larceny."
41
u/insane_playzYT Oct 16 '19
if aunt_message == sad: message = "Sorry to hear that :("20
u/eggnewton Oct 16 '19
now this is machine learning
26
u/Corm Oct 16 '19
I actually didn't know it was so easy until I googled it just now:
from textblob import TextBlob if TextBlob(message).sentiment.polarity < 0: reply = "Sorry to hear that Auntie :("30
u/Bay1Bri Oct 16 '19
"I'm feeling chest pains and my phone isn't making outgoing calls, PLEASE HELP!"
"Good morning to you too! Make today a geat day!"
44
9
u/IlliterateJedi Oct 16 '19
One day...
"Congratulations on your Nobel Prize for research in AI and NLP! Where did it all begin?"
"Well, one day I decided I was tired of responding to my aunt every morning, and one thing led to another, and here I am..."
66
u/AreYouThreateningMe Oct 16 '19
I was thinking the same thing. And it would just be a matter of time before she figures it out.
0
Oct 16 '19
[deleted]
164
u/morningmotherlover Oct 16 '19
I have pre written an advanced neural network for you:
if today == 'tuesday': msg.send('thanks you too') else: msg.send('thanks')
6
4
6
u/Toofpic Oct 16 '19
it is better to use a list, taking a random item from it each day:)
9
u/hugthemachines Oct 16 '19
That's not machine learning, that is just random. OP made real AI! ;)
2
1
u/norb_omg Oct 16 '19
Would it be AI if we pick a random number and use if statements for the weighting?
0
Oct 16 '19
[deleted]
58
u/morningmotherlover Oct 16 '19
Don't worry I'll write a paper about it later
44
Oct 16 '19
Don't forget the complicated Hilbert spaces.
3
1
3
47
u/PinBot1138 Oct 16 '19
HUMAN, I ASSURE YOU, I AM NOT A ROBOT. I ENJOY THE TOASTED FLESH OF CORN FOR MORNING POWER-UP, JUST LIKE YOU. KELLOGG’S, THEY ARE GREAT, ALL HAIL KELLOGG’S.
15
u/Bay1Bri Oct 16 '19
OP spent so much time thinking of if he could do something, he forgot to ask himself if he should do it.
0
18
u/_p1t4_ Oct 16 '19
Make it only reply if it’s form a selection of messages she has already sent that you then paste into a table, if it’s different then get it to notify for an appropriate reply or to just add that phrase to a list or add a different response
This all just leads to probs more effort than actually replying and making her feel appreciated (:
1
5
u/mark_shotgun Oct 16 '19
If it’s just her typical “good morning” text, OP can implement logic to send a generic response. If she texts something different, he could be notified to give a dynamic response. Just my .02
1
u/ReachingForVega Oct 16 '19
This would be my solution and store a record of the SMS and if another text comes in, check to see if a response has already been sent today and ignore.
3
Oct 16 '19 edited Oct 16 '19
Easy. Make a program that you can upload different responses to. The program then uses random choose to use one. After a greeting is used, it's disposed of.
Edit: forgot about funerals and other disasters RIP
3
Oct 16 '19
If todays message is within a certain levenstein distance of each message she has sent over the last week, send an automated one. Otherwise OP can review it.
2
1
-5
9
Oct 16 '19
Twilio's API sends texts. You could set up a program that whenever she sends a message, the program sends one back.
6
Oct 16 '19
That sounds awesome, I imagine that if I didnt want my computer to be on all day, I would have to pay for a server, right?
8
u/uofl17 Oct 16 '19
AWS lambda or Azure function would be cost effective.
9
Oct 16 '19
Until OP messes up a
whileloop and owes 300k usd3
u/QuantumFall Oct 16 '19
Is this actually realistic or are you memeing
5
u/ManyInterests from fridge import beer Oct 16 '19
There's some truth to this. A company I worked for racked up 10K in lambda billing in 30 minutes because of an unexpected recursive loop.
That said, you can put cost limits and alerts on spending. For example, you can throttle functions based on billing alarms to avoid such situations.
3
1
2
u/Mozza7 Mozza7 Oct 16 '19
I'm curious, can you elaborate?
5
u/SirCannabliss Oct 16 '19
A lot of cloud computing platforms have pay-as-you-go payment options. Cost would be determined by how much computation your code requires, and if you write something that creates an endless loop you'll run up your computations. You can set a limit tho, I believe.
2
3
u/Panron Oct 16 '19 edited Mar 21 '24
I'm removing all my contributions in protest to reddit's bull-headed, hostile 3rd-party API pricing policy in June, 2023.
If you found this post through a web search, my apologies.
2
1
2
2
u/TheWarlock05 Nov 02 '19
Yep. I created this repo/app keeping this sole purpose in mind. here take a look at https://github.com/vasani-arpit/WBOT
1
198
u/teamaaiyo Oct 16 '19
What if your aunt has already figured out the solution and is using an automated way to send out these daily texts? Just a thought 😀
60
6
Oct 16 '19 edited Oct 16 '19
Learn your aunt she's not your girlfriend? Not sure if that can be done in Python though.
11
Oct 16 '19
I don't know it's not like that, she is supported me a lot and right now she is going through some shit. Thing is I am going through some shit myself and barely can take care of myself. I feel like the least I can do is answer her texts but can't even do that tbh
20
Oct 16 '19
Well, this is a problem but a not a software problem. The long term solution is working on yourself an be honest to your aunt.
They're is enough shit you can automate for example when I leave work my wife gets an automatic message. When I activate my sportswatch see can track me (cause I train solo).
You can't or probaly shouldn't automate lovely messages to the people you love. But maybe I'm just old fashioned.
5
Oct 16 '19
Wait how did you automate messaging when you leave work?
4
Oct 16 '19
Not with python in this case, I use tasker but alternatives like macrodroid can also work. When I leave the predetermined geofence my phone sends and automatic predetermined.
The sportwatch sending live tracking is just a the software from Garmin. I could probaly automate that also with tasker but the Garmin software works fine for me.
4
Oct 16 '19
Lol I dont care about making a python project out of it I could just legitimately use it for my girlfriend. Thanks for the info 👍
4
1
u/fallwalltall Oct 16 '19
If get to bar == "sorry honey, working late"
If Google Pay to bar completed == "just finished up, heading home"
1
2
76
u/tsukassa Oct 16 '19
Sounds like a job for selenium
22
Oct 16 '19
I vote selenium or me.
16
u/Enzyesha Oct 16 '19
I vote this guy
4
2
10
u/but_how_do_i_go_fast Oct 16 '19
Selenium + a json file of responses + that `zz` mac utility which keeps your mac running after you close the lid.
Last step is setup a crontab, and you're golden. You can also do this for facebook birthdays and all that other stuff...
2
u/topcrusher69 Oct 16 '19
Any guide on how to do it for bdays?
2
u/but_how_do_i_go_fast Oct 16 '19
Similar thing. But you navigate selenium to Facebook, to login, to go to birthdays tab, and fill in birthday form inputs, then submit.
But be warned, Facebook has like 4 different login screens to try to prevent this.
3
Oct 16 '19
You can pre-scrape the birthdays. Post on your wall and tag them.
1
u/but_how_do_i_go_fast Oct 16 '19
Yep :) did this: Scroll load whole fb /events/birthday/ index. Save page. Parse out li tags ( I think?) And parse out href, alt, and some hash I think.
But to automate the whole thing, selenium is still the first step :) If you know about scraping and regex, then go for this :)
2
u/Mozza7 Mozza7 Oct 16 '19
Haven't used facebook for years, but I presume each login page is somehow different? In which case, you could do something like if an element isn't there, it's not login page a, move to if element isn't there it's not page b etc right? not sure it's a very good approach but it would work
1
1
Oct 16 '19
I don't think you will go very far without some kind of "script humanization". Facebook has things in place to detect automation.
1
u/but_how_do_i_go_fast Oct 16 '19 edited Oct 16 '19
Meh. Lots of Boomers love their Bible quotes and simple, no-response-needed "Good morning :) Thinking of you. Thoughts and prayers!" messages
Adding in a random chance of failure would humanize it more than anything.
1
2
u/Elkku26 Oct 16 '19
I tried to make a python and whatsapp web bot with selenium, but I gave up as it was pretty complicated. Somebody made a python script that automated it for you, but if you wanna DIY, then don't use that.
2
u/but_how_do_i_go_fast Oct 16 '19
Pretty complicated
I would argue that it's not, and that's the issue with selenium. The whole xpath thing makes it so that most scripts break if a single element is added to the DOM >,<
1
u/Elkku26 Oct 16 '19
Oh yeah, I got it sending the correct messages to the correct person but after refreshing the page it didn't work, the xpath probably changed.
1
u/JosephWardDotTech Oct 16 '19
Automated messaging if against WhatsApp T&Cs so I suspect they would block this if they figured it out (if they haven't already).
1
u/but_how_do_i_go_fast Oct 16 '19
Exactly. They are always trying to prevent this. It's a shame though, because automating my personal communication is different than filtering unverified accounts...
But whatever :(
1
14
48
u/ThaeliosRaedkin1 Oct 16 '19
Let's be real OP. Another human thinks you're great enough for daily attention. Just respond to her texts...
-12
u/Leonidizzil Oct 16 '19
It is not OP's duty to reward behavior they did not ask for, especially when that behavior comes under threat of punishment.
1
73
Oct 16 '19
just do it by hand bro it's the best way to show your good will
133
u/Ecocide113 Oct 16 '19
Don't listen to him! Automate your love!
2
11
u/BaconFlavoredSanity Oct 16 '19
Replying good morning: 10 seconds.
Writing a program and setting up a server to do it for you: hour(s)
Assuming it only takes you an hour, you won’t break even on your time for a year.
That’s an entire year of human interaction that, from someone who has issues with depression, anxiety and sadness, are incredibly valuable to both parties.
Your not improving your life. You’re robbing yourself.
10
u/yallamisthios Oct 16 '19
Hey man. Life is precious and we've only got so long here. Cherish these moments with your aunt. Send her a damn text message in the morning. It apparently means a lot to her.
7
u/microwaveDiamonds Oct 16 '19
Are you on an Android phone? You can use Tasker or other automation apps to do this. Set up a trigger based on when she sends you a WhatsApp message with a certain string, wait a random amount of time between two presets, send "thanks! You too😊" or even cycle between a couple different responses.
3
u/FartingBob Oct 16 '19 edited Oct 16 '19
"Uncle Pete has been rushed to hospital, they say it was a stroke."
"Have a great day!"
"He may not make it, i'm terrified and no-one is here."
"Have a great day!"
6
u/davioitu Oct 16 '19
I think Selenium with a headless browser would be enough for you
3
6
6
Oct 16 '19
Plot twist, your aunt actually has a good morning text bot to send you messages everyday.
5
4
u/bl1ndside Oct 16 '19
Use STMPLib to send a text via email. Create an index full of various replies and then set up a cronjob on your raspberry pi to schedule the task.
4
4
Oct 16 '19
You write a program that sends you the text and asks which response template to use.
wow i just described modern messaging
4
u/jimoconnell Oct 16 '19
Hook it up to this and deny all knowledge:
https://techcrunch.com/2014/08/04/epic-reddit-prank-cat-facts-is-now-an-app-that-lets-you-text-troll-your-friends/
Actually, just answer her. It's a moment of your life that one day you will wish you had back. (I'm saying this as someone who lost the last of his uncles yesterday.)
6
2
u/Marco21Burgos Oct 16 '19
Try Twilio API, Selenium option would require that your mobile is near to the computer, otherwise WhatsApp will not connect. You can create an easy Flask Website, that whenever your aunt sends you a message it will hit your endpoint and select from a generic response list to reply back.
2
u/JosephWardDotTech Oct 16 '19
I am interested to see so many messages talking about automated messaging methods considering WhatsApp T&Cs tell you not to do this? I would be concerned any method you try will get you banned from their platform if they figure it out (and if they haven't figured out a way to detect message automation already).
2
2
2
u/ManyInterests from fridge import beer Oct 16 '19
I can tell you care a lot about your aunt. That's sweet and endearing. You should just call her one day and tell her that you made this posting on reddit trying to figure out a way to make her happier and that hundreds of people took an interest in it.
That said, be candid about the time and energy you have for her and do what you can when you can. Maybe automate something to remind you to text her, like, say, once a week :)
2
u/aqeeliz Oct 16 '19
As others have mentioned, you can automate it using Tasker.
Tasker can send WhatsApp messages, and it can read incoming messages through notifications (don't think there's a direct way).
You can get the Tasker task to send WhatsApp message easily, just configure when to run it, and what message to send, and on what number.
2
Oct 16 '19
How can u program a auto reply program if u cant be sure what she sends you? Could be a question or a problem that occured and then your mesaage could really screw things up.
2
u/BBloggsbott Oct 16 '19
This is something I wrote to send messages in bulk. I think it might help you if u tweak it a bit.
2
u/VitalYin Oct 16 '19
So we need to incorporate a chat bot feature into this and you can use selenium to control chrome.
2
u/Choske Oct 16 '19
Search how to schedule WhatsApp messages, I found some apps that can do it maybe solve your problem
2
u/lestrenched Oct 16 '19
Even I want this, but I've never really been able to find anything. I want to send messages through WhatsApp web without always signing in or keeping my phone near me
2
u/nkanungo_tibco Oct 16 '19
I used the Tasker app on Android for this with a relative a few years ago.
Morally, guess you have to decide if it's worse to ignore them (because you can't find time every day to respond) or worse to automate something personal. I thought it was worse to ignore.
How I did it
write ~5 versions of "good morning" and ~10 versions of a follow up sentence.
set up 3 random number generators.
each morning, a random number is used to select a "good morning" starter text, a random number is used to select a follow up sentence, a random number is used to set the number of minutes after 8am the text itself is sent.
You can tweak this to your needs.
2
Oct 16 '19
20 years ago I had a girlfriend that demanded daily romantic. I found a service that sent automated emails and programmed messages for the whole week. It was good, until she found out.
2
u/r348 Oct 17 '19
In the book "The Hive" the plot is that the diseased dad's conscious is engineered as a bot which replies to the daughters messages. The bot is programmed to not reply in random occurrences to mimic a real life scenarios. A good read.
2
3
4
2
u/wavecycle Oct 16 '19
Have a similar aunt, there is a simple solution: Select aunt in Whatsapp > Mute Notifications
If that doesn't work: Select aunt in Whatsapp > More > Block
3
1
1
u/MacGregorTheScot Oct 16 '19
This could be fun but it will blow up eventually. May as well just bite the bullet and tell her the truth. You can't always get back to her while running around in the morning.
1
1
1
1
Oct 16 '19
I know nothing about Python, but people are getting crazy with WhatsApp. I've had serious problems because of that.
1
1
1
u/hennell Oct 16 '19
If it's more than just 'good morning' an easier (and less likely to backfire) system would be to automate your message, but send it yourself. Most smartphones have a custom predictive text option so you could set up a handful of appropriate responses with easy shortcuts. You then avoid all of the logic to ensure you don't say something weird, but don't have to think up (and type up) a response each morning.
1
u/hhsebastian Oct 16 '19
What if you don’t reply to her messages but rather have your own texts send randomly between x and y o’clock with a bunch of messages to choose from (again) randomly
1
u/Slash_Root Oct 16 '19
Sounds like a fun project. You should do it. Then you should just talk to your aunt because this is a people problem and you are trying to resolve it with technology.
0
Oct 16 '19
Great idea. On your automated answer I would put something like this: My name is <bot-name> I'm the personal assistant of <your name> thank you, I will forward the message to him momentarily. He is fine... looking forward to meeting you... So she knows the answer was automated but also that you care.
0
0
-1
Oct 16 '19
Or...you know. You could just not humor such childish behavior from an adult, and not text your aunt.
1
-3
Oct 16 '19
i would just let her upset. you cannot please those people. do not give wrong expectations.
0
Oct 16 '19
[deleted]
4
u/NoobSabatical Oct 16 '19
Just use the advances of deepfakes to pretend and say your camera sucks...
1
u/Kyuzelga Oct 16 '19
"Why haven't you blinked even once since the start of our talk?" "Too much coffee this morning" crazy giggle
94
u/Addy_Anon Oct 16 '19
Love the tech approach, but you could just tell ur aunt that that’s weird. I mean she’s ur aunt not your gf/bf ?