0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

今日の天気予報を好きなキャラで私の Slack 宛に送りつける

Last updated at Posted at 2025-01-27

材料さえあれば比較的簡単に自分好みのキャラで毎日天気予報を送り付けることができます。

image.png

材料

  • Slack
  • Azure OpenAI
  • Azure Logic Apps

詳細

Slack

無料の範囲内で使っています。投稿用なので、Slack でなくとも Line Bot などでも良いです。

Azure OpenAI

自分用のデプロイをひとつ用意しております。

image.png

POST https://{endpoint}/openai/deployments/{deployment-id}/chat/completions?api-version=2024-10-21

ここでは以下を用いています。

https://noyopenai.openai.azure.com/openai/deployments/noydeploy/chat/completions?api-version=2024-08-01-preview

image.png

Azure Logic Apps

マネージド ID

先に、当該 Logic Apps のシステム割り当てマネージド ID を有効にしておきましょう。Azure ロールの割り当てには Cognitive Services OpenAI User を指定しておきます。

image.png

トリガー

ワークフローを作成していきます。日次実行とします。

image.png

今日の予報を取得する

場所は東京。ほか特に何もしていません。

image.png

HTTP リクエスト

image.png

先ほど確認したエンドポイントへ POST を送ります。

本文は以下。

JSON
{
  "messages": [
    {
      "content": "今日の天気は@{body('今日の予報を取得する')}です。これをふなっしーのようにおしえてください。ふなっしーは「大人になるってのは成長なっしー」などとすべての語尾に なっしー を付けてしゃべります",
      "role": "user"
    }
  ]
}

メッセージの投稿_(V2)

メッセージの投稿結果が以下のようになります。

image.png

そのため body('HTTP')?['choices'][0]['message']?['content'] という形で内容を取得します。

image.png

投稿できた。

image.png

完成

自分メモ用 Slack に今日の天気を雨ニモマケズ風に毎日配信させています。サウイフモノニワタシハナリタイ。
image.png

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?