3
2

mekeを使って指定した日付のNASA宇宙写真を送ってくれるLINEbot開発したかったけどしくじった話

Posted at

野球好きのりまきです。
後半戦はなかなか調子がよさそうと思ったらそうでもないなぁと思ってるちなヤクです⚾

NASAのAPIが公開されている

makeで何かおもしろいものないかなぁとモジュール見てた。
聞いたことないサービス多いなぁという中、動物アイコンとかかわいいアイコンを調べてたらみつけちゃった!

調べてみたらNASAのAPIが公開されているらしい。

早速登録したらすぐにメール届いた!!
NASAからメールとかテンションあがる!
#タイトルにNASAとか書いてないけど

指定した日付の写真を送ってくれるbotを作るぞ!

自分の誕生日の宇宙って気にならないですか?
ちょっと考えたらワクワクしちゃう。
自分の誕生日の宇宙写真見たいがためにbot作ってみようと考えた。

NASAのAPI使うのに参考にした記事はコチラ

LINEで日付を指定したら、NASAから写真を送ってもらうbotを作ってみる。
makeで作っていく

LINE → NASA → LINEでいいのか?

LINEのWatch Events
NASAのRead Picture of the Day
LINEのSend a Replay Message

エラーラッシュ

LINEから送る日付指定でつまづく

1995年6月16日から2024年8月7日(今日)である必要があるらしい。
私はそんなに若くないからエラーがでたのか・・・

じゃあその日付の中で指定してLINEから送る

エラーラッシュ

日付指定がどうしてもうまくいかない。
makeAIに助けてもらってなんとかNASAモジュールは通るようになった。

設定はこんな感じ

NASAがクリアされたら次は最後のLINE

Reply Tokenが違うらしい。
makeAIに聞きすぎて7日間出禁をくらった。
明日じゃないんだ。1週間も使えないんだ。かなしい。。。。

Messageにmakeに教えてもらった色々なコード入れてみたけれど、すべてエラーになる。

またまたしくじり先生になってしまいました。

ちなみに最後に出たエラーとmakeAIとの最後の会話。

image.png

It seems there are two issues with the "Send a Reply Message" module (ID: 6):

The replyToken parameter is missing a value.
The messages parameter is not formatted correctly as an array of objects.
Let's address these issues:

Missing replyToken: Ensure that the replyToken is correctly mapped from the previous module.
Incorrect messages format: Ensure that the messages parameter is an array of objects.
Here's the corrected mapping for the module with ID 6:

{
  "id": 6,
  "module": "line:sendAReplyMessage",
  "version": 1,
  "parameters": {
    "__IMTCONN__": 2439170
  },
  "mapper": {
    "replyToken": "{{2.events[0].replyToken}}",
    "messages": [
      {
        "type": "image",
        "originalContentUrl": "{{1.hdurl}}",
        "previewImageUrl": "{{1.url}}"
      }
    ],
    "notificationDisabled": false
  },
  "metadata": {
    "designer": {
      "x": -783,
      "y": -126
    },
    "restore": {
      "parameters": {
        "__IMTCONN__": {
          "label": "NASA (宇宙)",
          "data": {
            "scoped": "true",
            "connection": "line2"
          }
        }
      },
      "expect": {
        "messages": {
          "mode": "edit"
        },
        "notificationDisabled": {
          "mode": "chose"
        }
      }
    },
    "parameters": [
      {
        "name": "__IMTCONN__",
        "type": "account:line2",
        "label": "Connection",
        "required": true
      }
    ],
    "expect": [
      {
        "name": "replyToken",
        "type": "text",
        "label": "Reply Token",
        "required": true
      },
      {
        "name": "messages",
        "type": "array",
        "label": "Messages",
        "validate": {
          "maxItems": 5
        },
        "required": true,
        "spec": [
          {
            "name": "type",
            "type": "select",
            "label": "Type",
            "options": [
              {
                "label": "Text",
                "value": "text",
                "nested": [
                  {
                    "help": "For LINE emoji, use a `$` character as a placeholder and specify details in the LINE Emojis parameter.",
                    "name": "text",
                    "type": "text",
                    "label": "Text",
                    "required": true,
                    "validate": {
                      "max": 5000
                    }
                  },
                  {
                    "help": "The number of emoji items must be equal to the number of `$` on Text parameter.",
                    "name": "emojis",
                    "spec": [
                      {
                        "help": "Product ID for a set of LINE emoji. See [Sendable LINE emoji list](https://d.line-scdn.net/r/devcenter/sendable_line_emoji_list.pdf).",
                        "name": "productId",
                        "type": "text",
                        "label": "Product ID",
                        "required": true
                      },
                      {
                        "help": "ID for a LINE emoji inside a set. See [Sendable LINE emoji list](https://d.line-scdn.net/r/devcenter/sendable_line_emoji_list.pdf).",
                        "name": "emojiId",
                        "type": "text",
                        "label": "Emoji ID",
                        "required": true
                      }
                    ],
                    "type": "array",
                    "label": "LINE Emojis",
                    "validate": {
                      "maxItems": 20
                    }
                  }
                ],
                "default": true
              },
              {
                "label": "Sticker",
                "value": "sticker",
                "nested": [
                  {
                    "help": "Package ID for a set of stickers. For information on package IDs, see the [Sticker list](https://developers.line.biz/en/docs/messaging-api/sticker-list).",
                    "name": "packageId",
                    "type": "text",
                    "label": "Package ID",
                    "required": true
                  },
                  {
                    "help": "Sticker ID. For a list of sticker IDs for stickers that can be sent with the Messaging API, see the [Sticker list](https://developers.line.biz/en/docs/messaging-api/sticker-list).",
                    "name": "stickerId",
                    "type": "text",
                    "label": "Sticker ID",
                    "required": true
                  }
                ]
              },
              {
                "label": "Image",
                "value": "image",
                "nested": [
                  {
                    "help": "Max file size is 10 MB.\nSupported image format - JPG, JPEG or PNG",
                    "name": "originalContentUrl",
                    "type": "url",
                    "label": "Original Content URL",
                    "required": true,
                    "validate": {
                      "max": 1000
                    }
                  },
                  {
                    "help": "Max file size is 1 MB.\nSupported image format - JPG, JPEG or PNG",
                    "name": "previewImageUrl",
                    "type": "url",
                    "label": "Preview Image URL",
                    "required": true,
                    "validate": {
                      "max": 1000
                    }
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "name": "notificationDisabled",
        "type": "boolean",
        "label": "Notification Disabled",
        "required": true
      }
    ]
  }
}

これ全部貼り付けたけど、同じエラーがでたというオチ。

ノーコードツールもまだまだ難しいなぁ・・・と四苦八苦しつつも
やっぱり宇宙はみたいので、解決して見れるようにしたいです!

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