LoginSignup
0
0

More than 1 year has passed since last update.

PowerAutomate: 定期で、毎回メッセージ入力をさせて通知 (wait for 例)

Posted at

背景

  • 定期的にフォローをしたい
  • 返信メッセージを毎回変えたい(入力か、複数メッセージからランダムとか)
  • 返信先を探すの面倒

ってことがあったので、Wait for の利用例的に

概要

  1. 定期でチャットに返信メッセージ要求が飛んでくるので、メッセージを入れると・・
    image.png

  2. こんな感じで決められたところへ返信される
    image.png

詳細

全体フロー

image.png

返信アクション

デザイナーで適当に作成して利用

今回の例は以下

返信要求
{
    "type": "AdaptiveCard",
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.4",
    "msteams": {
        "width": "Full"
    },
    "body": [
        {
            "type": "TextBlock",
            "wrap": true,
            "text": "定期活動フォロー"
        },
        {
            "type": "Input.Text",
            "placeholder": "返信コメントを入れてください",
            "label": "返信コメント",
            "id": "ReplyMessage",
            "isRequired": true,
            "errorMessage": "返信メッセージは必要です",
            "isMultiline": true
        },
        {
            "type": "ActionSet",
            "actions": [
                {
                    "type": "Action.OpenUrl",
                    "title": "返信先へ",
                    "url": "https://openurl.com",
                    "iconUrl": "https://static2.sharepointonline.com/files/fabric-cdn-prod_20210930.001/assets/brand-icons/product/png/teams_16x1.png"
                },
                {
                    "type": "Action.Submit",
                    "title": "返信",
                    "iconUrl": "https://static2.sharepointonline.com/files/fabric-cdn-prod_20210930.001/assets/brand-icons/product/png/teams_16x1.png"
                }
            ]
        }
    ],
    "backgroundImage": {
        "horizontalAlignment": "Center"
    }
}

返信

返信要求の際の、Input.Text の Id を Compose に格納して、Compose.Output を Teams Message として渡してやるだけ
image.png

Scope 全体のコピペ

アクション全部
{"id":"fdfece5b-d15d-4a18-b62f-035ad417e217","brandColor":"#8C3900","connectionReferences":{"shared_office365users":{"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_office365users/connections/shared-office365user-8adbcca0-19c0-4a73-8fdb-225b07b9092b"}},"shared_teams_1":{"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_teams/connections/shared-teams-864099d5-54a7-4002-93b6-565ecf481128"}}},"connectorDisplayName":"Control","icon":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZlcnNpb249IjEuMSIgdmlld0JveD0iMCAwIDMyIDMyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPg0KIDxwYXRoIGQ9Im0wIDBoMzJ2MzJoLTMyeiIgZmlsbD0iIzhDMzkwMCIvPg0KIDxwYXRoIGQ9Im04IDEwaDE2djEyaC0xNnptMTUgMTF2LTEwaC0xNHYxMHptLTItOHY2aC0xMHYtNnptLTEgNXYtNGgtOHY0eiIgZmlsbD0iI2ZmZiIvPg0KPC9zdmc+DQo=","isTrigger":false,"operationName":"Scope","operationDefinition":{"type":"Scope","actions":{"Reply_with_a_message_in_a_channel":{"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_teams_1","operationId":"ReplyWithMessageToConversation","apiId":"/providers/Microsoft.PowerApps/apis/shared_teams"},"parameters":{"poster":"Flow bot","location":"Channel","body/parentMessageId":"1653220212961","body/recipient/groupId":"a70cc9a6-85a4-4b73-974a-c005f11ca2b5","body/recipient/channelId":"19:f243c3cf57aa4845983306279f8649e5@thread.tacv2","body/messageBody":"<p>@{outputs('Compose')}</p>"},"authentication":"@parameters('$authentication')"},"runAfter":{"Compose":["Succeeded"]},"metadata":{"operationMetadataId":"5254b742-b4df-47a8-b7b6-f8180691bfe8"}},"Get_my_profile_(V2)":{"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_office365users","operationId":"MyProfile_V2","apiId":"/providers/Microsoft.PowerApps/apis/shared_office365users"},"parameters":{},"authentication":"@parameters('$authentication')"},"runAfter":{},"metadata":{"operationMetadataId":"b20274d3-6789-46dd-b712-fa9b2c79bab6"}},"Post_adaptive_card_and_wait_for_a_response":{"type":"OpenApiConnectionWebhook","inputs":{"host":{"connectionName":"shared_teams_1","operationId":"PostCardAndWaitForResponse","apiId":"/providers/Microsoft.PowerApps/apis/shared_teams"},"parameters":{"poster":"Flow bot","location":"Chat with Flow bot","body/body/messageBody":"{\n    \"type\": \"AdaptiveCard\",\n    \"$schema\": \"http://adaptivecards.io/schemas/adaptive-card.json\",\n    \"version\": \"1.4\",\n    \"msteams\": {\n        \"width\": \"Full\"\n    },\n    \"body\": [\n        {\n            \"type\": \"TextBlock\",\n            \"wrap\": true,\n            \"text\": \"定期活動フォロー\"\n        },\n        {\n            \"type\": \"Input.Text\",\n            \"placeholder\": \"返信コメントを入れてください\",\n            \"label\": \"返信コメント\",\n            \"id\": \"ReplyMessage\",\n            \"isRequired\": true,\n            \"errorMessage\": \"返信メッセージは必要です\",\n            \"isMultiline\": true\n        },\n        {\n            \"type\": \"ActionSet\",\n            \"actions\": [\n                {\n                    \"type\": \"Action.OpenUrl\",\n                    \"title\": \"返信先へ\",\n                    \"url\": \"https://openurl.com\",\n                    \"iconUrl\": \"https://static2.sharepointonline.com/files/fabric-cdn-prod_20210930.001/assets/brand-icons/product/png/teams_16x1.png\"\n                },\n                {\n                    \"type\": \"Action.Submit\",\n                    \"title\": \"返信\",\n                    \"iconUrl\": \"https://static2.sharepointonline.com/files/fabric-cdn-prod_20210930.001/assets/brand-icons/product/png/teams_16x1.png\"\n                }\n            ]\n        }\n    ],\n    \"backgroundImage\": {\n        \"horizontalAlignment\": \"Center\"\n    }\n}","body/body/updateMessage":"Thanks for your response!","body/body/recipient/to":"@{outputs('Get_my_profile_(V2)')?['body/mail']};"},"authentication":"@parameters('$authentication')"},"runAfter":{"Get_my_profile_(V2)":["Succeeded"]},"metadata":{"operationMetadataId":"03dfa191-df19-46de-9654-477da3b4111e"}},"Compose":{"type":"Compose","inputs":"@outputs('Post_adaptive_card_and_wait_for_a_response')?['body/data/replyMessage']","runAfter":{"Post_adaptive_card_and_wait_for_a_response":["Succeeded"]},"metadata":{"operationMetadataId":"887a2ba7-013b-461d-b416-7d002d45c249"}}},"runAfter":{},"metadata":{"operationMetadataId":"57c60f91-1834-4e6b-b31a-a863fcc029e3"}}}

参考

アイコンは以下で

あとがき

会社で外部連携が使えるようにする為にも、もっと使える人を増やさないと、ね。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0