Try   HackMD

使用 LINE 推播訊息通知粉專有新貼文

由於 Meta 更改政策,不再提供透過 API 存取 Instagram 個人帳號,因此原本在《AI 自動化流程超 Easy不寫程式 No code 也能聰明幹大事》一書中 2-8 頁以 Instagram 實作的範例無法運作,在 make.com 中必須改用 Instagram for Business App 取代原本的 Instagram App,這需要建立 Facebook 粉專後連結 Instagram 帳號,不過既然 Facebook 粉專變成必要條件,所以本文就把原本書中的例子改成使用 Facebook 的粉專實作。

開始跟著本文操作之前,請先確認你有在 Facebook 建立粉專,如果還沒有,可以跟著在 Facebook 建立粉絲專頁一文建立一個專門用來測試的粉專。

另外,因為 LINE Notify 服務於 2025/3/31 結束,所以範例中使用該服務來通知新貼文的方式也無法運作,本文也改成使用書中第四章建立 LINE 聊天機器人傳送推播訊息的方式。

繼續閱讀前,請確定先按照建立 LINE Bot 聊天機器人替代 LINE Notify 服務一文建立一個專門用來提供通知服務的 LINE 聊天機器人,並記錄該 LINE 聊天機器人所使用的 LINE 通道的存取令牌,也是先查詢欲發送通知對象的 LINE user/group id

讀取粉專新貼文

請跟著以下步驟建立可以讀取粉專新貼文的腳本:

  1. 登入 make.com 建立新腳本:

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    請在登入 make.com 後按右上方 + Cretae a new scenario

  2. 加入監看粉專新貼文的模組:

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    在搜尋欄位填入 "face" 後選取 Facebook Pages App:

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    選取 Watch Posts 模組:

    請確認選對,不要選到 Watch Posts (public pages),這個模組無法監看你自己建立的粉專,只能監看別人建立的粉專。

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    Create a connection 建立讓 make.com 可以讀取粉專的 Facebook 連線:

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    填入連線的名稱,本例保留預設名稱,再按 Save

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    如果你剛剛建立粉專,或是有切換成粉專的身分,就會先出現這個畫面,必須按繼續切換回你自己的身分才能繼續:

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    確認這是你要使用的帳號後按一下繼續:

    這個畫面無法切換不同的 Facebook 帳號,如果要改用別的帳號,就必須先登出 Facebook 在登入你要使用的帳號後再進行建立連線的步驟。你可以為不同的帳號建立個別的連線,方便之後使用。

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    建立完成後會在 Connection 欄位看到剛剛建立的連線,如果你有建立其它的連線,也可以在這裡選用。按一下 Pages 欄位可以選取要監看新貼的粉專;Limit 可以設定要讀取的貼文數量,這裡保留預設值 2。設定完成後請按 OK

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    這裡可以選擇哪些文章算新貼文:

    選項 說明
    From now on 從設定完成這刻起算
    Since specific date 會出現欄位讓你填入起算的日期時間
    All 所有貼文都是新貼文
    Choose manually 會列出貼文讓你選擇要從哪一篇開始當成新貼文

    這裡保留預設的 From now on 後按 OK,稍後我們會一邊貼文一邊測試。

  3. 完成設定後,就可以測試是否可以讀取到新貼文。首先在剛剛選取要監看新貼文的粉專上貼上一則有照片的文章:

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    接著執行剛剛設定好的模組:

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    在模組上按滑鼠右鍵後選 Run this module only 單獨執行:

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    正確讀取到新貼文後會顯示如上的畫面,貼文資訊會蒐集在資料包(bundle) 中,Link 是貼文網址、Message 是貼文文字、Picture 是縮圖網址、Full picture 是原圖網址。把縮圖或是原圖網址貼到瀏覽器網址列,就可以看到實際的圖片:

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    如果再貼兩則有照片的貼文,重新執行模組,可以看到:

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    就會產生兩個資料包,內含個別貼文的資訊。

  4. 加入以 LINE 傳送推播訊息通知有新貼文的模組:

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    先在空白處按一下,關閉顯示新貼文資訊的交談窗後再按模組右側的 +

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    在底下的搜尋欄鍵入 "line",選取 LINE App:

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    往下捲選取 Send a Push Message 模組:

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    Create a connection 建議讓 make.com 可以使用 LINE 傳送通知的連線:

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    鍵入連線名稱,本例保留預設的名稱後在 Channel Access Token 貼上你建立的聊天機器人的存取令牌,最後按 Save 繼續:

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    建立完成會在 Connection 欄位看到剛剛建立的連線,接著在 To 欄位貼上你要傳送對象的 LINE user/group id,然後按一下 Add item新增訊息內容項目:

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    先按 Type 欄位選 Text 新增文字內容,在 Text 欄位按一下設定內文,左側會出現可用的資料清單,這是從前一個模組產生的資料包而來。請按一下清單中的 1.Message 項目表示要選用貼文的文字內容,就會自動填入欄位中,項目前面的號碼是模組加入腳本的順序編號,你也可以在模組右下方看到,這可以用來辨別不同模組的同名資料項目。設定完成後再按一下下方的 Add item 新增圖片內容:

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    Type 欄位選取 Image 加入圖片內容,依照剛剛代入貼文內文的操作方式,將 Original Content URL 代入 Full Picture 項目、Preview Image URL 代入 Picture 項目,最後按 OK 完成。

  5. 完成整個腳本後,就可以進行測試了。請先自行貼一則含有照片的新貼文後再進行以下操作:

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    確認貼文後按一下腳本編輯區域左下方的 Run once

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    你可以看到兩個模組都有執行一次,表示有讀取到新貼文,而且也發送了一次通知:

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    在 LINE 上會看到送來的新通知。