Flow Builder

You can find the Flow Builder under Settings > Shop. It allows you to automate and easily customise your business processes without programming knowledge and enables you to take event-based actions to a whole new level. With the Flow Builder, you can specify event triggers even further with the help of rules. Depending on the event, you can, for example, automate the sending of emails and even have URL calls or changes to the order status carried out.

Under the menu item Settings > Shop > Flow Builder you will find an overview of all the business flows that have been created. In addition to whether a flow is active, the name and description of each flow is displayed, as well as the trigger that triggers the business process.
You can edit or delete the existing flows using the context menu on the right-hand side.
You can also edit it by simply clicking on the respective name. 
You can create a completely new flow by clicking on the Add Flow button in the top right-hand corner and you will be taken directly to the configuration of this flow. 
When you edit a flow or create a new one, the two tabs General and Flow are available.

General

In the General tab, you can define the general configurations for the flow.

Name (1): Enter the name here. This is used together with the description in the overview to distinguish this flow from others.
Description (2): Enter a meaningful description here. Since this description is visible in the overview, it will help you to quickly distinguish this flow from others.
Priority (3): If you have several flows that use the same trigger, you can specify which flow should be processed first.
Active (4): You can use this switch to activate or deactivate the flow.

Flow

In the Flow tab you will find the actual Flow Builder. An intuitive but comprehensive editor with which you can specify which actions are triggered by a trigger. In addition, you have the option of defining conditions for these actions, under which the actions are to be executed.

Trigger

Every flow begins with a trigger. This specifies when the flow is executed. Select the trigger for which you would like to create a flow.

You can choose from the following triggers:

