ChatbotX icon indicating copy to clipboard operation
ChatbotX copied to clipboard

I am facing an issue when integrating a flow with Google Sheets via the External API Request block.

Open SergeyPrimak opened this issue 1 month ago • 0 comments

Have you checked for existing requests?

  • [x] I have searched the existing issues and found no similar request.

Affected Component

🔀 Flow Builder (Flows, Tags, Custom Fields)

Deployment Environment

Self-Hosted (Docker Compose)

ChatbotX Version

latest

Describe the bug

External API Request does not recognize successful response from Google Apps Script, routing to Error and skipping final message

Steps To Reproduce

Here is the fully translated and focused GitHub issue in English, ready to be copy-pasted.


Title: External API Request does not recognize successful response from Google Apps Script, routing to Error and skipping final message

Description:

Hello ChatbotX team,

I am facing an issue when integrating a flow with Google Sheets via the External API Request block.

The core problem: Data is successfully written to the Google Sheet (meaning the request reaches the script and it executes). However, ChatbotX does not recognize the response from Google Apps Script as successful. It routes the flow to the Error branch and fails to show the final message to the user ("Thank you! Your request has been accepted...").

At the same time, the Error Logs (External Request type) are completely empty.

🛠 Our Configuration

1. Google Apps Script (deployed as Web App: Execute as: Me, Who has access: Anyone):

var SECRET_KEY = "MySuperSecretPassword123";

function doPost(e) {
  try {
    var data = JSON.parse(e.postData.contents);
  } catch (error) {
    return sendResponse("error", "Invalid JSON");
  }

  if (data.key !== SECRET_KEY) {
    return sendResponse("error", "Access Denied");
  }

  var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1");
  if (!sheet) {
    return sendResponse("error", "Sheet not found");
  }

  var rowData = [
    new Date(),
    data.name || "Not specified",
    data.phone || "No phone",
    data.service || "Not selected"
  ];

  sheet.appendRow(rowData);

  // We tried different response formats — the result is always the same.
  // 1. return ContentService.createTextOutput("OK").setMimeType(ContentService.MimeType.TEXT);
  // 2. return sendResponse("success", "Data added");
  
  return ContentService.createTextOutput("OK").setMimeType(ContentService.MimeType.TEXT);
}

function sendResponse(status, message) {
  return ContentService.createTextOutput(JSON.stringify({ status: status, message: message })).setMimeType(ContentService.MimeType.JSON);
}

2. External API Request block settings in ChatbotX:

  • Method: POST
  • URL: https://script.google.com/macros/s/.../exec
  • Headers: Content-Type: application/json (also tried text/plain)
  • Body Type: JSON
  • Body:
{
  "key": "MySuperSecretPassword123",
  "name": "{{client_name}}",
  "phone": "{{client_phone}}",
  "service": "Dentistry/Car Service"
}

🐛 Steps to Reproduce

  1. Create a Google Apps Script with the code above and deploy it as a Web App.
  2. In ChatbotX, create an External API Request block with the settings above.
  3. In the flow, connect the green Success output of the External API Request block to a Send Message block containing the text "Thank you".
  4. Complete the flow in Telegram until the end (enter name, phone number).

❌ Actual Result

  1. Data (name, phone) successfully appears in the Google Sheet.
  2. The user does not receive the "Thank you" message.
  3. There are no error records in ChatbotX (in Error Logs).
  4. If we manually add an additional edge from the red Error output to the "Thank you" block, the message is delivered. This confirms that ChatbotX is somehow routing the request to the Error branch.

🔍 What We Have Already Tried

  1. Changed the script response: returned {"status":"success"}, {"status":"error"}, and plain text "OK". ChatbotX still routes to Error.
  2. Changed Content-Type: tried application/json, text/plain. The result is the same.
  3. Configured Pick JSON path: tried to set $.status and paste a sample JSON response into the Paste sample field. Upon saving, the field is cleared, and the setting is not preserved (this might be an interface bug that prevents correct parsing).
  4. Checked Error Logs: there are no records under the External Request type.

💡 Additional Information

  • ChatbotX Version: Community Edition (self-hosted, Docker).
  • Channel: Telegram.
  • Pick JSON path issue: the field does not save the entered data, which may be related to ChatbotX failing to parse the response from Google Script correctly due to redirects or CORS specifics.

Expected behavior

The External API Request block should correctly process the response from Google Apps Script (even if it is plain text "OK" or JSON {"status":"success"}) and route the flow via the Success branch, showing the user the final message.

Screenshots or Error Logs

Image Image

SergeyPrimak avatar Oct 20 '26 16:10 SergeyPrimak