Beginner trying to reproduce an SMSApp video

Hey TIMAI2,

Apologize for no reply from my side.

So the app is not working properly: I did the change suggested and downloaded once more the app on my phone and the "<!DOCTYPE" was remaining.

Below are the screenshots from the error content:

Honestly at this stage, no idea what goes wrong and with my close to zero knowledge, hard to decipher the error content :sweat_smile: :no_mouth:

Any help to push my on track would be appreciated :hugs:

And this ?

Yes the script was added to the MIT App since the beginning :upside_down_face:

I can see you have added the script url, I mean the spreadsheet url IN the script

should look like this:

const SHEET_URL = "https://docs.google.com/spreadsheets/d/1tAyBD7RcLaimV6mD181dWIY0R7UPDiSU";

with the correct ID for your spreadsheet

Hello all, I have same issue. Yet my app works perfectly fine with deployment options set to 'Me' As 'Execute the app' and 'Anyone, even anonymous' under 'who has access'.

But app is being used by a couple of people. And when executing it by someone else who was not owner of script then we have issue that copies off messages are not being stored at ones phone. I've noticed that when looking at Google Sheet history status column is filled by owner of script. And only if he is sending these copies are being stored at his phones. If anybody else uses app then he is still 'virtually' setting statuses as 'sent'. It is quite painfull since it would be nice to have copy of what was sent just in case someone might tell that he 'did not receive a message' - then non-owner user dont have any proof that sms was sent. When changing execution settings to 'Anyone who use WebApp' these elements doctype errors are being thrown.

To use your google apps script web app, these are the only settings you should use in your AppInventor app, unless you do more complicated things:

1 Like

In the meantime I've came up with another idea - to set up shared google account for us all then connect it to certain google sheet and then log in all phones to that new google account. That could probably cut issues with permissions. Thing is that while it is still working and now that shared account is adding 'sent' statuses to the files. I dont have copies of messages sent saved in my phone which is also logged in to that new owner account.

Any idea why is that so? How are these messages handled? Why can't we just set up some new block to save 'copy' of message sent to phone messages list?

Not sure I understand the problem?

Your google sheet just stores data
Your web app creates access to this data from your App Inventor app
Your app inventor app will SEND the SMS message as the user set on the device, based upon the data provided by the google sheet/web app

Yes you can set up a separate google account to handle all this, but if you have your web app constructed correctly, your users should be able to use the app to build data on the google sheet and recall it as required to send an SMS, with no need to directly access the google sheet.

Well let's start from the beginning for better visibility - first of all we all have access to that sheet so everyone can pas their own data (phone numbers and text to send) as needed.

One of us who deployed this script based on tutorial linked somewhere above with settings that he (no user who uses app) is one who executes it no matter what. Then when using app we've noticed two cases of what is the result:

Case no.1 user who deployed that script sends messages. These are being sent and delivered correctly. Copies of these messags are being saved on his phone i messages app as he would send them the usual way by just typing it in via messaging app.

Case no.2 anybody else sends messages. Messages are being sent and delivered also correctly, BUT copies of messages sent are not stored in messaging app ie. there is no proof that message was sent other than status in google sheet. While it may be sufficient when one of the recipients asks you back after what was sent to him. For example let's assume that message one sent via this app is as follows:

'The code for you is 13579 Please respond with same code in reverse order for validation purposes'.

Then you get response from that number '97531'. But only his response is in messaging app. Message that was sent by you to that number is missing so you basically are unable to compare response with what was sent.


So we've been digging why is that so that only one of us (one who did deployment and is marked as one who executes script) only have message copies stored on his device while others are sending messages but without copies stored on their phones. I found out that it was connected probably with that in edit history of that sheet status updates were always set by owner's account - even when he was offline. That pushed me to think about it that only thing that is needed to be changed here is to change 'Execute the app' from 'Me' to 'anyone who use webapp'. But then those doctype errors pop up.

I've set another account and when I fetch and send messages with that account it sends messages normally but copies are still saved on my phone [ie. I don't see what was sent when checking phone]. Only change here is that status is now updated by that new account. Not sure at which point where that 'save copy or not' thing is happening.

