android-sms-gateway icon indicating copy to clipboard operation
android-sms-gateway copied to clipboard

Google Sheet App Script

Open Nizam861 opened this issue 4 months ago • 7 comments

i have succ set-up

Webhook via google sheet app as per guid available in site but one issue with this

One msg come multiple time like 10/ to 15 time in just 20 msg google sheet use 2000 plus row so please share the app script code

To solve this issue

Nizam861 avatar Oct 21 '25 03:10 Nizam861

Image Image Image

Nizam861 avatar Oct 21 '25 03:10 Nizam861

Hello!

Thank you for your interest in the project!

It appears your script isn't returning a success code within a reasonable time. In this case, the application is making multiple attempts to send the webhook. For more information on retries, see https://docs.sms-gate.app/features/webhooks/#step-5-receive-the-payload.

Make sure the request to the script returns a 2xx HTTP status code and the request processing time doesn't exceed 30 seconds. Try making the request manually using curl.

Also, check the application logs according to the documentation: https://docs.sms-gate.app/features/logging/#accessing-logs

If nothing helps, please provide the curl results, as well as the application logs retrieved through the local server API.

capcom6 avatar Oct 21 '25 06:10 capcom6

I am don't know how to use curl

I have attached app snapshot logs

D-X Game Zone Nizam Kumbhar Mo.9879123217

On Tue, 21 Oct 2025, 12:11 pm Aleksandr, @.***> wrote:

