silence whatsapp groups during working hours

Post your questions and help other users.

Moderator: Martin

Post Reply
kenvega
Posts: 12
Joined: 19 Nov 2019 17:57

silence whatsapp groups during working hours

Post by kenvega » 06 Dec 2019 16:12

Hi, kinda new to Automagic. Hope this is the right place to ask.

I've been thinking of silencing my group chats during working hours with the control UI action like this:

- have a list of Whatsapp groups to silence
- select them, and silence them, all through UI touches

Haven't tried that yet, so I'm not really sure if it would work and if it is the best possible solution.

I was thinking maybe there is a way to change a certain notification channel for groups from Whatsapp app in a range of time too. Reference here: https://developer.android.com/training/ ... r/channels.

I see Whatsapp supports the group notification channel option so it could work. But I'm not really sure if Automagic can do that.

What do you think? I will still be looking for ways to do it and update if I get a solution.

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

Re: silence whatsapp groups during working hours

Post by Desmanto » 07 Dec 2019 02:16

It can be done. The proof of concept is here : viewtopic.php?f=5&t=7580#p22158

It is just quite advance level already even if you ever use Control UI before. To select the group, we can use looped scroll down and check the group name. If it is in the silence list, tap to select it. Loop for 3-5 pages (should be enough) and finally tap the icon mute. The other way is to use CUI to search the group and silence each of them. But this is slower when you have a lot of groups to slience. I prefer the looped scroll.

I might try to simplify and standarize the looped scroll script for my further usage. I also need it actually for my whatsapp group number to contact flow, but haven't got the mood to finish it for so long.

Whatsapp group notification is in one channel, disabling it will disable every group notification. It is much easier to use control UI to go to the whatsapp setting to disable the group notification altogether, rather than disabling per group. Depends on what you need, the solution is different.
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.

kenvega
Posts: 12
Joined: 19 Nov 2019 17:57

Re: silence whatsapp groups during working hours

Post by kenvega » 10 Dec 2019 00:21

@Desmanto I tried to take the group channel modification route and it worked but I had one problem.

This is how the group channel id for whatsapp looked before the successful change (group_chat_defaults_8):
before.png
before.png (255.14 KiB) Viewed 26118 times
I looked into the settings on my phone and it was changed. But after a minute or less a notification from whatsapp groups still generated notifications. I looked again the flow and somehow the channel id for the group changed in number (group_chat_defaults_9):
after.png
after.png (254.85 KiB) Viewed 26118 times
So it won't work the second time (because tomorrow at the same time the channel id will be different). Actually now that I review again it has changed once more. I still wanted to go with this solution but was not sure how to form that id with a regex pattern.

I tried `group_chat_defaults_.*` on the Notification Channel ID based on this link http://automagic4android.com/automagic/ ... terns.html but it didn't work. Any suggestions? I was also thinking of setting a variable before this action but wasn't sure how to get all the notification channels in a script.

PD. Sorry for big images clutter. I couldn't find a way to reduce the images in size on the preview of the post.

kenvega
Posts: 12
Joined: 19 Nov 2019 17:57

Re: silence whatsapp groups during working hours

Post by kenvega » 10 Dec 2019 01:12

In fact, I just tested again. The modification channel change is done correctly by automagic but somehow after a few minutes whatsapp gets that fixed. It seems it creates a new channel id with the default configuration (?) not really sure. Will keep investigating that.

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

Re: silence whatsapp groups during working hours

Post by Desmanto » 10 Dec 2019 18:03

I have tried to check Whatsapp's notification channel at the app info and it shows the group notif only has one channel. But I don't know yet until you show me that the number keep increasing, while maintaining still one group notif channel. At mine it is 34, and I don't know why it behaves so. Hence modifying the channel seems not the way to do it.

For now, Control UI seems the only way to do it. There is another not-Control UI way to do it, but I need to test it first tomorrow.
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.

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

Re: silence whatsapp groups during working hours

Post by Desmanto » 11 Dec 2019 16:46

Mind blown :o , I just discovered that my alternate method works! It doesn't require Control UI, so can be done when screen off. It also doesn't mess with the notification or the notification channel.

