---
title: App
---



{/* 
  CONTRIBUTOR NOTE:
  ----------------
  This is a legacy document that is being deprecated.
  Please DO NOT make changes to this version.
  All updates should be directed to the new version at:
  /plugin-dev-en/9242-reverse-invocation-app
*/}

<Card title="This Documentation is Being Deprecated" icon="circle-exclamation" href="/plugin-dev-en/9242-reverse-invocation-app">
  <p>This page is being phased out as part of our documentation reorganization.</p>
  
  <p><strong>Click this card</strong> to be redirected to the updated version with the most current information.</p>
  
  <p>If you notice any discrepancies or areas needing improvement in the new documentation, please use the "Report an issue" button at the bottom of the page.</p>
</Card>

Reverse App requesting means plugins can access App data in Dify. This module supports both streaming and non-streaming App calls.

### **Endpoints Type:**

* For `Chatbot/Agent/Chatflow` type applications, they are all chat-type applications, having the same input and output parameters, thus can be uniformly viewed as a **Chat Interface**.
* For Workflow applications, they occupy a separate **Workflow Interface**.
* For Completion (text generation) applications, they occupy a separate **Completion Interface**.

Note: Plugins can only access Apps within the same Workspace as the plugin.

### **Requesting Chat Interface** **Entry Point**

#### Entry

```python
self.session.app.chat
```

#### **Endpoint Specification**

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

When `response_mode` is `streaming`, the interface returns `Generator[dict]`, otherwise returns `dict`. For specific interface fields, refer to `ServiceApi` return results.

#### **Example**

We can request a Chat type App in an `Endpoint` and directly return the results:

```python
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.workflow.invoke(
                app_id=app_id, inputs={}, response_mode="streaming", files=[]
            )
            for data in response:
                yield f"{json.dumps(data)} <br>"
        return Response(generator(), status=200, content_type="text/html")
```

**Requesting Workflow Endpint** **Entry Point**

#### Entry

```python
self.session.app.workflow
```

#### **Endpoint Specification**

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

### **Requesting Completion Endpoint**

#### Entry

```python
self.session.app.completion
```

**Endpoint Specification**

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

{/*
Contributing Section
DO NOT edit this section!
It will be automatically generated by the script.
*/}

---

[Edit this page](https://github.com/langgenius/dify-docs/edit/main/en/plugins/schema-definition/reverse-invocation-of-the-dify-service/app.mdx) | [Report an issue](https://github.com/langgenius/dify-docs/issues/new?title=Documentation%20Issue%3A%20&body=%23%23%20Issue%20Description%0A%3C%21--%20Please%20briefly%20describe%20the%20issue%20you%20found%20--%3E%0A%0A%23%23%20Page%20Link%0Ahttps%3A%2F%2Fgithub.com%2Flanggenius%2Fdify-docs%2Fblob%2Fmain%2Fen/plugins/schema-definition/reverse-invocation-of-the-dify-service%2Fapp.mdx%0A%0A%23%23%20Suggested%20Changes%0A%3C%21--%20If%20you%20have%20specific%20suggestions%20for%20changes%2C%20please%20describe%20them%20here%20--%3E%0A%0A%3C%21--%20Thank%20you%20for%20helping%20improve%20our%20documentation%21%20--%3E)

