0
votes

Trying to receive an SMS at my Twilio number and send a POST request to a Google Apps Script app URL as a result of the received SMS.

I have this doPost() message:

function doPost(request) {

    return ContentService.createTextOutput("User says: "+JSON.stringify(request));
}

Some text should be spit out containing the request data.

My doPost() method never gets called. I can't tell if the POST request is actually being sent by Twilio. I see in the Twilio number message log that my SMS is received by Twilio. But after that I can't tell. I have the Twilio number configured for webhook - HTTP POST, and the published URL of my Google Apps Script project. If I change that to HTTP GET my doGet() method DOES get called. I need to doPost() method called, though. any suggestions? TIA.

2

2 Answers

2
votes

How about the following confirmation?

Confirmation points :

  • Redeploy Web Apps as a new version again.
    • When the script is updated, Web Apps is required to be redeployed as a new version for reflecting the update.
  • Confirm setting for Web Apps.
    • "Execute the app as:" is "Me".
    • "Who has access to the app:" is "Anyone, even anonymous".
  • Retrieve a log of request using Stackdriver.
    • The sample script is as follows. Please copy and paste it. And redeploy Web Apps.
    • Request POST.
    • On script editor, click View -> Stackdriver Logging
    • By this, when POST request is received, you can see the log.

Sample script :

function doPost(request) {
  console.log(JSON.stringify(request)); // Here
  return ContentService.createTextOutput("User says: "+JSON.stringify(request));
}

By above confirmation, the reason of your problem may be found. But if this was not useful for you, I'm sorry.

0
votes

I decided to just use doGet(). See my response to the previous comment.