generated at
GPTsでの会話内容をSlackに投稿する

手順1. Slack APIを使って、Botとしてメッセージを送信する
開くと「Create a Slack App」の入力画面ができ、下記それぞれ入力する
サイドメニューの「OAuth & Permissions」->「Scopes」->「Bot Token Scopes」に「Add an OAuth Scope」
chat:write scopeのみ追加


サイドメニュー「OAuth & Permissions」-> 「Install to Workspace」-> 遷移先で、許可する
Bot User OAuth Tokenが得られる。

Slackに、testチャネル(なんでも良い)を作り、このチャンネルに、上で作ったボットを追加する


これで、Terminalから、Curlコマンドが使える。
shell
curl -X POST -H 'Authorization: Bearer <ここに、Bot User Token>' \ -H 'Content-type: application/json' \ --data '{"channel":"test","text":"こんにちは from curl"}' \ https://slack.com/api/chat.postMessage


手順2. Actionsの設定

OpenAPIのSchemaはこちらを使用
yaml
openapi: 3.0.0 info: title: Slack-like Messaging API version: 1.2.0 description: API for sending messages in a chat channel servers: - url: https://slack.com/api description: Main server paths: /chat.postMessage: post: summary: Send a message to a specific channel operationId: sendMessage tags: - Messages requestBody: required: true content: application/json: schema: type: object properties: channel: type: string description: ID of the channel to send the message to text: type: string description: The text message to be sent required: - channel - text responses: "200": description: Message sent successfully content: application/json: schema: type: object properties: success: type: boolean message_id: type: string description: ID of the sent message "400": description: Invalid request "500": description: Internal server error

Authenticationに以下を設定
Authentication Type: API Key
API Key: 上で作成した、Bot User OAuth Token
Auth Type: Bearer

Actions完成形は、このような形

system promptは、たとえばこんな形
プロンプト
直前のユーザーの会話を、Slackのtestチャンネルに投稿します。 チャンネルの指定があった場合はそのチャンネルに投稿してください。 投稿しましたなどの報告は不要です。 ユーザーへ、自然な返答を返してください。




参考