Monday, May 6, 2024
API KEY
HomeGoogle Apps Scriptใช้ Loading Animation ด้วย App Script

ใช้ Loading Animation ด้วย App Script

Loading Animation คืออะไร มีประโยชน์อย่างไร Loading Animation ของ LINE มีประโยชน์ในการแจ้งให้ผู้ใช้ทราบว่ามีการดำเนินการบางอย่างกำลังเกิดขึ้นและต้องการให้ผู้ใช้รอสักครู่ โดยเฉพาะเมื่อ LINE Official Account ได้รับข้อความจากผู้ใช้และต้องการเวลาในการเตรียมหรือประมวลผลข้อความนั้น การแสดง Loading Animation สามารถช่วยให้ผู้ใช้รู้สึกว่าพวกเขากำลังถูกดูแลและไม่ถูกทอดทิ้งในขณะที่รอคำตอบ

นอกจากนี้ ยังสามารถช่วยลดความรู้สึกหงุดหงิดจากการรอคอย และสร้างประสบการณ์การใช้งานที่ดีขึ้นสำหรับผู้ใช้ได้1 โดย Loading Animation จะหายไปโดยอัตโนมัติหลังจากที่เวลาที่กำหนดไว้ (5 ถึง 60 วินาที) ผ่านไป หรือเมื่อมีข้อความใหม่มาถึง ทำให้ผู้ใช้มีประสบการณ์ที่ดีขึ้นและรู้สึกมีส่วนร่วมในขณะที่ใช้แอปพลิเคชัน โดยทั่วไป Loading Animation เป็นเครื่องมือที่มีประโยชน์ในการสื่อสารกับผู้ใช้และช่วยให้พวกเขาเข้าใจว่ากำลังมีกระบวนการทำงานอยู่เบื้องหลังฉาก ซึ่งอาจต้องใช้เวลาสักครู่ในการดำเนินการ

โค้ดการทำงานของ Loading Animation ใน Google App Script มีดังนี้ สามารถเรียกฟังก์ชั่นใช้งานได้เลย เพียงแค่ของ User ID ไปเท่านั้น

function startLoadingAnimation(userId) {
 var url = "https://api.line.me/v2/bot/chat/loading/start";
 var token = CHANNEL_ACCESS_TOKEN; // Replace with your actual channel access token
 var payload = JSON.stringify({
   "chatId": userId, // Replace with the actual chat ID
   "loadingSeconds": 5
 });
  var options = {
   'method': 'post',
   'contentType': 'application/json',
   'headers': {
     'Authorization': 'Bearer ' + token
   },
   'payload': payload,
   'muteHttpExceptions': true // Set to false to throw exceptions on HTTP errors
 };
 var response = UrlFetchApp.fetch(url, options);
 return response // Logs the HTTP response to the Google Apps Script log
}
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
คอร์สเรียนออนไลน์

Most Popular

Recent Comments