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
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?
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:
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 [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
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.
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.
Sure here it is:
SMSApp_v1_2.aia (4.2 KB)
Are other users running the same
default
messaging app, e.g. the one provided by their device, or by google ?
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.
well I'm getting Doctype error when fetching SMS.
since script has changed so now it needs sheetID which as far as I know is gid:
.
Since gid is 0 then in script it should look like this?
I'm asking since. App is getting these doctype errors
And while trying to execute script in script editor also getting this:
So I went back to openByUrl swapped gid to whole url and now it fetch data correctly and app is sending messages as intended.
Thing is that I still dont have copies on my phone (even that I've deployed that script) and I'm starting to wonder why is that happening. Normally I'd say that it is something wrong with my phone but if 5 or so phones have these issues I have my doubts on that. I'll dig somewhere maybe on stackoverflow because it seems that whole situation with missing copies is not really connected with app inventor itself.
It should look like this:
const SHEET_ID = '1I02Ij8Sy6hbOl3x6if4p27wzo0HlXFiUBDvGht411d0';
The ID for the sheet is the string of characters in the url:
https://docs.google.com/spreadsheets/d/1I02Ij8Sy6hbOl3x6if4p27wzo0HlXFiUBDvGht411d0/edit#gid=0
Yup I've just found it. Previously I've found that gid is sheet ID which was quite suspicious to me. But anyways it works basically same as before and those copies are still not being stored. Well for me having reliable delay that will make sure sms was sent correctly is just enough. I can always lookup what was sent by taking look at sheet file. While others tend to store their data in excel files not in cloud. They probably would need to move to cloud if they want to have good way of see messages sent to compare.
At least until I'll find out whats wrong with these copies. Currently my guess is that it may be connected with fact that our phones has more than one google account connected.
our phones has more than one google account connected
That could be it, with SendMessageDirect selecting the default
messaging app on the device, worth checking.....(I do not have that setup on any of my devices)
I'm not sure if there is any possibility to select certain google account to be treated as main for messaging purposes as well. I'm gonna look more into this tomorrow or on Sunday. As far as I know Android tend to treat first logged in account as master one. Thus I would need to check it with an app. That's the best bet I have for now. Though still I am not sure how google account could be connected to messaging generally speaking. I'll try it anyway. Then I'll start to ask around over the internet.
On your device ( I looked on my Android 11 device), go into Settings, then Apps, then Default Apps, this will show you the default app for messaging.
The SendMessageDirect block tooltip says it will use the default app for messaging. However, this still may not overcome the potential issue that the "master" google account on your phone is the one that actually sends the messages, which may not be the account you believe you are using at the time...
On your device ( I looked on my Android 11 device), go into Settings, then Apps, then Default Apps, this will show you the default app for messaging.
as for that I only have one messaging app and it is Google Messages.
However, this still may not overcome the potential issue that the "master" google account on your phone is the one that actually sends the messages, which may not be the account you believe you are using at the time...
And this one is also busted. While I did not check it myself. Guy who first found that tutorial had it deployed via his personal google account to a file that I was owner (on my google drive). And his phone where he was testing it was only logged in to our common google account to store contact details [3rd account].
I will try to explain....
When you set up a google apps script web app, in the way that we have done: executed as the owner of the google account and with access to anyone, even anonymous), the script is available to anyone (yes, anyone) who has the link (script url) and they can use this script url to carry out the functions therein. The creator of the script (e.g. the google account owner), owns the script, but allows anyone to use it. This means that any user, even those without a google account, can run the script.
This is how the web component on an AI2 app is able to send parameters to a google apps script, run it, and return output data, without any need for OAuth or authentication to the script owner's google account.
Consequently, what ever is happening in the app, or on the user's device with regard to google accounts, has nothing to do with being able to run the google apps script with the web component. You do not have to be using the same google account on your device in order to run the google apps script, of for the app to then send a message.
I must check if your organisation is using google workspace with a domain, as things could be responding differently....
Well for me it is quite logical what you've just said. Though it is still not clear to me why these copies are not stored on phones. Especially given that when you for example have 2 or more messaging clients sending a SMS from any of those automatically stores message so other apps have copies of them as well. That means more or less that in andoid there is a place in memory (lets call it folder) where all messages received and sent [whole correspondence] is stored. And all messaging apps whether it is Samsung Messages, Google Messages, or even Messenger (by FB - i heard it also has messaging capabilities) - are using same place to write history of conversations. Now it is very strange that these copies are not being written there by AI2 app while still are being pushed to be sent as normal SMS.
I must check if your organisation is using google workspace with a domain, as things could be responding differently....
No, at least not yet. We use more or less our private accounts and we are about to force management to move from buying office for every new employee and instead invest into cloud solutions whether it would be office 365 (more expensive) or Google Workspace (more affordable).