1 Like

You have something wrong in your sheet, script, or blocks. Without revealing all it is difficult to debug. The script is designed for a single user, so please show how you have modified it for multiple users...this could be the issue.

Bonjour Pierre. Je peux résoudre votre problème si seulement je peux avoir la capture de votre script.

Donnez moi quelques minutes pierre. je vous reviens. Je traite ce problème Merci. Ne vous inquitez pas.

Je viens de localiser l'erreur. Allez dans vos Blocs, dans le bloc : "When (WebGet).GotText do". La dernière instructions dans ce bloc vous avez écrit set(Message Liste).(selection) to. Au lieu de selection mettez plutôt "Elements" et votre application fonctionnera très bien

thing is that it was not much modified only thing we've added was a delay because when sending like 70-100messages at once some devices can catch hickup. Script is totally copypasted from tutorial linked here.

And app as mentioned only have delay to send one message every 10 seconds to make sure these are correctly sent.

I will need to work through your blocks logic for a while, but straight off the bat, a problem will/must arise with your delay blocks

image

you should not introduce a delay in this way, use a clock timer to break up the processing.

I would also suggest that if you are sending 70 - 100 messages that you call down all the data from the google sheet in one go (which is happening but you have included blocks to call everytime??), process all the messages in the app, then send back all the data to the sheet in one go...and process each row with the web app.

Still not really sure why sent messages are not showing up in the messaging app for some users?

1 Like

Well I'm totally aware that our resolutions to some of our needs might not be top notch. 2 of us based on rather poor knowledge of VBA for Office moved recently to Google Sheets just trying to figure out stuff on our own. To be honest we would need to learn javascript to write own macros for Sheets. And while we were sending messages out of sheets by copying them to 'your phone' window app or just via messages.google.com. which was huge improvement already - moving forward to doing so by using that built app is lightyears away. To the point where we both were using it for quite some time now res of our coworkers are using that way too.

And since that delay work rather oddly... (it updates status every 10 seconds then basically every time when status is updated in sheet it also sends a message). But then when it go through whole list of messages it then shows popups every 10 seconds with that:

obraz

and android popup 'Message sent'.

But it works. Only thing that we want to get rid off is that only one device has copies of these messages when app is used and the device guy who deployed script. Others dont have those copies. Once we figure out how to deal with that so everyone who uses it has messages sent in their devices aswell then we are good to go.

We have also one common google account used to store contact data to all of our drivers (we usually send shitload of messages to our drivers that's why we do it in batches like 100's or so). And while sms is not that great due to limiations on sending media etc - it is most convenient way to deliver information to everybody even those who dont use Whatsapp and similar. And I was trying to figure out why those copies are not stored. My best bet is that what was said earlier - script is executed by its owner no matter who is using app.

For example one of us did his chores today [orange cells] and statuses were updated by script owner who is out of the office today :smiley: [purple cells]

and only he (purple cells) if he is using app has copies on his phone while others dont have them.


Well... it looks like one who deployed script is not also one who will have copies saved...

I've created my own deployment copied script address and pasted it into app inventor compiled it and now I'm doing changes of statuses but still don't have copies on my phone...


aaaand edit #5 or more :stuck_out_tongue:

I've created brand new file on my personal account not shared with anybody created and deployed script from scratch then its addres pasted into app inventor compiled new apk file installed and everything works perfect but copies of messages sent - these are still not there.

Also tried it with another device with another messaging app (thought maybe its because Google Messages are not compliant with that). But still there is no copy of message there. Which is now really strange. It is beyond my debugging skills to find out where messages sent are also being pushed to device using sms sending app...

This has nothing to do with what is happening in the app inventor app. If you need to know this information (who used the app) then you need to develop your app, your script and your spreadsheet to set this data.

If you can upload an aia project (remove any important details like script url) I can provide a revised project and script for you to try.

Are other users running the same default messaging app, e.g. the one provided by their device, or by google ?