EventDescriptionActions
checkout.customer.before.loginTriggers as soon as a customer logs inNo action
checkout.customer.loginTriggers as soon as a customer logs inAdd/remove tag
checkout.customer.logoutTriggers when a customer logs outAdd/remove tag
checkout.customer.deletedTriggers if a customer gets deletedAdd/remove tag, send mail
user.recovery.requestTriggers when a user created a password recovery request at adminSend mail
checkout.customer.changed-payment-methodTriggers when a customer changes his payment method in the checkout processAdd/remove tag
checkout.order.placedTriggers when an order is placedAdd/remove tag, send mail, generate document, set order status
checkout.order.payment_method.changedTriggers when a user changed payment method during checkout processNo action
customer.recovery.requestTriggers when a customer recovers his passwordAdd/remove tag, send mail
checkout.customer.double_opt_in_registrationTriggers when a customer commits to his registration via double opt inAdd/remove tag, send mail
customer.group.registration.acceptedTriggers when admin accepted a user who register to join a customer groupAdd/remove tag, send mail
customer.group.registration.declined<Triggers when admin declined a user who register to join a customer groupAdd/remove tag, send mail
checkout.customer.registerTriggers when a new customer was registeredAdd/remove tag, send mail
checkout.customer.double_opt_in_guest_orderTriggers as soon as double opt-in is accepted in a guest orderAdd/remove tag, send mail
checkout.customer.guest_registerTriggers when a new guest customer was registeredAdd/remove tag, send mail
contact_form.send<Triggers when a contact form is sendSend mail
mail.after.create.messageTriggers when a mail message/ content is createdNo action
mail.before.sendTriggers before a mail is sendNo action
mail.sentTriggers when a mail is send from ShopwareNo action
newsletter.confirmTriggers when newsletter was confirmed by a userSend mail
newsletter.registerTriggers when user registered to subscribe to a sales channel newsletterSend mail
newsletter.unsubscribeTriggers when user unsubscribe from a sales channel newsletterSend mail
newsletter.updateDeprecated in 6.5.0Send mail
product_export.logTriggers when product export is executedNo action
state_enter.order_transaction.state.openTriggers when an order payment enters status "Open"Add/remove tag, send mail, generate document, set order status
state_leave.order_transaction.state.openTriggers when an order payment leaves status "Open"Add/remove tag, send mail, generate document, set order status
state_enter.order_transaction.state.paidTriggers when an order payment enters status "Paid"Add/remove tag, send mail, generate document, set order status
state_leave.order_transaction.state.paidTriggers when an order payment leaves status "Paid"Add/remove tag, send mail, generate document, set order status
state_enter.order_transaction.state.refunded_partiallyTriggers when an order payment enters status "Refunded partially"Add/remove tag, send mail, generate document, set order status
state_leave.order_transaction.state.refunded_partiallyTriggers when an order payment leaves status "Refund partially"Add/remove tag, send mail, generate document, set order status
state_enter.order_transaction.state.chargebackTriggers when an order payment enters status "In progress"Add/remove tag, send mail, generate document, set order status
state_leave.order_transaction.state.chargebackTriggers when an order payment leaves status "Chargeback"Add/remove tag, send mail, generate document, set order status
state_enter.order_transaction.state.paid_partiallyTriggers when an order payment enters status "Paid partially"Add/remove tag, send mail, generate document, set order status
state_leave.order_transaction.state.paid_partiallyTriggers when an order payment leaves status "Paid partially"
state_enter.order_transaction.state.failedTriggers when an order payment enters status "Failed"Add/remove tag, send mail, generate document, set order status
state_leave.order_transaction.state.failedTriggers when an order payment leaves status "Failed"Add/remove tag, send mail, generate document, set order status
state_enter.order_transaction.state.remindedTriggers when an order payment enters status "Reminded"Add/remove tag, send mail, generate document, set order status
state_leave.order_transaction.state.reminded<Triggers when an order payment leaves status "Reminded"Add/remove tag, send mail, generate document, set order status
state_enter.order_transaction.state.authorizedTriggers when an order payment enters status "Authorized"Add/remove tag, send mail, generate document, set order status
state_leave.order_transaction.state.authorizedTriggers when an order payment leaves status "Authorized"Add/remove tag, send mail, generate document, set order status
state_enter.order_transaction.state.cancelledTriggers when an order payment enters status "Cancelled"Add/remove tag, send mail, generate document, set order status
state_leave.order_transaction.state.cancelledTriggers when an order payment leaves status "Cancelled"Add/remove tag, send mail, generate document, set order status
state_enter.order_transaction.state.refundedTriggers when an order payment enters status "Refunded"Add/remove tag, send mail, generate document, set order status
state_leave.order_transaction.state.refundedTriggers when an order payment leaves status "Refunded"Add/remove tag, send mail, generate document, set order status
state_enter.order_transaction.state.in_progressTriggers when an order payment enters status "In progress"Add/remove tag, send mail, generate document, set order status
state_leave.order_transaction.state.in_progressTriggers when an order payment leaves status "In progress"Add/remove tag, send mail, generate document, set order status
state_enter.order_delivery.state.returned_partiallyTriggers when an order delivery enters status "Return partially"Add/remove tag, send mail, generate document, set order status
state_leave.order_delivery.state.returned_partiallyTriggers when an order delivery leaves status "Return partially"Add/remove tag, send mail, generate document, set order status
state_enter.order_delivery.state.returnedTriggers when an order delivery enters status "Returned"Add/remove tag, send mail, generate document, set order status
state_leave.order_delivery.state.returnedTriggers when an order delivery leaves status "Returned"Add/remove tag, send mail, generate document, set order status
state_enter.order_delivery.state.cancelledTriggers when an order delivery enters status "Cancelled"Add/remove tag, send mail, generate document, set order status
state_leave.order_delivery.state.cancelledTriggers when an order delivery leaves status "Cancelled"Add/remove tag, send mail, generate document, set order status
state_enter.order_delivery.state.openTriggers when an order delivery enters status "Open"Add/remove tag, send mail, generate document, set order status
state_leave.order_delivery.state.openTriggers when an order delivery leaves status "Open"Add/remove tag, send mail, generate document, set order status
state_enter.order_delivery.state.shippedTriggers when an order delivery enters status "Shipped"Add/remove tag, send mail, generate document, set order status
state_leave.order_delivery.state.shippedTriggers when an order delivery leaves status "Shipped"Add/remove tag, send mail, generate document, set order status
state_enter.order_delivery.state.shipped_partiallyTriggers when an order delivery enters status "Shipped partially"Add/remove tag, send mail, generate document, set order status
state_leave.order_delivery.state.shipped_partiallyTriggers when an order delivery status is changed from "Shipped partially" to from another statusAdd/remove tag, send mail, generate document, set order status
state_enter.order.state.in_progressTriggers when an order enters status "In progress"Add/remove tag, send mail, generate document, set order status
state_leave.order.state.in_progressTriggers when an order leaves status "In progress"Add/remove tag, send mail, generate document, set order status
state_enter.order.state.completedTriggers when an order enters status "Completed"Add/remove tag, send mail, generate document, set order status
state_leave.order.state.completedTriggers when an order leaves status "Completed"Add/remove tag, send mail, generate document, set order status
state_enter.order.state.openTriggers when an order enters status "Open"Add/remove tag, send mail, generate document, set order status
state_leave.order.state.openTriggers when an order leaves status "Open"Add/remove tag, send mail, generate document, set order status
state_enter.order.state.cancelledTriggers when an order enters status "Cancelled"Add/remove tag, send mail, generate document, set order status
state_leave.order.state.cancelledTriggers when an order leaves status "Cancelled"Add/remove tag, send mail, generate document, set order status
state_enter.order_transaction.state.unconfirmedTriggers when an order payment enters status "Unconfirmed"Add/remove tag, send mail, generate document, set order status
state_leave.order_transaction.state.unconfirmedTriggers when an order payment leaves status "Unconfirmed"Add/remove tag, send mail, generate document, set order status
**Notice: Stop flow action: Available for all events.  

