Beginner trying to reproduce an SMSApp video

Hello all,

Disclaimer:

  1. I reproduced the steps from a video I found handy online (https://www.youtube.com/watch?v=PReU4ITp37I).

  2. In attachment I will add the screenshots of what I reproduced!


  3. I am not knowledgeable about MIT inventor nor coding in general so if you reply to me with an expert language, there are chances I will not understand at all :smile: )

  4. Finally here is the error received

Does anyone knows what can be the issue?
Any help would be appreciated :smiley:

Hello, I don't know what's exactly causing the error, but I know where the error is occurring.
Here:
screenshot-community-appinventor-mit-edu-t-beginner-trying-to-reproduce-an-smsapp-video-29370-1616412164644

Now to find the problem, do what I say:

  1. Connect to the Companion App (I hope you know about it)
  2. Right click on the purple block and select Do It from the dropdown menu.
  3. A yellow box will pop up, expand it, send the screenshot here.

Hello Kaustubh,

Thanks a lot for your answer.

I tried to follow the steps you suggested me & downloaded the Ai2 Companion App and managed to have access to Do IT with right click.

However, I am not sure what should I provide at this stage:

What type of data should I provide on the response content= ?

Thanks,

Please click do it on this

Temporarilly add a label and set label text to get response content. Then you will be able to see what the response is or copy it and paste it as values on the response content=

Your problem is upstream, in the data you receive from Google.

Double check your script and its permissions against the text version of the tutorial at

Hey Alpha, thanks a lot for your answer, unfortunately I do not see any block looking like your screenshot.

I tried on this one:

But it doesnยดt seem to give my any result.

Could you guide me?

Hello Dora, thanks for the reply, however I have no idea how and where to add this label :frowning: a step-by-step example would be really helpful :slight_smile:

You can drag the block image from my post to the workspace or the block is in the List section of blocks

hey Alpha, and all, as I understood I might have missed something on the way, I started a v2 from scratch :sweat_smile:


  1. The AppScript looks like:
    const SHEET_URL = "Url";
    const SHEET_NAME = "SMS";

const doGet = () => {
const sheet = SpreadsheetApp.openByUrl(SHEET_URL).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.openByUrl(SHEET_URL).getSheetByName(
SHEET_NAME
);
const [header] = sheet.getRange('A1:1').getValues();
const STATUS = header.indexOf('Status');
var rowId = Number(e.parameter.row);
sheet.getRange(rowId + 1, STATUS + 1).setValue('SMS Sent');
return ContentService.createTextOutput('').setMimeType(
ContentService.MimeType.TEXT
);
};

  1. The web app seems deployed correctly

  2. @Alpha, following your suggestion I get the following:

  3. I downloaded the version 2 on my mobile and I am able to click on the button fetch messages without getting an error (which was not the case before).
    However no text messages are appearing on the Ai2 companion app nor SMS downloaded on my phone. (setting are belows for the messageList):

  1. Finally the new error message I get is the following:

Does someone knows:
1 - why I do not see the fetch messages?
2- What this new error means and how to fix it? :laughing:

This needs changing:

image

should be messageList.Elements

If you are getting "<!DOCTYPE" back as a response, then the web app is not working correctly. Ensure you have republished/deployed your web app after any changes.

If you are still getting "<!DOCTYPE" back put the response content to a label, you can then read the entire response, the error is usually near the end, identifying the line of the code that is failing.

Did you put your google sheet url in the script ?

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