Create Shopify Flow actions
Connect your app to Shopify Flow, so that your app receives data and information when a workflow action runs.
The example used in this task creates a trigger that starts a workflow when a customer is added to a campaign in your app.
Before you begin
Make sure that you have the following:
- A test app that has access to the Internet, so that it can receive POSTs from Shopify Flow.
- A test store that has Shopify Flow installed. You can install Shopify Flow from the Shopify App Store.
Step 1: Add an action connector for Shopify Flow (Shopify Partner Dashboard)
To add an action to Shopify Flow, you need to create an action connector for your app. This action needs to contain the following information:
- the fields that the merchant needs to complete when they add your action their workflows
- the URL that Shopify Flow needs to use to send (POST) the contents (JSON payload) of the action to your app.
To create an action for Shopify Flow:
In the Partner Dashboard, open Apps and then click your test app.
Click Extensions > Shopify Flow: If you don't see Shopify Flow listed under Extensions, then you need to add the extension to your app.
Click Add action.
Enter a title and description for your action. For example, enter Log and Logs messages to the console respectively. In the Action Preview area, you can see how the title and action will appear to your merchants when they are choosing actions in Shopify Flow.
Enter the URL where the JSON payload will be sent to your app.
Click Create field and create the fields that will appear in Shopify Flow when your merchant chooses your app action. For example, to create a field for the merchant to send a message to your app add the following values:
Option Value Field name
Input type Text (single line) Label The APP Message Additional description Message to log to the APP’s console.
In the Payload preview area, you can see the data model that Shopify Flow will use in the JSON payload that it sends to your app.
Step 2: Add support for your action in your app
After you create the action in the Partner Dashboard, you need to add a service to your app to listen for the JSON payload that Shopify Flow will send. For security reasons, your service should enforce a hash-based message authentication (HMAC) header verification that uses the API secret key that you created when you configured your app.
When your action runs in a workflow, Shopify Flow posts the contents (JSON payload) of the action to the URL that you entered when you created the action in the Partner Dashboard. When your app receives the POST request, the app processes it. For example, you app could receive the request, and output the message in the payload to a console in your app.
Step 3: Test your action in a workflow (Shopify Flow)
Now that you’ve created an acton in the Partner Dashboard and added support for it in your app, you can test it in Shopify Flow. In your test store, create a workflow that uses the action that you created for your app:
In your test store, install your app.
In your test store, create a Shopify Flow workflow that uses your action.
In your test store, trigger the workflow. For example, create an order.
When this workflow completes, the message that you added when you created the workflow appears in your app’s server console.