十分鐘教會你用軟體機器人做 Line 訊息廣播!

RPA 軟體機器人在這幾年來逐漸被企業客戶重視與使用,微軟的產品也因為免費提供 Windows 10 的客戶下載而逐漸取得客戶的興趣,在這篇文章中我們會使用 Youtube 影片以及直接可以操作的 腳本,來讓您再十分鐘內就建立一個軟體機器人流程,讓您的主管跟同事刮目相看!

 

步驟1. 註冊與登錄 Line Notify 服務

請前往以下網址登錄 Line Notify 服務  https://notify-bot.line.me/zh_TW/

步驟2. 請依照本步驟內影片說明的作法,將本文章中以’==我是分隔線==’ 隔開的RPA 程式碼複製貼上到您的電腦上。

==我是分隔線==’

# 請依照影片所示將第二行的變數內容填入您取得的 Line Notify 存取金鑰(Access Token)
SET Line_Notify_Access_Token TO $'''<將您拿到的 Line Notify Access Token 放在這裡>'''
Display.InputDialog Title: $'''請輸入要廣播到 Line 群組的訊息''' Message: $'''在這裡輸入訊息.''' InputType: Display.InputType.Multiline IsTopMost: False UserInput=> UserInput ButtonPressed=> ButtonPressed
IF UserInput.IsEmpty <> 1 THEN
    Text.Replace Text: UserInput TextToFind: $'''%' '%''' IsRegEx: False IgnoreCase: False ReplaceWith: $'''+''' ActivateEscapeSequences: False Result=> PreparedURLParams
    Web.InvokeWebService.InvokeWebService Url: $'''https://notify-api.line.me/api/notify?message=%PreparedURLParams%''' Method: Web.Method.Post Accept: $'''application/xml''' ContentType: $'''application/x-www-form-urlencoded''' CustomHeaders: $'''Authorization: Bearer %Line_Notify_Access_Token%''' ConnectionTimeout: 30 FollowRedirection: True ClearCookies: False FailOnErrorStatus: False EncodeRequestBody: False UserAgent: $'''Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.21) Gecko/20100312 Firefox/3.6''' Encoding: Web.Encoding.AutoDetect AcceptUntrustedCertificates: False ResponseHeaders=> WebServiceResponseHeaders Response=> WebServiceResponse StatusCode=> StatusCode
    IF StatusCode = 200 THEN
        Display.ShowMessageDialog.ShowMessage Title: $'''Line Notify 服務執行完成''' Message: $'''訊息
%UserInput%
已順利送出!''' Icon: Display.Icon.Information Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: True ButtonPressed=> ButtonPressed2
    ELSE
        Display.ShowMessageDialog.ShowMessage Title: $'''Line Notify 服務執行錯誤''' Message: $'''以下為錯誤訊息,請找 IT 技術同事協助處理.
%StatusCode%
%WebServiceResponseHeaders%
%WebServiceResponse%''' Icon: Display.Icon.Question Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: True ButtonPressed=> ButtonPressed2
    END
ELSE
    Display.ShowMessageDialog.ShowMessage Title: $'''執行錯誤''' Message: $'''您沒有輸入要傳送的訊息哦...''' Icon: Display.Icon.Question Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: True ButtonPressed=> ButtonPressed2
END

==我是分隔線==’

步驟3. 請依照本步驟內影片的說明將 Line Notify 權杖(Access Token)填入 RPA 中的變數就完成啦!

 

2022/06/06 更新,微軟腳本格式更動,本篇文章支援的 Power Automate 桌機版 版本為 2.20.00133