# 独自のSlackBotを設定する

## **概要**

SlackBotコネクタには、デフォルトでは**Anyflowが作成したSlackBot**が設定されています。

<figure><img src="https://files.readme.io/c01b9d0-image.png" alt="" width="375"><figcaption></figcaption></figure>

Anyflowのものでない独自のSlackBotを設定する方法について、このページで紹介します。

## **手順**

大まかな流れは以下のとおりです。

1. 独自のSlackBotを作成します（作成済の場合はスキップ可能）
2. SlackBotの Client ID と Client Secret をAnyflow CSチームに共有します
3. Anyflow側で設定を行うと独自のSlackBotからメッセージ投稿が行えるようになります
4. （任意）Slack側でのアプリ審査を行う

### **1.独自のSlackBotを作成する**

[Slack API](https://api.slack.com/)のページから、[Your Apps](https://api.slack.com/apps)に 進みます。

<figure><img src="https://files.readme.io/aab93b3-image.png" alt=""><figcaption></figcaption></figure>

Create New App を選択します。

<figure><img src="https://files.readme.io/ac9fb00-image.png" alt="" width="563"><figcaption></figcaption></figure>

モーダルからFrom scratch を選択します。

<figure><img src="https://files.readme.io/f6fc68d-image.png" alt="" width="563"><figcaption></figcaption></figure>

App Name, workspace を設定し、Create App を選択します。

<figure><img src="https://files.readme.io/85a8286-image.png" alt="" width="563"><figcaption></figcaption></figure>

左メニューから、OAuth & Permissions を選択します。

<figure><img src="https://files.readme.io/ca131c8-image.png" alt=""><figcaption></figcaption></figure>

Redirect URLS の欄で以下のコールバックURLを追加し、Save URLs を押します。

追加するURL：

```
https://for-product-api.anyflow.jp/oauth2/callback
```

<figure><img src="https://files.readme.io/8cbc48c-image.png" alt=""><figcaption></figcaption></figure>

Scopes の欄で以下のスコープを追加します。

追加するスコープ：

```
"users:read",
"chat:write",
"chat:write.public",
"users:read.email"
```

<figure><img src="https://files.readme.io/15b945b-image.png" alt=""><figcaption></figcaption></figure>

左側のメニューから「Manage Distribution」を選択します。

<figure><img src="https://files.readme.io/d45e625885395209d22121a21ccb3ec6a6e24146d75a4b39b7664ec2f6b900c4-image.png" alt=""><figcaption></figcaption></figure>

下にスクロールし、「Share Your App with Other Workspaces」のセクションに進みます。\
4つの条件が全てクリアされていると、「Active Public Distribution」のボタンが有効になります。

<figure><img src="https://files.readme.io/1f3d1e7ff78b6ff1b2c5d199c81009bdae257d01d185de3aa7d382d56b2b8d16-image.png" alt="" width="563"><figcaption></figcaption></figure>

「Active Public Distribution」のボタンを押すと、このアプリは他のワークスペースからでもインストールできるようになります。

<figure><img src="https://files.readme.io/dadeffa5b97c8de80fee2dd63273f9d59eed2e874224e0172207e791986c86f5-image.png" alt=""><figcaption></figcaption></figure>

左メニューから Basic Information に進みます。

<figure><img src="https://files.readme.io/43142c2-image.png" alt=""><figcaption></figcaption></figure>

App Credentials の欄にある Client ID と Client Secret の値をAnyflow CSチームにご共有ください。

<figure><img src="https://files.readme.io/3f00db7-image.png" alt=""><figcaption></figcaption></figure>

Anyflow側にて、OAuth Client をカスタムする設定が完了すると、独自のSlackBotからメッセージ投稿が行えるようになります。

<figure><img src="https://files.readme.io/b972246-image.png" alt="" width="375"><figcaption></figcaption></figure>

Botのアイコンや表示名などの設定も自由に行ってください。\
（基本的に Client ID, Secret に変更がなければ、Botの見た目やスコープなどの設定は即時反映されます。Anyflowへの共有は不要です）

{% hint style="success" %}

### 📘ヒント

Slack Bot 以外のコネクタでも独自のOAuthクライアントを設定できます。\
詳しくはOAuth画面をカスタムするをご確認ください。
{% endhint %}

Slack App Directory にアプリを追加すると、エンドユーザーがApp Directoryからアプリを検索して取得できるようになるほか、以下の「このアプリはSlackによる承認を受けていません。」の表示がなくなります。

<figure><img src="https://files.readme.io/dfebaaa261f69aca97903094232d4a62efb76e039c595539d0863226c0f25c6d-image.png" alt="" width="563"><figcaption></figcaption></figure>

Slack App Directory にアプリを追加するには、Slack側でのアプリ審査が必要となります。\
詳しくは以下のページをご確認ください。

**Slack App ディレクトリにアプリを提出しよう**\
<https://api.slack.com/lang/ja-jp/submitting-apps-to-the-directory>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs-embed.anyflow.jp/recipe/communication/slackbot-custom-original-bot.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