capcom6 left a comment (capcom6/android-sms-gateway#285) https://github.com/capcom6/android-sms-gateway/issues/285#issuecomment-3424941412

Hello!

Thank you for your interest in the project!

It appears your script isn't returning a success code within a reasonable time. In this case, the application is making multiple attempts to send the webhook. For more information on retries, see https://docs.sms-gate.app/features/webhooks/#step-5-receive-the-payload.

Make sure the request to the script returns a 2xx HTTP status code and the request processing time doesn't exceed 30 seconds. Try making the request manually using curl.

Also, check the application logs according to the documentation: https://docs.sms-gate.app/features/logging/#accessing-logs

If nothing helps, please provide the curl results, as well as the application logs retrieved through the local server API.

— Reply to this email directly, view it on GitHub https://github.com/capcom6/android-sms-gateway/issues/285#issuecomment-3424941412, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACPPCYCKDFE4LGSJ5HFLKK33YXIQPAVCNFSM6AAAAACJXUKPROVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTIMRUHE2DCNBRGI . You are receiving this because you authored the thread.Message ID: @.***>

Nizam861 avatar Oct 21 '25 10:10 Nizam861

Sorry, but I don't see any app logs in your message.

However, I did find that Google Apps Script returns a 302 status code for the POST request. This is why the application is retrying.

A quick fix is ​​to disable retry attempts in the application settings: Settings -> Webhooks -> Retry count -> 1.

I'll look into this further.

capcom6 avatar Oct 21 '25 12:10 capcom6

I've identified the root cause of the issue.

The Google Apps Script (GAS) is responding to the POST request with an HTTP 302 redirect. According to HTTP standards, POST requests are not automatically followed for redirects because it can lead to unintended side-effects (like duplicate submissions).

Even if we were to ignore this standard, the subsequent redirected request would remain a POST method. The GAS endpoint likely expects a GET request at the redirect location, which would result in a 405 Method Not Allowed error. Therefore, the webhook delivery would fail regardless.

Since this behavior is specific to how Google Apps Script handles requests, I don't have plans to adjust the application's core HTTP client to accommodate it at this time. The most effective solution is to set the "Retry count" to 1 in your application settings to prevent multiple attempts.

Another option is to implement deduplication in your Google Apps Script code. Each webhook payload includes a unique event ID. You can check your sheet to see if an event with that ID has already been processed before inserting a new row. This would make your webhook handler idempotent and resilient to any duplicate delivery attempts.

capcom6 avatar Oct 21 '25 13:10 capcom6

Hi

D-X Game Zone Nizam Kumbhar Mo.9879123217

On Tue, 21 Oct 2025, 6:48 pm Aleksandr, @.***> wrote:

capcom6 left a comment (capcom6/android-sms-gateway#285) https://github.com/capcom6/android-sms-gateway/issues/285#issuecomment-3426602629

I've identified the root cause of the issue.

The Google Apps Script (GAS) is responding to the POST request with an HTTP 302 redirect. According to HTTP standards, POST requests are not automatically followed for redirects because it can lead to unintended side-effects (like duplicate submissions).

Even if we were to ignore this standard, the subsequent redirected request would remain a POST method. The GAS endpoint likely expects a GET request at the redirect location, which would result in a 405 Method Not Allowed error. Therefore, the webhook delivery would fail regardless.

Since this behavior is specific to how Google Apps Script handles requests, I don't have plans to adjust the application's core HTTP client to accommodate it at this time. The most effective solution is to set the "Retry count" to 1 in your application settings to prevent multiple attempts.

Another option is to implement deduplication in your Google Apps Script code. Each webhook payload includes a unique event ID. You can check your sheet to see if an event with that ID has already been processed before inserting a new row. This would make your webhook handler idempotent and resilient to any duplicate delivery attempts.

— Reply to this email directly, view it on GitHub https://github.com/capcom6/android-sms-gateway/issues/285#issuecomment-3426602629, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACPPCYCCKGUNLRYROAL44BT3YYXBZAVCNFSM6AAAAACJXUKPROVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTIMRWGYYDENRSHE . You are receiving this because you authored the thread.Message ID: @.***>

Nizam861 avatar Oct 21 '25 13:10 Nizam861

Also check i use another app

In this google script i send

Also check i use another app

In this google script i send

https://github.com/sa3dany/android-sms-hooks?tab=readme-ov-file

/**

  • This function is executed when a POST request is made to the published
  • script URL. It appends the SMS details as a row in first sheet in the
  • spreadsheet bound to the script.
  • For documentation about the request parameter e please see:
  • https://developers.google.com/apps-script/guides/web#request_parameters */ function doPost(e) { let sms = JSON.parse(e.postData.contents); let sheet = SpreadsheetApp.getActive().getSheets()[0]; sheet.appendRow([sms.timestamp, sms.from, sms.body]); return ContentService .createTextOutput(JSON.stringify({})) .setMimeType(ContentService.MimeType.JSON); }

D-X Game Zone Nizam Kumbhar Mo.9879123217

On Tue, 21 Oct 2025, 7:23 pm Nizam Kumbhar, @.***> wrote:

Also check i use another app

In this google script i send

D-X Game Zone Nizam Kumbhar Mo.9879123217

On Tue, 21 Oct 2025, 6:48 pm Aleksandr, @.***> wrote:

capcom6 left a comment (capcom6/android-sms-gateway#285) https://github.com/capcom6/android-sms-gateway/issues/285#issuecomment-3426602629

I've identified the root cause of the issue.

The Google Apps Script (GAS) is responding to the POST request with an HTTP 302 redirect. According to HTTP standards, POST requests are not automatically followed for redirects because it can lead to unintended side-effects (like duplicate submissions).

Even if we were to ignore this standard, the subsequent redirected request would remain a POST method. The GAS endpoint likely expects a GET request at the redirect location, which would result in a 405 Method Not Allowed error. Therefore, the webhook delivery would fail regardless.

Since this behavior is specific to how Google Apps Script handles requests, I don't have plans to adjust the application's core HTTP client to accommodate it at this time. The most effective solution is to set the "Retry count" to 1 in your application settings to prevent multiple attempts.

Another option is to implement deduplication in your Google Apps Script code. Each webhook payload includes a unique event ID. You can check your sheet to see if an event with that ID has already been processed before inserting a new row. This would make your webhook handler idempotent and resilient to any duplicate delivery attempts.

— Reply to this email directly, view it on GitHub https://github.com/capcom6/android-sms-gateway/issues/285#issuecomment-3426602629, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACPPCYCCKGUNLRYROAL44BT3YYXBZAVCNFSM6AAAAACJXUKPROVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTIMRWGYYDENRSHE . You are receiving this because you authored the thread.Message ID: @.***>

Nizam861 avatar Oct 23 '25 08:10 Nizam861