//เด็กคอม www.dek-com.com
const ACCESS_TOKEN = "ACCESS_TOKEN";
const bot = new LineBotSdk.client(ACCESS_TOKEN);

function doPost(e) { bot.call(e, callback) };
function callback(e) {
  if (e.message.type == "text" ) {
     bot.replyMessage(e, [bot.textMessage(bard(e.message.text, 'en', 'th'))]);
  }
};

//เด็กคอม www.dek-com.com

function bard(prompt) {
  var promptEN = LanguageApp.translate(prompt, 'th', 'en'); // เพิ่มจุดที่ 1
  var api_key = "API KEY"; //bard2 api
  var url = "https://[Log in to view URL]" + api_key;

  var headers = {

    "Content-Type": "application/json"
  };

  var requestBody = {
    "prompt": {
    "text": promptEN
    }
  }
  
  var options = {
    "method" : "POST",
    "headers": headers,
    "payload": JSON.stringify(requestBody)
  }

  var response = UrlFetchApp.fetch(url,options);
  var data = JSON.parse(response.getContentText());
  var output = data.candidates[0].output;
  return  LanguageApp.translate(output, 'en', 'th'); // เพิ่มจุดที่ 2
}
//เด็กคอม www.dek-com.com

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: