สอนการใช้ Template Power Automate “Notify a team of new SharePoint file/SharePoint list item”

by

ในบทความนี้จะสอนเกี่ยวกับการใช้ Power Automate template ได้แก่

  1. Notify a team of new SharePoint files
  2. Notify a team of new SharePoint list items
Type “notify team new sharepoint” in search bar

Notify a team of new SharePoint files

Template นี้จะ post ข้อความไปที่ chat หรือ channel ใน Microsoft Teams เมื่อมีไฟล์เพิ่มเข้าไปใน SharePoint library หรือ folder ที่เราระบุ

กด Connect Microsoft Teams และ SharePoint จากนั้นกด ‘Continue’

Connect your account and press continue

เลือก SharePoint site, SharePoint library, SharePoint folder, Microsoft teams team และ channel ที่ต้องการจากนั้นกด ‘Continue’

Select SharePoint and Microsoft team

กด Test

Completed flow

ลองเพิ่มไฟล์ใน SharePoint library

Add file in SharePoint library

เมื่อโฟลว์ทำงานสำเร็จ ลองไปดูที่ MS teams channel

Power Automate Cloud run successfully
Notify in Microsoft Teams successfully

ใน Template flow นี้เราจะได้เห็นวิธีการใช้ Adaptive card ด้วย

Adaptive card

โดยในโฟลว์นี้มีการใช้ dynamic values 3 ค่า ซึ่งค่าเหล่านี้ไม่มีอยู่ใน dynamic content picker เราต้องเขียน expressions ขึ้นมาเอง

ถ้าเราเลือก ‘File name with extension’ จาก picker เราจะได้ expression แบบด้านล่าง:

triggerBody()?['{FilenameWithExtension}']

แต่ในโฟลว์นี้ เราต้องเขียน expression แบบด้านล่าง:

triggerOutputs()?['body/{FilenameWithExtension}']

ดังนั้น dynamic values ทั้ง 3 ค่าในโฟลว์นี้ คือ:

triggerOutputs()?['body/{FilenameWithExtension}']
triggerOutputs()?['body/{Path}']
triggerOutputs()?['body/{Link}']

ถ้าหากต้องการให้ Power Automate แจ้งเตือนแค่เรา สามารถเปลี่ยน parameter ‘Post in’ เป็น ‘Chat with Flow bot’ แล้วเพิ่มตัวเองเป็น recipient ได้เลย จากนั้นก็ลบ Team ID และ Channel ID

Change parameter “Post in” to be “Chat with flow bot”

Result Chat with flow bot

ถ้าต้องการให้ Power Automate แจ้งเตือนใน group chat สามารถเปลี่ยน parameter ‘Post in’ เป็น ‘Group chat’ เพิ่ม group chat แล้วลบ parameter ที่ไม่จำเป็นออกไป

Change parameter “Post in” to be “Group chat”

เราสามารถออกแบบ adaptive card โดยใช้ adaptive card designer หรือ ChatGPT เขียนโค้ดให้ได้

Adaptive card designer

ในที่นี้ ลองใช้ Designer ดูก่อน โดย copy code จาก Power Automate template แล้ววางใน Adaptive Card Designer (เลือก host app เป็น Microsoft Teams) แล้วลองแก้ไขข้อความตามที่ต้องการ

ปรากฏว่าข้อความไม่ wrap ให้ ก็เลยเอาไปถาม ChatGPT ให้ช่วยแก้ code ให้

Ask ChatGPT

รูปภาพด้านล่างแสดงผลลัพธ์ ก่อนและหลังของ Adaptive Card ที่ไม่ wrap text กับ wrap text

Adaptive card result before and after wrap text

Notify a team of new SharePoint list items

Template นี้จะ post ข้อความไปที่ chat หรือ channel ใน Microsoft Teams เมื่อมีไฟล์ item เพิ่มเข้าไปใน SharePoint list ที่เราระบุ

กด Connect Microsoft Teams และ SharePoint จากนั้นกด ‘Continue’


Connect your account and press continue

เลือก SharePoint site, SharePoint list, Microsoft teams team และ channel ที่ต้องการจากนั้นกด ‘Continue’

Select SharePoint and Microsoft team

กด Test

Completed flow

ลองเพิ่ม item ใน SharePoint list

Add item in SharePoint list

After the flow run success, check your team channel.

Power Automate Cloud run successfully
Notify in Microsoft Teams successfully

สามารถเปลี่ยน time zone จาก UTC เป็น time zone ที่ต้องการได้ ในที่นี้กรุงเทพใช้ UTC+07:00.

Convert time zone action

จากนั้นแทนที่ dynamic content ของเวลาที่เปลี่ยน time zone ใน adaptive card

Replace dynamic content result from convert time zone

ทดสอบโฟลว์และดูผลลัพธ์

Adaptive card result after convert time zone

หวังว่าบทความนี้จะช่วยให้ทุกคนเข้าใจการใช้ Power Automate templates และสามารถนำความรู้ไปปรับใช้ เพื่อสร้าง adaptive cards ด้วยการใช้ Designer และ ChatGPT ได้

Until we meet again, Happy Automating!! 😁

Did You Enjoy this Article?

Subscription to get new articles sent to your inbox each week for FREE

Question?

If you have any questions or feedback about this article please leave a message in the comments section below.


Comments

Leave a comment

Subscribe to get new articles sent to your inbox each week for FREE