> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dify.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# App

> プラグインから Dify アプリの Chat、Workflow、Completion インターフェースを呼び出す

> このドキュメントは AI によって自動翻訳されています。不正確な部分がある場合は、[英語版](/en/develop-plugin/features-and-specs/advanced-development/reverse-invocation-app) を参照してください。

プラグインは Dify 内の App を逆呼び出しして、そのデータにアクセスできます。ストリーミング呼び出しと非ストリーミング呼び出しの両方に対応しています。逆呼び出しの基本概念に不慣れな場合は、まず [Dify サービスの逆呼び出し](/ja/develop-plugin/features-and-specs/advanced-development/reverse-invocation) をお読みください。

**インターフェースの種類**：

* **Chat インターフェース**：`Chatbot`、`Agent`、`Chatflow` アプリケーションはすべてチャットベースで、入力パラメータと出力パラメータの型が共通のため、このインターフェースを共有します。
* **Workflow インターフェース**：Workflow アプリケーションで使用します。
* **Completion インターフェース**：Completion（テキスト生成）アプリケーションで使用します。

プラグインがアクセスできるのは、そのプラグインが存在するワークスペース内の App のみです。

## Chat インターフェースの呼び出し

### エントリーポイント

```python theme={null}
    self.session.app.chat
```

### インターフェース仕様

```python theme={null}
    def invoke(
        self,
        app_id: str,
        inputs: dict,
        response_mode: Literal["streaming", "blocking"],
        conversation_id: str,
        files: list,
    ) -> Generator[dict, None, None] | dict:
        pass
```

`response_mode` が `streaming` の場合、このインターフェースは `Generator[dict]` を返します。それ以外の場合は `dict` を返します。具体的なインターフェースフィールドについては、`ServiceApi` の戻り結果を参照してください。

### ユースケース

次の例では、`Endpoint` 内で Chat タイプの App を呼び出し、結果を直接返します。

```python theme={null}
import json
from typing import Mapping
from werkzeug import Request, Response
from dify_plugin import Endpoint

class Duck(Endpoint):
    def _invoke(self, r: Request, values: Mapping, settings: Mapping) -> Response:
        """
        Invokes the endpoint with the given request.
        """
        app_id = values["app_id"]

        def generator():
            response = self.session.app.chat.invoke(
                app_id=app_id,
                inputs={},
                response_mode="streaming",
                conversation_id="some-conversation-id",
                files=[],
            )

            for data in response:
                yield f"{json.dumps(data)} <br>"

        return Response(generator(), status=200, content_type="text/html")
```

## Workflow インターフェースの呼び出し

### エントリーポイント

```python theme={null}
    self.session.app.workflow
```

### インターフェース仕様

```python theme={null}
    def invoke(
        self,
        app_id: str,
        inputs: dict,
        response_mode: Literal["streaming", "blocking"],
        files: list,
    ) -> Generator[dict, None, None] | dict:
        pass
```

## Completion インターフェースの呼び出し

### エントリーポイント

```python theme={null}
    self.session.app.completion
```

### インターフェース仕様

```python theme={null}
    def invoke(
        self,
        app_id: str,
        inputs: dict,
        response_mode: Literal["streaming", "blocking"],
        files: list,
    ) -> Generator[dict, None, None] | dict:
        pass
```

## 関連リソース

* [Dify サービスの逆呼び出し](/ja/develop-plugin/features-and-specs/advanced-development/reverse-invocation) - 逆呼び出しの基本概念を理解する
* [モデルの逆呼び出し](/ja/develop-plugin/features-and-specs/advanced-development/reverse-invocation-model) - プラットフォーム内でモデル機能を呼び出す方法を学ぶ
* [ツールの逆呼び出し](/ja/develop-plugin/features-and-specs/advanced-development/reverse-invocation-tool) - 他のプラグインを呼び出す方法を学ぶ
* [Slack Bot プラグインの開発](/ja/develop-plugin/dev-guides-and-walkthroughs/develop-a-slack-bot-plugin) - 逆呼び出しを使用した実践的なアプリケーションケース
* [拡張プラグインの開発](/ja/develop-plugin/dev-guides-and-walkthroughs/endpoint) - 拡張プラグインの開発方法を学ぶ
