Whatsapp messaging using custom fields

I have been working lately on Manager-Whatsapp automation using the Whatsapp protocol whatsapp://send?

I was considering many options and I settled eventually on embedding a button within a custom field since:

  1. This doesn’t require external hosting
  2. It’s extremely efficient with little to no noticeable overheads
  3. It allows users to edit automated messages

And more importantly:

  1. This is the simplest method and requires the least number of clicks by the user with zero lag

Current setup

This is the setup I’m using this code inside a custom field:

<div class="flex items-center gap-1"
    style="white-space: nowrap;"
>
    <button class="btn btn-sm" 
        onclick="(() => { 
            const tr = this.closest('tr'); 
            const bal = encodeURIComponent(tr.getElementsByClassName('observer:blur-sm')[0].innerText).replace(/-/gi,''); 
            var msg=`Dear%20X%2C%0A%0A%2AYour%20COD%20balance%20is%20${bal}%2A%0A%0AMake%20sure%20to%20pay%20your%20COD%20as%20soon%20as%20possible%20today%20before%20going%20online%20to%20avoid%20any%20issues.%0A%0A%2ABalances%20older%20than%2048%20hours%20will%20result%20in%20account%20suspension.%2A%20%F0%9F%9A%AB%0A%0APlease%20ignore%20this%20message%20in%20case%20you%20already%20paid.%0AThank%20you%21`; 
            msg = 'whatsapp://send?phone=97300000000&text=' + msg;
            window.open(msg); 
        })()"
    >Send COD</button>
    <a class="btn btn-sm" href="whatsapp://send?phone=97300000000">Chat</a>
    <a class="btn btn-sm" href="whatsapp://call?phone=97300000000">Call</a>
</div>

Which gives me this:

My issue is this, though this is working as it should at the moment, but I’m not comfortable with relying on observer:blur-sm class to get the amount to be included in the message – which is a bit hacky and seems like it could break at anytime.

Also, I had to hardcode values of other fields like Name, Phone, etc because getting those is even more hacky.

This got me thinking that previously, Manager used to hold the entire .json representation of the tab within the webpage which in theory could be used to lookup the amount given the current tr is indexed or otherwise identifiable by an attribute.

My wishfull thinking–hopefully not :grimacing:

Is it possible that some custom attributes like data-column={Column Name} be added to table cells to help users directly query the table instead of scraping like I just did.

Or maybe reintroducing of .json representation somewhere in the body and adding an attribute like data-key={UUID} for all cell rows is another alternative.

Idk, I’m just spitballing but @lubos, how about sharing how you feel about this that would mean a lot to me.

1 Like