LoginSignup
2
2

More than 3 years have passed since last update.

LINE オウム返し BOT を Microsoft FLOW でコーディングなしで作成

Last updated at Posted at 2019-08-16

LINE オウム返し BOT を Microsoft FLOW でサクっと作ります。
コーディング不要です。

image.png

LINE Developers コンソール

LINE Messaging API を利用するため、LINE Developers コンソールでチャネルを作成しましょう。こちらのドキュメントを参照します。

TITLE: Messaging APIを利用するには
URL: https://developers.line.biz/ja/docs/messaging-api/getting-started/

"自動応答メッセージ" は "利用しない" に設定します。
image.png

Microsoft Flow

Microsoft Flow でコーディングなしで Bot を作成します。
https://flow.microsoft.com/ja-jp/

Microsoft Flow の概要や使い方はこちらが参考になります。
https://docs.microsoft.com/ja-jp/learn/modules/get-started-with-flow/

フローの作成

"HTTP 要求の受信時" をトリガーに指定します。
image.png

image.png

"サンプルのペイロードを使用してスキーマを生成する" をクリックします。

サンプルとして、こちらのドキュメントにあるペイロードを利用します。
https://developers.line.biz/ja/reference/messaging-api/

"Webhookイベントオブジェクトの例" を用います。

{
  "destination": "xxxxxxxxxx", 
  "events": [
    {
      "replyToken": "0f3779fba3b349968c5d07db31eab56f",
      "type": "message",
      "timestamp": 1462629479859,
      "source": {
        "type": "user",
        "userId": "U4af4980629..."
      },
      "message": {
        "id": "325708",
        "type": "text",
        "text": "Hello, world"
      }
    },
    {
      "replyToken": "8cf9239d56244f4197887e939187e19e",
      "type": "follow",
      "timestamp": 1462629479859,
      "source": {
        "type": "user",
        "userId": "U4af4980629..."
      }
    }
  ]
}

image.png

"+ 新しいステップ" をクリック。
image.png

"HTTP" をアクションに指定します。
image.png

こちらのドキュメントの情報を基に "HTTP" アクションのパラメータを設定します。
https://developers.line.biz/ja/reference/messaging-api/#send-reply-message

image.png

方法: POST
URI: https://api.line.me/v2/bot/message/reply
ヘッダー:
Content-Type application/json
Authorization Bearer {channel access token}

{channel access token} は Developers Console で生成したアクセス トークンを記述します。

image.png

本文:
JSON ペイロードは、前述の URL のページの情報を基に記述します。

{
    "replyToken":"[replyToken]}",
    "messages":[
        {
            "type":"text",
            "text":"[text]}"
        }
    ]
}

[replyToken] と [text] は、トリガーに指定した "HTTP 要求の受信時" に関連した動的なコンテンツから指定します。この指定により "Apply to each" が自動的に追加されます。

image.png

"保存" をクリックします。

image.png

"HTTP 要求の受信時" の HTTP POST の URL が生成されます。この URL を LINE Developers コンソールで "Webhook送信" を "利用する" に変更し、"Webhook URL" を記述します。

image.png

image.png

動作確認

image.png

LINE Developers の QR コードを読み取って、友達に追加します。

トークを送って、Bot から返信があることを確認します。

image.png

2
2
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
2
2