ITTIRIT T.
Oct 27, 2021

--

LINEBOT — บันทึกไฟล์ในกลุ่มไปยัง Google drive [Google Apps Script]

หมดปัญหาไฟล์หาย ไฟล์หมดอายุ เมื่อเพื่อนในกลุ่มส่งไฟล์ต่างๆ ผ่านไลน์ เราสามารถส่งต่อไปยังแอพอื่นๆด้วย url ได้อย่างรวดเร็วทันใจ

โดยปกติ Google Drive จะให้พื้นที่ฟรี 15GB สำหรับทุกๆ 1 Gmail ซึ่งจะเป็นพื้นที่รวมสำหรับใช้งาน email, drive และแอพอื่นๆ

เริ่มต้นด้วยการสร้าง public folder ใน google drive สำหรับจัดเก็บไฟล์ (ทุกคนที่มี link สามารถเข้าถึงโฟลเดอร์ได้)

เข้าไปที่ >> My Drive — Google Drive

กด New
เลือก Folder
ตั้งชื่อโฟลเดอร์และสร้าง
กดเลือก Folder ที่เราสร้าง > กดที่ชื่อ Folder และเลือก Share
เลือก Get link >> Anyone with the link และกด Done

หากต้องการแยกประเภทไฟล์ File, Video, Audio, Image สามารถสร้าง Folder เพิ่มได้ โดยแต่ละ Folder จะมี Folder-Id แตกต่างกัน

เมื่อเสร็จสิ้นในส่วนของ Google จะได้ Folder ID สำหรับนำไปใช้งานกับ Code ใน Google Apps Script หากไม่ต้องการแยกประเภทไฟล์ สามารถใช้ Folder Id เดียวกันทั้งหมดได้เลย

นำโค๊ดด้านบนไปวางใน Google Apps Script

แก้ไข channelToken, gdrivefolderId และ Deploy

นำ Web app URL ที่ได้ไปใช้เป็น Webhook URL สำหรับ Line bot

บอทสำหรับทดลอง (เชิญบอทเข้ากลุ่ม)

https://lin.ee/yL3naPs

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response