That was just my guess why copies of messages were not stored since I've found out that script is always executed by that one account. That's why I tried to change it so it was executed by whoever is using it at the moment. But since most of my knowledge in programming apart from mentioned VBA for office is more like 'Monkey see, monkey do', I'm more like a walking in the dark with guesses why something works and why something doesn't.

Sure here it is:
SMSApp_v1_2.aia (4.2 KB)

Well... in android environment it is hard to tell which one is default since basically every manufacturer does it differently. For example my company phone Huawei has Google Messages app for messaging. My private Samsung phone has Samsung messaging app, others are also using mostly Google Messages but on different devices. Guy who had those copies stored had Moto E6s (that is also using Google Messages app). He swapped today to Poco X3 pro due to performance issues with that Motorola we will see tomorrow if he would have that copies on his new phone.

I went totally through that tutorial video posted above and for me there is no other way to distinguish one app from another than this global GoogleScript variable.

My guess now is that whole texting.SendMessageDirect is bugged. Since when I pick SendMessage then it goes straight into my app and prepares only one SMS but just ready to send. So it has some kind of connection with that - its just that SendMessageDirect sends messages but doesn't store those sent messages on device [or at least in messaging app].

I've noticed that one SMS got saved in my messaging app 3 hours ago and the text sent says that it was sent from my own file with my own script.

Also I've noticed that once I disabled delays to wait for each sms. Then when sending batch of 3 sms all 3 got status 'sent' but usually 2 out of 3 are sent so another device receives them. So some kind of delay is a must here especially when sending 50-100 messages. To make sure everything was sent.

OK, I have reworked and tested your script and aia project.

Apps Script

  • changed SHEET_URL to SHEET_ID
  • added code to handle all status updates in one go
  • added user to Status message
  • provides a completion message

Please overwrite your existing script with the script below, enter your SHEET_ID at the top, and then republish with new version (legacy editor) / create new version (new editor)

const SHEET_ID = '<Your Sheet_ID Here>';
const SHEET_NAME = 'SMS';

const doGet = () => {
    const sheet = SpreadsheetApp.openById(SHEET_ID).getSheetByName(SHEET_NAME);
    const [header, ...data] = sheet.getDataRange().getDisplayValues();

    const PHONE = header.indexOf('Phone');
    const TEXT = header.indexOf('Text');
    const STATUS = header.indexOf('Status');

    const output = [];

    data.forEach((row, index) => {
        if (row[STATUS] === '') {
            output.push([index + 1, row[PHONE], row[TEXT]]);
        }
    });

    const json = JSON.stringify(output);

    return ContentService.createTextOutput(json).setMimeType(ContentService.MimeType.TEXT);
};

const doPost = (e) => {
    const sheet = SpreadsheetApp.openById(SHEET_ID).getSheetByName(SHEET_NAME);
    const [header] = sheet.getRange('A1:1').getValues();
    const STATUS = header.indexOf('Status');
    
    const statuses = JSON.parse(e.postData.contents);
    let user = statuses[statuses.length-1];
    statuses.pop();

    for (var i=0;i<statuses.length;i++) {
        sheet.getRange(statuses[i] + 1, STATUS + 1).setValue('SMS Sent by ' + user);
    }
    
    return ContentService.createTextOutput('All Statuses Updated');
};

AppInventor App

This is significantly changed:

  • added option to add user name (default == default)
  • added option to set delay interval (default == 5000)
  • reorganised the blocks so that messages are sent with a delay used by a clock timer
  • now add all the row IDs to a list, then send this list, along with the user name, to the doPOST

Suggest to use this aia project as a base, rather than trying to edit your own.
Remember to enter your apps script URL to the googleScript variable

Tested in companion 2.61u on Android 11 (Google Pixel 4a) - SMS permission requested...
Sent messages appear in the messaging app (Google) on this device
Note that using the SendMessageDirect block will not allow this ap to be published on Google Play

SMSApp_v1_2_REVISED.aia (28.5 KB)

You should consider developing this app, or creating another, that allows your users to add messages to be sent to your google sheet.....

Really appreciate your effort on that. Will test that one later and do some reverse engineering maybe I'll learn something new myself. I'll let you know how it goes later.