> For the complete documentation index, see [llms.txt](https://docs-embed.anyflow.jp/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs-embed.anyflow.jp/trial-tour/start/step3.md).

# STEP3｜ifステップ

## **概要**

STEP3では、STEP2のソリューションを活用し、**ソリューションの実行内容を条件分岐させる方法**をご紹介します。

今回のソリューションは、ifステップを設定することで実現可能になります。\
ifステップは、STEP2でマスターしたエンドユーザー変数なども指定条件として利用可能です。\
ぜひマスターしてみてください🎉

{% hint style="success" %}

### ifステップについて

今回はトライアルツアーで設定するための必要な情報のみをご紹介しております。\
ifステップの詳細については、[こちら](/solution-editor/logic/if.md)をご確認ください。
{% endhint %}

## **1.ソリューションを作成しよう（Lv3）**

[STEP2のソリューション](/trial-tour/start/step2.md)にて、「Slackのメッセージ投稿チャンネルが、\[# general]の場合にAというメッセージを投稿とする」といった、簡単なソリューションを設定します。

## **2. ifステップの設定**

### **2-1.ifステップを追加する**

トリガーとアクションの間にカーソルを合わせ、\[+] ボタンをクリックします。

<figure><img src="https://files.readme.io/db896b1-if-step-add.png" alt=""><figcaption></figcaption></figure>

***

\[ステップを追加] から \[ifステップ] を選択します。

<figure><img src="https://files.readme.io/97bdedd-if-step.png" alt=""><figcaption></figcaption></figure>

### **2-2. 条件を指定する**

今回は、Slackのメッセージを投稿するチャンネルが、 \[# general]の場合という条件指定をします。

### **2-3. チャンネル名が\[general]の場合の設定**

画面右側に、ifの設定画面が表示されるので、以下のように設定します。

* データ : エンドユーザー変数（STEP2で作成したもの）
* 状態 : \[等しい]
* 値 : \[# general のチャンネルID]（例:C54MBHJ5P）

{% hint style="danger" %}

### 指定する条件の値について

今回は、エンドユーザーが指定したSlackのチャンネル名が \[# general] の場合という条件指定ですが、\
条件指定する値の入力フィールドには、\[# general] のチャンネルID（例:`C54MBHJ5P`）を指定することで、条件指定が可能になります。\
（APIで取り扱うデータを指定する必要があるため）

チャンネル名（例:`general`）を入力してもエラーとなりますので、ご注意下さい。
{% endhint %}

上記の設定により、**Slackのチャンネル名が \[# general] だったら**という条件指定がされました。

<figure><img src="https://files.readme.io/1c349df-if-conditions.png" alt=""><figcaption></figcaption></figure>

***

### **2-4.メッセージの内容を指定する**

\[if]の下にある、\[Yes]の線上にカーソルを合わせ、\[+] ボタンをクリックします。

<figure><img src="https://files.readme.io/6426881-if-yes.png" alt=""><figcaption></figcaption></figure>

***

\[アクション] をクリック

<figure><img src="https://files.readme.io/653d06c-if-yes-actions.png" alt=""><figcaption></figcaption></figure>

***

\[SlackBot] アクションを選択し、\[メッセージを投稿] を選択します。

<figure><img src="https://files.readme.io/5908e8f-slacbot-yes-actions.png" alt=""><figcaption></figcaption></figure>

***

* 投稿するチャンネル : \[エンドユーザー変数] を選択
* メッセージ : テキストを入力します。

<figure><img src="https://files.readme.io/a5014cc-slacbot-yes-message.png" alt=""><figcaption></figcaption></figure>

***

4 のSlackアクションを削除します。\
該当アクションの右側の \[…] をクリックし、\[削除] を選択します。

<figure><img src="https://files.readme.io/7c327c4-actions-delete.png" alt=""><figcaption></figcaption></figure>

***

アクションが削除されました。

<figure><img src="https://files.readme.io/0b83dc9-setting-done.png" alt=""><figcaption></figcaption></figure>

以上で、全ての設定が完了です🎉

***

## **3.テスト実行**

[STEP1](/trial-tour/start/step1.md#id-4tesuto)と同様の方法でテスト実行を行います。\
ifステップで指定したSlackのチャンネルに正しくメッセージが投稿されているか確認します。

また、テストの実行履歴が確認可能です。\
今回は、\[ifステップ] の \[入力値] を確認すると`true`になっているため、指定した条件が合致しているといった結果になっています。

<figure><img src="https://files.readme.io/eae9fbc-test-result.png" alt=""><figcaption></figcaption></figure>

***

## **まとめ**

今回のセクションでは、ifステップについて学ぶことができました。\
その他、様々な条件指定が可能なので、様々な条件を試してみてください。

***

## **ネクストステップ**

次は、STEP1〜3のソリューションを活用し、変数を使用したソリューションの方法とデバッグの方法をご紹介します。\
[STEP4｜変数の活用、デバッグ](/trial-tour/start/step4.md) にお進みください。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs-embed.anyflow.jp/trial-tour/start/step3.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
