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

# Utilizing Workflow Managed Templates

You can create Workflows using pre-built templates, which are designed to fulfill specific automation use cases. Workflow templates are designed and an managed by the platform to ensure reliability and consistency. When you create a Workflow from a template, editing is restricted and you won't be able to alter the main design flow by adding or removing functions. However, you will be able to edit functions to provide required parameters to suit the particular Workflow instance such as adding any required credentials.

This topic explains how to utilize Workflow managed templates by providing a worked example of creating a Workflow to automate usage data ingest into the m3ter platform:

* [Worked Example](#worked-example)
* [Prerequisites](#prerequisites)
* [Creating a Workflow from a Managed Template](#creating-a-workflow-from-a-managed-template)
* [Adding and Configuring a Webhook Trigger](#adding-and-configuring-a-webhook-trigger)

If you want to utilize a Workflow managed template but avoid the editing restrictions imposed on your Workflow instance, you can instead branch from a managed template:

* [Branching from a Managed Template](#branching-from-a-managed-template)

<Warning>
  **Review First!** Before attempting to follow this worked example and create a m3sh Workflow based on a managed template, please review the earlier topics in this section introducing [Workflow Key Concepts and Options](/guides/m3sh-workflows/m3sh-workflows-key-concepts-and-options) and the [Workflow Builder](/guides/m3sh-workflows/getting-to-know-the-workflow-builder).
</Warning>

## Worked Example

If your operational use case for ingesting customer usage data into the m3ter platform calls for a file upload from data files stored in an AWS S3 bucket, you can utilize the **Submit measurements from S3 source with SNS Trigger** Workflow managed template designed to meet this requirement:

* Uses an Incoming Webhook trigger that exploits the AWS Simple Notification Service (SNS) - a Workflow run is triggered when a file is uploaded to the designated AWS S3 bucket.
* When triggered, the Workflow reads the file's content, applies transformations on the usage data, and ingests the data into the m3ter platform via the m3ter File Upload service.

<Warning>
  **Warnings and Notes!**

  * **Slow throughput**. m3sh Workflows are slow to process so using this managed template to implement a usage data ingest solution doesn’t in any way align with the current ingest Service Level Agreements (SLAs) and is NOT recommended as a valid solution for high throughput ingest scenarios.
  * **Troubleshooting**. Using a Workflow for usage data ingest introduces an additional point of failure. If something fails *before* the file is processed by the Workflow, you will need to look for the causes of failure as an integration error event, not an ingest error one.
</Warning>

## Prerequisites

To complete the configuration and setup for a usage data ingest Workflow based on the **Submit measurements from S3 source with SNS Trigger** Workflow managed template, you'll need to perform some prerequisite work:

* [Setting Up Credentials](#setting-up-credentials)
* [Checking Usage Data Files](#checking-usage-data-files)

### Setting Up Credentials

you must first create required Credentials in your m3ter Organization:

* [Creating Incoming Webhook Credential for AWS SNS Request](#creating-incoming-webhook-credential-for-aws-sns-request)
* [Creating AWS Service Credential](#creating-aws-service-credential)

#### Creating Incoming Webhook Credential for AWS SNS Request

In the m3ter Console, open the **Settings>Integrations** page and select the **Credentials** tab. From there you can create an AWS SNS Request Incoming Webhook Credential:

* Enter a **Name** for the Credential and for **Destination**, select **m3sh Workflow**.
* For **Type** select **AWS SNS request**.
* For **Topic arn**, enter the relevant Amazon Resource Name in the standard format including `region` and `account-id`. For example:

`arn:aws:sns:eu-west-2:441235399388:m3sh-measurements`

* Select **Create credential**. The new Incoming Webhook Credential is listed on the **Integrations** page under **Credentials**:

<img src="https://mintcdn.com/m3ter/JDLEbvkzfCbdo08X/images/M3shAutomation311.png?fit=max&auto=format&n=JDLEbvkzfCbdo08X&q=85&s=919b386ddb8874f6512d478777f19829" alt="M3sh Automation311" width="1266" height="458" data-path="images/M3shAutomation311.png" />

* When we add a trigger to the example Workflow for usage data ingest, this Incoming Webhook Credential will be available for selection, allowing the AWS SNS service to access our Workflow as destination and act as its trigger.

<Tip>
  **More details?** See [Creating Incoming Webhook Credentials](https://docs.m3ter.com/guides/integrations/setting-up-integrations/managing-integration-credentials#creating-incoming-webhook-credentials).
</Tip>

#### Creating AWS Service Credential

In the m3ter Console, open the **Settings>Integrations** page and select the **Credentials** tab. From there you can create an AWS Service Credential:

* Enter a **Name** for the Credential and for **Destination**, select **AWS**.
* For **Account id**, enter your AWS account number that hosts the IAM role m3ter will assume when connecting with AWS.
* For **Role name**, enter the IAM role m3ter will assume.
* Select **Create credential**. The new AWS Service Credential is listed on the **Integrations** page under **Credentials**:

<img src="https://mintcdn.com/m3ter/JDLEbvkzfCbdo08X/images/M3shAutomation316.png?fit=max&auto=format&n=JDLEbvkzfCbdo08X&q=85&s=341eb95ca84d73c23cbc97500d7e1c7f" alt="M3sh Automation316" width="1266" height="647" data-path="images/M3shAutomation316.png" />

* When we create the example Workflow for usage data ingest, this AWS Service Credential will be available for selection to configure the AWS Read from S3 function used as the second step in the Workflow and allowing it to access the S3 bucket.

<Tip>
  **More Details?** See [Creating and Managing Integration Credentials](/guides/integrations/setting-up-integrations/managing-integration-credentials).
</Tip>

### Checking Usage Data Files

The m3ter platform's File Upload service API for usage data measurements accepts JSON formatted files as the default. However, constraints are imposed on file structure and ingest will fail if these constraints are not met. For details, please review the [File Upload Service API](https://docs.m3ter.com/guides/billing-and-usage-data/submitting-usage-data/file-upload-service-api) topic and ensure the usage data measurements files in your AWS S3 buckets for file upload by the Workflow comply with these requirements.

<Note>
  **CSV Usage Data Files**. CSV formatted usage data files are also supported.
</Note>

## Creating a Workflow from a Managed Template

For the current worked example, from the *Workflows* page we can quickly create a Workflow from a managed template to implement usage data ingest using file upload from an S3 bucket.

**To create a m3sh Workflow from a managed template:**

1. Select **m3sh**:

<img src="https://mintcdn.com/m3ter/gg3zPcB5MVj--Cnq/images/m3shMainNav1.png?fit=max&auto=format&n=gg3zPcB5MVj--Cnq&q=85&s=c26ad71debe6cffcd46844fa558e0e6f" alt="M3sh Main Nav1" title="M3sh Main Nav1" style={{ width:"8%" }} width="61" height="64" data-path="images/m3shMainNav1.png" />

* The **Workflows** page opens.

2. Select **Create workflow>Create managed workflow**:

<img src="https://mintcdn.com/m3ter/JDLEbvkzfCbdo08X/images/M3shAutomation320.png?fit=max&auto=format&n=JDLEbvkzfCbdo08X&q=85&s=8f356baeb6964f07b827823441aa2e50" alt="M3sh Automation320" title="M3sh Automation320" style={{ width:"37%" }} width="297" height="297" data-path="images/M3shAutomation320.png" />

* The **Workflows>Create** from template page opens:

<img src="https://mintcdn.com/m3ter/JDLEbvkzfCbdo08X/images/M3shAutomation305.png?fit=max&auto=format&n=JDLEbvkzfCbdo08X&q=85&s=f8c8e2d3406c521872f193cc448372cb" alt="M3sh Automation305" width="1201" height="713" data-path="images/M3shAutomation305.png" />

3. Enter the details of the new Workflow:

* **Name**. (*Required*)
* **Code**. (*Required*)
* **Description**. (*Required*)
* **Workflow template**. (Required) Use the drop-down to select the **PLATFORM TEMPLATE** you want to base the new Workflow on: **Submit measurements fro S3 source with SNS trigger**.

4. Select **Create**. The new Workflow opens in the builder in **Draft** mode and is clearly flagged as **MANAGED**:

<img src="https://mintcdn.com/m3ter/JDLEbvkzfCbdo08X/images/M3shAutomation306.png?fit=max&auto=format&n=JDLEbvkzfCbdo08X&q=85&s=b60798ea68bf2d62030364433a1a3933" alt="M3sh Automation306" width="1200" height="812" data-path="images/M3shAutomation306.png" />

5. If you zoom in, you will see that the second step uses an **AWS Read from S3** function:

<img src="https://mintcdn.com/m3ter/JDLEbvkzfCbdo08X/images/M3shAutomation307.png?fit=max&auto=format&n=JDLEbvkzfCbdo08X&q=85&s=9334021378174632a9d8cd3929129e8b" alt="M3sh Automation307" title="M3sh Automation307" style={{ width:"38%" }} width="216" height="122" data-path="images/M3shAutomation307.png" />

* Note that this function is flagged as invalid because configuration is incomplete.

6. Select to open the function's **Edit** panel:

<img src="https://mintcdn.com/m3ter/JDLEbvkzfCbdo08X/images/M3shAutomation309.png?fit=max&auto=format&n=JDLEbvkzfCbdo08X&q=85&s=e43c70588892b8c000e070e84e828bc8" alt="M3sh Automation309" title="M3sh Automation309" style={{ width:"71%" }} width="889" height="865" data-path="images/M3shAutomation309.png" />

7. Enter the missing required details to complete the **AWS Read from S3** function's configuration:

* **Credentials**. Select the AWS Service Credential created above under [Prerequisites](#prerequisites).
* **Region**.
* **Bucket**.

For example:

<img src="https://mintcdn.com/m3ter/JDLEbvkzfCbdo08X/images/M3shAutomation317.png?fit=max&auto=format&n=JDLEbvkzfCbdo08X&q=85&s=afd1333ba20e9b305629923a298e0acf" alt="M3sh Automation317" title="M3sh Automation317" style={{ width:"80%" }} width="766" height="877" data-path="images/M3shAutomation317.png" />

* To complete setting up the Workflow, we must now add a webhook trigger to the usage data ingest Workflow - see the [following section](#adding-and-configuring-a-webhook-trigger).

<Note>
  **CSV Usage Data Files**. CSV formatted usage data files are also supported for upload and is an option available when you edit the **Read from S3** function for the Workflow.
</Note>

## Adding and Configuring a Webhook Trigger

When you add a webhook trigger to a Workflow, you have the option to select users in your Organization that you want to receive an email notification when the trigger is disabled.

**To add and configure a Workflow Webhook trigger:**

1. Select **m3sh**. The **Workflows** page opens.
2. Select the **Name** hotlink text of the Workflow you want to add a trigger to. The **Workflow** opens in **Draft** mode.
3. Select **Workflow triggers**. In the current worked example, no triggers have yet been added for the Workflow:

<img src="https://mintcdn.com/m3ter/giI4Unhw7J8GXJWM/images/M3shAutomation246.png?fit=max&auto=format&n=giI4Unhw7J8GXJWM&q=85&s=09481f9f7a805c9d1df6b10c408c43ab" alt="M3sh Automation246" title="M3sh Automation246" style={{ width:"83%" }} width="645" height="280" data-path="images/M3shAutomation246.png" />

4. Select **Add trigger>Add webhook trigger**:

<img src="https://mintcdn.com/m3ter/giI4Unhw7J8GXJWM/images/M3shAutomation247.png?fit=max&auto=format&n=giI4Unhw7J8GXJWM&q=85&s=af4201acc4322b547e19ac815a631b4c" alt="M3sh Automation247" title="M3sh Automation247" style={{ width:"35%" }} width="228" height="108" data-path="images/M3shAutomation247.png" />

* An **Add webhook trigger** dialog appears:

<img src="https://mintcdn.com/m3ter/JDLEbvkzfCbdo08X/images/M3shAutomation318.png?fit=max&auto=format&n=JDLEbvkzfCbdo08X&q=85&s=f1fdd83e3f49336cb58f2cb30d83dfa2" alt="M3sh Automation318" width="1004" height="338" data-path="images/M3shAutomation318.png" />

5. Enter a **Name** for the webhook trigger.
6. Use the **Credentials** drop-down to select the Incoming Webhook Credential you want to use to authenticate with the Workflow. For the current worked example, we've selected the Incoming Webhook Credential we set up above - see [Creating Incoming Webhook Credential for AWS SNS Request](#creating-incoming-webhook-credential-for-aws-sns-request).
7. Select **Submit**. The selected webhook trigger is listed under **Workflow triggers**:

* For the selected **INCOMING WEBHOOK**, you can check:
  * The URL and copy it to your clipboard.
  * Whether the webhook is **ACTIVE** or **INACTIVE**.

8. If you want to set up users in you Organization to receive an email notification if the trigger is disabled, select the **Details** icon:

<img src="https://mintcdn.com/m3ter/x9njGwvgYQSkiyfJ/images/DetailsIcon.png?fit=max&auto=format&n=x9njGwvgYQSkiyfJ&q=85&s=99fb80630065f9bc7047b03130aac1db" alt="Details Icon" title="Details Icon" style={{ width:"5%" }} width="32" height="31" data-path="images/DetailsIcon.png" />

* A **Workflow trigger** modal appears:

9. Under **Trigger options**, use the **Disabled notification users** drop-down to add the Organization users you want to receive an email notification if the Workflow trigger is disabled.

<Note>
  **Disabled Webhook Triggers:** Webhook triggers are automatically disabled if the Workflow encounters errors in 20 consecutive runs via a trigger.
</Note>

10. Select **Update**. A message shows to confirm that the **Trigger options** for notifying Organization users were updated successfully.
11. Select **Publish draft**. The Workflow is now ready to be triggered and run when you upload usage data files into the designated S3 bucket.

<Warning>
  **Important: Testing Usage Data Ingest Workflow!** Before you deploy the Workflow to your production environment, we *strongly recommend* that you run it in your test environment/m3ter sandbox Organization and check all run logs for any errors. You can use Usage [Data Explorer (v2)](/guides/data-explorer/usage-data-explorer-v2) after running the Workflow to check that all usage data measurement from your S3 file have been ingested as expected.
</Warning>

## Branching from a Managed Template

When you create a Workflow, you select a managed template as the starting point to branch your Workflow from. No editing restrictions are imposed and you'll be able to add new functions, remove functions, or modify functions. However, your Workflow will no longer benefit from updates made for future versions of the original platform managed template.

**To create a m3sh Workflow from a managed template:**

1. Select **m3sh**:

<img src="https://mintcdn.com/m3ter/gg3zPcB5MVj--Cnq/images/m3shMainNav1.png?fit=max&auto=format&n=gg3zPcB5MVj--Cnq&q=85&s=c26ad71debe6cffcd46844fa558e0e6f" alt="M3sh Main Nav1" title="M3sh Main Nav1" style={{ width:"8%" }} width="61" height="64" data-path="images/m3shMainNav1.png" />

* The **Workflows** page opens.

2. Select **Create workflow>Branch from template**:

<img src="https://mintcdn.com/m3ter/JDLEbvkzfCbdo08X/images/M3shAutomation321.png?fit=max&auto=format&n=JDLEbvkzfCbdo08X&q=85&s=23607e994f770e31904a8f5a1210c0e2" alt="M3sh Automation321" title="M3sh Automation321" style={{ width:"37%" }} width="299" height="482" data-path="images/M3shAutomation321.png" />

* A **Branch from template** modal opens:

<img src="https://mintcdn.com/m3ter/JDLEbvkzfCbdo08X/images/M3shAutomation323.png?fit=max&auto=format&n=JDLEbvkzfCbdo08X&q=85&s=5d0041630f346f8fdd2dd5122913e832" alt="M3sh Automation323" width="1003" height="635" data-path="images/M3shAutomation323.png" />

3. Under **PLATFORM TEMPLATES**, select the **Workflow template** you want to branch your new Workflow from. The selected template is loaded into the modal to preview it:

<img src="https://mintcdn.com/m3ter/JDLEbvkzfCbdo08X/images/M3shAutomation324.png?fit=max&auto=format&n=JDLEbvkzfCbdo08X&q=85&s=93603d29d8da25374583d85498c7b46f" alt="M3sh Automation324" width="1004" height="637" data-path="images/M3shAutomation324.png" />

* You can zoom in and inspect function details to assess the suitability of the template as a starting point for your new Workflow:

<img src="https://mintcdn.com/m3ter/JDLEbvkzfCbdo08X/images/M3shAutomation325.png?fit=max&auto=format&n=JDLEbvkzfCbdo08X&q=85&s=04bc5a89e4ece24646471ffeb4557dd9" alt="M3sh Automation325" width="1001" height="633" data-path="images/M3shAutomation325.png" />

4. Select the **Branch from this template** hotlink. The **Workflows>Create** page open allowing you to enter required details for the new Workflow:

* **Name**.
* **Code**.
* **Description**.

5. Select **Create**. The Workflow opens in the Builder in **Draft** mode:

<img src="https://mintcdn.com/m3ter/JDLEbvkzfCbdo08X/images/M3shAutomation328.png?fit=max&auto=format&n=JDLEbvkzfCbdo08X&q=85&s=b801d19b307434f55c1073645da4f86e" alt="M3sh Automation328" width="1320" height="810" data-path="images/M3shAutomation328.png" />

Note that:

* You can select to open the **Functions** menu or add **Global parameters**.
* The Workflow is *not flagged* as **MANAGED**.
