Skip to main content

Get Data from Google Sheet

The API for using Google Sheets with app.neoagent.co provides functionality to obtain a sheet by sending a GET request to the endpoint /chat/Chatbot/GetGoogleGoolgeSheetData.

warning

Warning: this API is compatible only with traditional chatbots and is not yet compatible with template-based chatbots.

Endpoint

Request URL: https://app.neoagent.co/chat/Chatbot/GetGoogleGoolgeSheetData
Method: GET

Request Body

The request body must contain the following parameters:

{
// string, mandatory - Unique identifier (ID) of the chatbot
"serialNumber": "3254a9d0424c4806b9ea3d0763xxxxxx",
// array of integers, optional - List of IDs of data to retrieve
"ids": [
1,
2
],
// integer, optional - Maximum number of items to return per page, the default value is 10
"pageSize": 10,
// integer, optional - Page number to retrieve, the default value is 1
"pageNumber": 1,
// boolean, optional - Indicates whether the results should be sorted in ascending order, the default value is true
"isASC": true
}

Parameters

  • serialNumber - string, mandatory - Unique identifier (ID) of the chatbot
  • ids - array of integers, optional - List of IDs of data to retrieve
  • pageSize - integer, optional - Maximum number of items to return per page, the default value is 10
  • pageNumber - integer, optional - Page number to retrieve, the default value is 1
  • isASC - boolean, optional - Indicates whether the results should be sorted in ascending order, the default value is true

Required Headers

The API request must include the following headers:

  • Authorization: <Your-Secret-Key> - string, mandatory - The secret key to authenticate the API request
  • Content-Type: application/json - string, mandatory - The content type of the request payload (must be application/json)

Request Examples

const res = await fetch('https://app.neoagent.co/chat/Chatbot/GetSource', {
method: 'GET',
headers: {
"Authorization": "<Your-Secret-Key>",
"Content-Type": "application/json"
},
body: JSON.stringify({
"serialNumber": "3254a9d0424c4806b9ea3d0763xxxxxx"
})
});

const data = await res.json();
console.log(data);

Response

The API response will be a JSON object with the following structure:

{
// object - Represents the results of the query divided into pages.
// In each element of the list, the ID field serves as a unique identifier for each row of data.
// It is important to note that fields such as URL, name, product name, and price are dynamic custom fields.
// Their definitions and values are determined by the user and can be modified based on specific requirements.
"Data": {
"List": [
{
"ID": 1,
"url": "XXXXX",
"name": "xiaomi",
"productName": "xiaomi 16",
"price": 999
},
{
"ID": 2,
"url": "XXXXX",
"name": "apple",
"productName": "iphone 16 pro max",
"price": 999
}
],
"VirtualCount": 2
},
// string - API Version
"Version": "1.0.0",
// boolean - Status of operation success
"Success": true,
// integer - HTTP status code
"Code": 200,
// string - Error message, if present
"Message": ""
}

Error Handling

If the request fails, you should:

  1. Check the HTTP status code for network-level errors
  2. Examine the Code and Message fields in the response for business-level errors
  3. The Message field will contain detailed information about the error.