The concept use custom notification sound. You can change the Notification Tone or ringtone, either individual chat, group, certain chat or certain group. Let say you want all group
- If you want the notification sound to be the same as usual, you can copy the default notification sound from your ROM, /system/media/audio/notifications/ (or alarms, ringtones, ui).
- Copy or put the file to certain folder, preferably Automagic folder. /sdcard/Automagic/CustomSound/. Let say the file is Antimony.ogg. Or it can be other custom sound file you want.
- Go to https://commons.wikimedia.org/wiki/File:Silence.ogg and download Silence.ogg. Put it into the same folder
- Change Whatsapp Settings > Notifications > Groups > Notification Tone > Change to custom notification that use file based.
- I use MiXplorer to select the sound and it seems the file path select properly (don't know if other or built-in Sounds picker works or not). Use MiXplorer to select the sound file, Antimony.ogg
- Now all group notification use the new file based Antimony.ogg as the notification sound.

In your flow, use trigger time (or whatever trigger you use). When working hour, Rename the sound file (Antimony.ogg) to something else and rename Silence.ogg to Antimony.ogg. You can use Action move file. But I just use Execute command (non root version) as it can be done within one element.
Execute command :

Code: Select all

mv Antimony.ogg tempgroup.ogg; mv Silence.ogg Antimony.ogg
with working directory, the path to your custom sound folder. In this example is : /sdcard/Automagic/CustomSound/
optional, you can toast message or notification on statusbar to notify the changes.

Now we have replaced the file with silence sound, means incoming group notification now become silence, even though it still points to Antimony.ogg filename.

After working hour, reverse the command to rename back to the original file.
Execute command :

Code: Select all

mv Antimony.ogg Silence.ogg; mv tempgroup.ogg Antimony.ogg
The same method can be applied to certain groups or chats. Just go to the group/chat info and choose custom notification and change to the same file name. You can also set up various file name for various usage; just remember to copy the Silence ogg as many as you need. Or maybe for multiple sound, just use copy/del instead. The entry flow is rename filename to tempname, copy silence.ogg to the filename; the exit flow is to delete the filename (which is Silence.ogg in real) and rename back the tempname. So you only maintain single Silence.ogg for multiple usage.

Other usage
Not limited to slience, This can also be used to change the ringtone sound. So maybe you want certain ringtone sound during certain time/event/condition for certain chat/group.

Extended usage
The same method can be applied to Call/sms, other social media/chatting app that support custom notification sound.

Try it out and see if it works at yours.
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.

kenvega
Posts: 12
Joined: 19 Nov 2019 17:57

Re: silence whatsapp groups during working hours

Post by kenvega » 13 Dec 2019 22:26

@Desmanto this work and is great! thanks a lot, you are awesome for sharing this!

Things I could add:
- couldn't get notifications from my system to copy so I got one from https://notificationsounds.com/
- used the 'move file' action instead of the 'script' action

There is an issue with the solution I think it could happen. It happened to me when I started to set the workflow. I think there might be a case in which, if you don't control very well the triggers, you might end up deleting one of your .ogg files which would be awful if you don't have backups on your phone.

Is there a condition to check if a file exist? so I can set conditions before renaming and don't accidentally delete my sound files.

About the notification channels with whatsapp:
- seems that whatsapp somehow overrides the manual notifications channels changes and that's why the numbers increase later on their ids
- I tested manually changing the group notification channel (through the settings app, not settings from whatsapp and without the help of automagic), and when I got a message from a group the changes made to the group notification channel were overwritten.
- I found an email from their support team in another forum thread explaining more [here](https://forums.oneplus.com/threads/what ... t-18144216)

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

Re: silence whatsapp groups during working hours

Post by Desmanto » 14 Dec 2019 08:13

Probably you need root to access the /system partition since Oreo 8.0. I have root, so don't know if that's the case.

You might want to change the flow execution policy to "Skip" or "Wait". Since this involved dealing witth I/O which will be chaos if executed parallelly.
There is function in script/expression, existsFile(). To check using condition, use expression with it.

Code: Select all

existsFile("/sdcard/Automagic/CustomSound/Antimony.ogg");
The other way is to use Init Variables File info, tick the File Exists and check that value in the expression later. But this require 2 elements, so better use the above one.

- Probably Whatsapp do that to make sure the notification survive. Since a lot of people angry to Whatsapp because Whatsapp don't give notification caused by things those are outside of their control. People use task killer and then wonder why their Whatsapp never notify for new messages until they open the app.
- I don't have that problem in the link. I just simply turn off popup and uncheck use high priority notifications (to ensure no heads-up notification).
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.

sudh33r
Posts: 1
Joined: 06 May 2019 14:47

Re: silence whatsapp groups during working hours

Post by sudh33r » 19 Jul 2020 04:14

i have created a group guys. make sure you dont spam my WhatsApp group and also introduce after joing the group or else you will be removed instantly without any warning

Post Reply