Condition

Conditions are used to refine the flow. For this purpose, the rules from the Rule Builder are used or new rules are created directly for it. These rules can then be used to determine whether and which action is executed. For more extensive flows, several conditions can be queried one after the other.

Each condition has two possible outcomes. True or False. For each result, you can define further conditions or actions that are then to be processed.

Action

The action is executed as soon as the trigger has been triggered and all preceding conditions have been fulfilled or not.

Depending on the trigger, not all actions may be available. For example, a tag can only be added if the trigger concerns an entity to which a tag can be attached by default.

The following actions can be selected depending on the trigger:
Add Tag / Remove Tag:
Here you can select an entity that is affected by the trigger and add or remove a tag to it.

Create a document:
This action creates a new document in the current order. In the dropdown menu you can define which document type should be created by this action.

Send mail:
With this action you can have emails sent automatically. In the configuration, first select a recipient. In addition to the administrator and the customer, this can also be one or more defined email addresses. Next, you select an email template that is to be sent and specify whether and which documents you want to add to the email.

Set status:
This action allows you to change the payment status, shipping status and order status of the order affected by the trigger.

Stop flow
You can include this action in the Flow Builder at any point where nothing else should happen. This can be the case, for example, if an action is only to be executed if the condition is true. If the condition is false, you then set the action Stop flow.

Examples

Tag new customers

In this example, new customers are to receive a tag indicating which country they come from.
For this purpose, the trigger Checkout / Customer / Register is selected because it is triggered as soon as a customer registers. Then it is gradually checked whether the customer comes from the USA, Austria or Switzerland and, if necessary, a corresponding tag is added to the customer. 
If the customer does not come from one of these countries, no tag is assigned.

Send documents automatically

In this example, the invoice is to be sent automatically with the confirmation mail. To do this, you use the trigger Checkout / Order / Placed. This trigger is triggered as soon as an order is placed in your shop.
First, you must create the document that is to be sent automatically. In this example, you first select generate document as the action and then select invoice as the document type. 
In the next step, this document will be attached to the automatic notification. Below the action generate document, add another action send email and select default as the recipient so that the customer receives the email. For the email template, select order confirmation to send an order confirmation and select the desired document to be attached to the email. 

Notify the warehouse of a paid order

In this example, you send a mail to the warehouse as soon as an order has been paid for so that the warehouse can dispatch the goods. The first step is to select State enter / Order transaction / State / Paid as the trigger state. This trigger is triggered as soon as the payment status changes to paid
Next, you decide whether the warehouse should also receive the customer's invoice and/or delivery note. In this case, you first select create document as the action and select the corresponding document. In our example, you send an invoice and therefore select invoice. As a subsequent action, you select Send email so that an email will be sent to the warehouse.

In the configuration of the Send email action, select custom recipient as the recipient. This allows you to specify an individual email address to which the email is to be sent. Then enter the email address of the warehouse or the responsible employee. You can select any template as the email template or create one yourself for this standard email. In our example we send the default template for Enter payment state: Paid. Finally, you select which document is to be sent. In our example, the invoice is sent along. However, you can also select several documents (e.g. invoice and delivery note) to be sent along.

Please not that it is important that the documents that are to be sent along were automatically generated in the previous step.

Notification to an external platform (Slack)

In this example, we will show you how to send a notification to an external platform such as Slack using Flowbuilder. For this example you need the extension Flow Builder Professional for Shopware 6 which includes the action Webhook.

Slack: 
To do this, first create a new workflow in Slack. You can find all information about the workflows in Slack and how to find the Workflow Builder here
In the Workflow Builder, you first create a new workflow. Every workflow needs a trigger and at least one action, which is called a step in Slack. You select webhook as the trigger, as we will use this in the Shopware Flow Builder.

URL of the web request (1): The target address that you need for the webhook in Shopware Flowbuilder is displayed here. You should always save this address. This address is not yet displayed when you call up the trigger for the first time. It will only be displayed as soon as you have completed and published the complete workflow.

