0

Currently I'm working with my script that can search a data from google sheet by sending a keyword in telegram but I have eerror with my script.

Error TypeError: Cannot read property 'postData' of undefined doPost

Error Line

function doPost(search) {
  var stringJson = search.postData.getDataAsString();
  var updates = JSON.parse(stringJson);
 
    if(updates.message.text){
      sendText(updates.message.chat.id,SearchIDSheet(updates.message.text)); 
    }
}

SEND

function sendText(chatid,text,replymarkup){
var data = {
    method: "post",
    payload: {
      method: "sendMessage",
      chat_id: String (chatid),//(chatid),
      text: text,
      parse_mode: "HTML",
      reply_markup: JSON.stringify(replymarkup)
    }
  };
  UrlFetchApp.fetch('https://api.telegram.org/bot' + BotToken + '/', data);
}

May I know what I need to change or modify with the script for me to resolve this error?

Thank you!

rodskies
  • 119
  • 1
  • 11

0 Answers0