Hello @ells-t ,
This is Gina from flareAI app helping Shopify merchants get $6Million+ in sales from Google Search, on autopilot.
If there is a need for multiple processes within a single application to subscribe to a common topic, like “bulk_operations/finish,” there are a few possible approaches you can consider.
→ Single webhook endpoint
Instead of having multiple webhook endpoints, you can utilize a single webhook endpoint that subscribes to the “bulk_operations/finish” topic. By doing so, all webhook notifications related to that topic will be received by this endpoint. To distinguish between process A and process B queries, you will need to examine the payload or relevant information within your app logic. By analyzing the received data, you can determine which process the webhook is associated with.
→ Multiple webhook endpoints
Another approach is to register separate webhook endpoints for process A and process B. Each endpoint will independently receive webhook notifications. You can set up one endpoint for process A and another for process B, both subscribing to the “bulk_operations/finish” topic. With this approach, the differentiation is handled at the endpoint level. Each endpoint is dedicated to a specific process, making it easier to manage and keep the logic separate.
The optimal approach depends on your specific requirements. If distinguishing between queries from process A and process B is necessary, it is recommended to register separate webhook endpoints. This allows you to handle the webhooks independently and take distinct actions based on the query source.
If differentiation is not required, employing a single webhook endpoint simplifies your code and facilitates management. However, you must devise a method to differentiate between queries within the webhook payload, as Shopify does not offer built-in functionality for this purpose. The responsibility for distinguishing between process A and process B queries lies with your application. You would need to analyze the data received in the webhook payload, such as query parameters or any other relevant information, to determine which process the webhook pertains to.
Consider the following techniques for distinguishing between queries in the webhook payload.
-
Utilize the ‘id’ field in the webhook payload, which is unique for each bulk operation. You can leverage this identifier to determine the originating process.
-
Inspect the ‘query_params’ field in the webhook payload, which contains the query parameters employed in the bulk operation. This information can help identify the process responsible for the query.
-
Combine both the ‘id’ and ‘query_params’ fields for the most accurate differentiation between queries. This approach provides a comprehensive means of identifying the query source.
The choice between a single webhook endpoint or multiple endpoints depends on your app’s specific requirements and how you prefer to organize and manage the webhook processing logic within your app.
I hope this information proves useful.
Gina