Variables (2): It doesn't really matter how you name the variables. In this example, however, we use the following:

  • orderURL: Here we will store the URL to the order.
  • orderPositions: Here we will store a listing of all positions from the order.
  • orderNumber: Here we will store the order number of the order.
  • orderCustomerAdress: Here we will store the customer address.

HTTP sample text (3): We will need this sample text later in Shopware Flowbuilder to transfer the variables with the webhook. You should therefore also save this text.

Next, you add a step to the workflow that should be executed as soon as the trigger takes effect. In our example, we choose the send message step to send a user or Slack group a message with the new order.

Send this message to (1): Select the users or the Slack group to which the message should be sent.

Message text (2): Here you can design the message text. To add your previously created variants, click on insert variable at the bottom right. In our example, we insert a heading and have the content of the variables displayed, which we will later fill with the order content in Shopware Flowbuilder.

Im Shopware Flow Builder
In the Shopware Flow Builder, you can either edit the existing flow for incoming orders or create a new one and select Checkout / Order / Placed as the trigger. If, for example, you only want to create the Slack message for orders that have already been paid for, you can also select State Enter / Order Transaction / State / Paid as the trigger.  
If you do not want to specify any further conditions for creating a Slack message, select Call URL (Webhook) as the action.

Method (1): Choose the POST method here, as we want to transmit information to Slack.
URL (2): Enter the target URL here. This was created in the Slack configuration under the item URL of the web request.
Parameters (3): Since Slack expects the parameters in the body, you can still leave the parameters empty here.

In the Body tab, select the BodyType: Raw and copy the HTTP example from Slack into the code.


{
  "orderURL": "Sample text",
  "orderPositions": "Sample text",
  "orderNumber": "Sample text",
  "orderCustomerAdress": "Sample text"
}

You now replace the content of the variables with Shopware variables that you also know from the email templates. For our example, the code would look like this:


{
  "orderURL": "http://doku1.test.shopware.in/admin#/sw/order/detail/{{ order.id }}",
  "orderPositions": "
 {% for lineItem in order.LineItems %}
 {{ lineItem.payload.productNumber }} - {{ lineItem.label }}
    
 {% endfor %}",
  "orderNumber": "{{ order.orderNumber }}",
  "orderCustomerAdress": "{% set billingAddress = order.addresses.get(order.billingAddressId) %}
{{ billingAddress.company }}
{{ billingAddress.firstName }} {{ billingAddress.lastName }}
{{ billingAddress.street }}
{{ billingAddress.zipcode }} {{ billingAddress.city }}
{{ billingAddress.country.translated.name }}"
}

After saving this configuration, the workflow should be correctly integrated. As soon as an order is received in your shop, a corresponding message is automatically generated in Slack..

Flow Builder Professional for Shopware 6

This extension is available with a Professional Subscription. It extends the Flow Builder with further useful functions.

Action: Call URL (Webhook)

With this action, you can have a web URL called automatically and pass parameters as soon as the trigger is fired. A WebHook makes it possible, for example, to tell a server software that a certain event, such as a new order, has occurred. This can be a notification or a request to the server to do something with the information.
General

Method (1): Generally we support 5 different methods of a webhook.

  • Get: In this method, information is to be obtained from a remote resource.
  • POST: This method is used to transmit a piece of information to a remote resource.
  • PUT: The PUT method replaces information in the target resource with information in the current request.
  • PATCH: This method is used to make partial changes to a piece of information on the remote resource.
  • DELETE: This method can be used to remove a specific piece of information from the target resource.

URL (2): The URL specifies the destination to which the webhook should be sent.
Description (3): In the description you can note the purpose of this webhook to be able to classify it correctly later.
Parameters (4): Depending on the goal and task of the webhook, it may be necessary to include parameters from the store system. You can do this via the parameters. To do this, enter a parameter name on the left side and select the parameter on the right side that is to be transmitted to the target via this parameter name.
URL-Vorschau (5): Hier siehst Du eine Vorschau der URL inklusive der angegebenen Parameter, die mit ans Ziel ├╝bergeben werden.

Header-Parameters

Some servers that accept webhooks expect special header parameters. These can be stored here.

Body

Some servers that accept webhooks expect a special body. This can either be in the form of parameters that are passed in, like the header, or as code. Slack, for example, uses this to pass parameters. How the code should then look is usually specified by the target server to which the webhook is to be sent. The Shopware variables can be accessed in the code.

Basic Auth

If the destination requires authentication, this can be activated here and the necessary access data stored.

Was this article helpful?