--- title: Azure Logic Apps Trigger Agent to Schedule Teams Meeting --- # Trigger Agent via Logic Apps 建立教學 --- 參考資料: + [Trigger an agent using Logic Apps](https://learn.microsoft.com/en-us/azure/ai-foundry/agents/how-to/triggers) --- ## 一、前置需求 📌 **重要提示**: - 請使用您公司的 M365 Outlook 帳號登入。 - 已預先建立一個AI Foundry Agent。 --- ## 二、建立Logic Apps ### 1. 在Azure Portal 輸入 Logic Apps  ### 2. Add Logic apps  ### 3. 選擇Multi-tenant Consumption plan  ### 4. 新增 Logic apps + Resource Group: 選擇既有或新建 + Logic app name: 輸入自定義名稱 + Region: 輸入同一Region + **Review + Create**  ## 三、授權 Logic Apps 存取 AI Foundry 專案 ### 1. 開啟Logic apps Manage Identity + 點擊 **identity** + status 選擇 **on** + save  ### 2. 授權Logic Apps存取AI Foundry + Azure Portal 選擇 **Azure AI Foundry**  + 在 AI Foundry選擇您建立的project  + 點選 Access Control(IAM) + add role assignment  + 選擇 Azure AI User + Next  + 點選 manage identity + select member + 選擇剛所建立的logic apps + 點擊 **Select** + Next  + 點擊 **Review + assign**  ## 四、設置 Logic Apps ### 1. Add email trigger + 點擊 **add a trigger** + 輸入 when a new email arrives + 選擇 **when a new email arrives (V3)**  ### 2. 登入Microsoft 365 outlook帳號  ### 3. 設置Trigger規則 + 點擊 **show all**  + From: 請輸入您的email address + Subject Filer: `會議記錄` + Folder: `Sent items`  #### 💡 如果要處理多個 Subject Filter(例如「會議記錄」或「meeting minutes」) 由於 **Subject Filter** 欄位只支援單一文字關鍵字(不支援多個值或 OR 條件),若要讓觸發器在多個主題條件下啟動,可使用 **使用 Trigger Condition 條件式** 在觸發器設定中點擊 **Settings** → **Trigger Conditions**,加入以下表達式: ```text @or( contains(triggerOutputs()?['body/subject'], '會議記錄'), contains(toLower(triggerOutputs()?['body/subject']), 'meeting minutes') ) ``` 💡 contains() 比對有區分大小寫(case-sensitive)所以一律轉成小寫。 #### ⚠️ 重要:請將原本的 Subject Filter 欄位清空,否則條件式不會生效。 ### 4. 新增初始化變數 + add an action + 輸入 **initialize variables**  ### 5. 設置初始化變數 - 變數 - agent_id  - Name: agent_id - Type: string - Value: 請到AI Foundry Agent頁面複製您的agent id  - Add a Variable - 變數 - email_content  - Name: email_content - Type: string - Value: 請點選Value左方閃電符號依下方畫面輸入  ### 6. 新增condition - add an action - 輸入condition  ### 7. 設置condition條件 - 輸入以下條件 Condition Expression: **AND** 加上`toUpper`處理大小寫的所有subject - Subject not contains `RE:` - Subject not contains `FW:` - Subject not contains `回覆:` - Subject not contains `轉寄:` - Subject not contains `稿件確認` - Subject not contains `DRAFT` ``` toUpper(triggerBody()?['subject']) ```  ### 8. Step for True - Create Thread: 建立初始thread  - 輸入Azure AI Project Endpoint  - 至您建立的AI Foundry Project 在 **overview**頁面 獲取此資訊  - 點選 **create new** - Advanced Parameters 勾選**messages**  - 點選 `+ Add new item`  - Role-1: user - Content - 1: 點擊閃電選取 **email_content**  - Create Run: 建立Run  - The ID of the thread to create a message for: 選擇Create Thread的id - assistant_id: 選擇變數 `agent_id` - temperature: 輸入 **0.01**  - Delay: 等待上述 Run 完成  - Count: 輸入 `180` - Unit: 選擇 `Second`  - Get Run: 得到 Run 結果  - The ID of the thread to create a message for: 選擇`Create Thread`的id - The ID of the run: 選擇`Create Run`的id  - List Messages: 得到這個thread的所有messages  - The ID of the thread to create a message for: 選擇`Create Thread`的id  - Compose: 輸出最後一個Message  - Inputs請輸入 ``` body('List_Messages')['data'][0]['content'][0]['text']['value'] ```  ### 9. 設置完成  ### 10. 測試 + 情境一: 郵件主旨包含或不包含`會議記錄` + 情境二: 郵件主旨包含或不包含`轉寄:` `回覆:` `FW:` `RE:` `draft` `稿件` + 情境三: 郵件內文Action Item是否提及下次會議時間 ### 11. Debug 操作指引 #### 情境一:確認是否符合郵件觸發條件(Trigger) 判斷依據: - 郵件主旨包含 `會議記錄` 關鍵字。 - 若符合條件,系統會透過 Logic App 進行觸發。 檢查方式: - 前往 Logic App 的 Run History,確認是否有觸發紀錄。  --- #### 情境二:確認 AI Agent 是否成功被驅動 判斷依據: - 郵件主旨不包含以下關鍵字: `轉寄:`、`回覆:`、`FW:`、`RE:`、`draft`、`稿件` - 郵件內文中「Action Item」或類似標題之後的內容,需提及明確的下次會議時間。 檢查方式: - 前往 AI Foundry Portal → Agent → My Threads - 找到最近的一筆 thread,點選 Try in Playground 進行驗證。 
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up