> For the complete documentation index, see [llms.txt](https://support.docstudio.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://support.docstudio.com/user/scenarios/running-scenarios/how-to-run-a-scenario-via-integration.md).

# ​How to Run a Scenario via Integration

You can run a specific scenario via an integration. To do this, set the scenario UUID in the envelope XML in the integration rule.

Integration data has the highest priority. It replaces scenario data if it’s defined in the integration rule.

Set the scenario UUID in the `<envelope>` tag as the `scenarioUuid` attribute:

{% code title="scenario-via-integration.xslt" lineNumbers="true" %}

```xml
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
        <envelope templateUuid="19089ab8-a828-4447-9129-44b1da1cbc9d" templateVersion="f2e1a1c5-15ac-4bfb-bf31-f1ddba652b89" scenarioUuid="e17db760-580a-4192-bc96-a91683123bea">
                ...
        </envelope>
    </xsl:template>
</xsl:stylesheet>
```

{% endcode %}

You can start a scenario from any step via an integration. The system automatically picks the first step that matches the template and version. It creates an envelope using the data from the integration rule.

By default, the scenario chain configuration is ignored for envelopes created via an integration rule. To chain envelopes, set the chain UUID in the `<envelope>` tag as the `chainUuid` attribute.

* Use a static UUID to chain all envelopes created by the integration.
* Use a dynamic UUID to chain envelopes separately per extracted file.

{% code title="scenario-via-integration-with-chain.xslt" lineNumbers="true" %}

```xml
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
        <envelope templateUuid="19089ab8-a828-4447-9129-44b1da1cbc9d" templateVersion="f2e1a1c5-15ac-4bfb-bf31-f1ddba652b89" scenarioUuid="e17db760-580a-4192-bc96-a91683123bea" chainUuid="e17db760-580a-4192-bc96-a91683123ben">
                ...
        </envelope>
    </xsl:template>
</xsl:stylesheet>
```

{% endcode %}
