Add prebuilt integration to send Slack messages on new Shopify orders - #62
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdds a Ballerina integration that listens for Shopify order creation webhooks, extracts and formats order details using configurable templates and thresholds, and posts notifications to a Slack channel; includes Choreo metadata, config schema, docs, and project manifests. Changes
Sequence Diagram(s)sequenceDiagram
participant Shopify as Shopify Webhook
participant Service as Ballerina Service
participant Slack as Slack API
Shopify->>Service: POST order.created (OrderEvent)
activate Service
Service->>Service: extractOrderDetails(event)
Service->>Service: Check orderTotal >= minimumOrderPrice
alt meets threshold
Service->>Service: buildSlackMessage(details, customMessage)
Service->>Slack: chat.postMessage(channel, text, client_msg_id)
activate Slack
Slack-->>Service: 200 OK / confirmation
deactivate Slack
else below threshold
Service-->>Service: skip notification
end
deactivate Service
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 6
🧹 Nitpick comments (1)
ballerina-integrator/new-shopify-order-to-slack/config.bal (1)
8-9: Prefer a privacy-safer default template.The default message includes customer email and shipping location, and
ballerina-integrator/new-shopify-order-to-slack/main.bal, Line 22-29 sends that rendered text straight to Slack. For a sample people will copy with defaults, it would be safer to leave those placeholders out and make PII opt-in.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ballerina-integrator/new-shopify-order-to-slack/config.bal` around lines 8 - 9, The current default configurable string customMessage includes PII placeholders (customerEmail, shippingAddress) that get posted to Slack by the publisher in main.bal (where the rendered text is sent), so change the default value of configurable string customMessage to remove PII placeholders (omit {customerEmail} and {shippingAddress} and any other direct PII like full address) and keep only non-PII placeholders (e.g., {orderId}, {customerName}, {itemCount}, {items}, {totalPrice}, {currency}, {createdAt}); retain the placeholders for the sensitive fields so operators can opt-in by overriding the configurable value, and ensure any documentation or comments mention that PII must be explicitly enabled via the configurable variable.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@ballerina-integrator/new-shopify-order-to-slack/.choreo/config-schema.json`:
- Around line 10-32: The schema currently omits the minimumOrderPrice setting
used by config.bal/main.bal and exposes shopifyPort which is not used
(connections.bal hard-codes 8090) while additionalProperties is false; update
config-schema.json to add a minimumOrderPrice property (number/integer with
description) so the Choreo contract matches config.bal/main.bal, and either
remove shopifyPort from the schema or make it a real configurable knob by adding
shopifyPort to config.bal and wiring it into connections.bal (replace the
hard-coded 8090 with the config value); keep additionalProperties=false only if
the schema now accurately reflects all used config fields.
In `@ballerina-integrator/new-shopify-order-to-slack/config.bal`:
- Around line 11-12: Change the configurable minimumOrderPrice from int to
decimal (configurable decimal minimumOrderPrice = 0.0) so fractional thresholds
like 49.99 are representable, and update the comparison in main.bal (where order
totals are decimal) to compare the order's decimal total directly against
minimumOrderPrice instead of casting or converting from int; ensure any
default/zero value uses a decimal literal and remove any int-to-decimal casts
around minimumOrderPrice usage.
In `@ballerina-integrator/new-shopify-order-to-slack/functions.bal`:
- Around line 88-108: The buildSlackMessage function inserts raw Shopify values
into the Slack template, which lets characters like &, <, > be interpreted as
mrkdwn; create a small HTML-escape helper (e.g., escapeHtml) and call it on
every event-derived field before doing the regex replacements inside
buildSlackMessage — at minimum apply to details.customerFullName,
details.customerEmail, details.itemsDetails, details.shippingAddress and any
other details.* fields used for substitution so that & => &, < => <, and
> => > are replaced prior to placeholder replacement.
In `@ballerina-integrator/new-shopify-order-to-slack/main.bal`:
- Around line 24-30: The Slack posting currently sends duplicate messages on
webhook retries; modify the call to slackClient->/chat\.postMessage.post to
include clientMsgId set to the unique event id extracted by extractOrderDetails
(use event?.id or orderDetails.eventId/orderNumber as appropriate) to let Slack
deduplicate client-side, and add durable deduplication: persist processed event
IDs (e.g., in a small file, DB table, or KV store) and check that store at the
start of your webhook handler (and before calling
slackClient->/chat\.postMessage.post) to skip already-processed event IDs and
write the id after successful post so retries across restarts are ignored.
In `@ballerina-integrator/new-shopify-order-to-slack/README.md`:
- Around line 34-42: Update the README to reflect the actual configuration
contract: state that customMessage has a default in config.bal (so it's
optional), add documentation for minimumOrderPrice (name must match the config
key used in config.bal) and clarify its semantics as "greater than or equal to"
to match the existing comparison (orderPrice < minPrice) in the filter logic,
and ensure the same wording is copied into .choreo/instructions.md so both docs
stay aligned; reference config.bal, the customMessage setting, the
minimumOrderPrice threshold, and the orderPrice < minPrice check when updating
the text.
- Around line 24-30: Update the Slack setup instructions in README.md (steps
about OAuth token and channel membership) and .choreo/instructions.md to
instruct creating a Slack App with a bot token (xoxb-), granting the bot the
chat:write scope (and chat:write.public if posting to public channels),
installing the app to the workspace, and adding the bot to the target channel
(instead of copying a user OAuth token xoxp- and relying on a personal account);
replace references to "User OAuth Token" and personal account membership with
the bot token flow and note where to find the Bot User OAuth Token and how to
add the app/bot to channels.
---
Nitpick comments:
In `@ballerina-integrator/new-shopify-order-to-slack/config.bal`:
- Around line 8-9: The current default configurable string customMessage
includes PII placeholders (customerEmail, shippingAddress) that get posted to
Slack by the publisher in main.bal (where the rendered text is sent), so change
the default value of configurable string customMessage to remove PII
placeholders (omit {customerEmail} and {shippingAddress} and any other direct
PII like full address) and keep only non-PII placeholders (e.g., {orderId},
{customerName}, {itemCount}, {items}, {totalPrice}, {currency}, {createdAt});
retain the placeholders for the sensitive fields so operators can opt-in by
overriding the configurable value, and ensure any documentation or comments
mention that PII must be explicitly enabled via the configurable variable.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: dce9cfcc-c579-4981-a24b-52c363c94722
📒 Files selected for processing (15)
ballerina-integrator/new-shopify-order-to-slack/.choreo/component.yamlballerina-integrator/new-shopify-order-to-slack/.choreo/config-schema.jsonballerina-integrator/new-shopify-order-to-slack/.choreo/diagram.mdballerina-integrator/new-shopify-order-to-slack/.choreo/instructions.mdballerina-integrator/new-shopify-order-to-slack/.gitignoreballerina-integrator/new-shopify-order-to-slack/Ballerina.tomlballerina-integrator/new-shopify-order-to-slack/README.mdballerina-integrator/new-shopify-order-to-slack/agents.balballerina-integrator/new-shopify-order-to-slack/automation.balballerina-integrator/new-shopify-order-to-slack/config.balballerina-integrator/new-shopify-order-to-slack/connections.balballerina-integrator/new-shopify-order-to-slack/data_mappings.balballerina-integrator/new-shopify-order-to-slack/functions.balballerina-integrator/new-shopify-order-to-slack/main.balballerina-integrator/new-shopify-order-to-slack/types.bal
- Change minimumOrderPrice from int to decimal - Add minimumOrderPrice to Choreo config schema - Implement HTML escaping for Slack text payload - Update Slack token instructions to use Bot Token (xoxb-) - Implement Slack message deduplication via client_msg_id - Remove PII from default customMessage template - Update README with optional configurations
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
ballerina-integrator/new-shopify-order-to-slack/.choreo/config-schema.json (1)
11-30: Consider adding descriptions for better Choreo UI experience.All property descriptions are empty strings. While not blocking, adding brief descriptions would improve the configuration experience in Choreo's UI.
📝 Example descriptions
"shopifyApiSecretKey": { "type": "string", - "description": "" + "description": "Shopify API secret key for webhook signature verification" }, "slackToken": { "type": "string", - "description": "" + "description": "Slack Bot Token (xoxb-...) for posting messages" }, "slackChannelId": { "type": "string", - "description": "" + "description": "Slack channel ID where notifications will be posted" }, "customMessage": { "type": "string", - "description": "" + "description": "Custom message template with placeholders (e.g., {orderName}, {totalPrice})" }, "minimumOrderPrice": { "type": "number", - "description": "" + "description": "Minimum order price threshold for sending notifications" }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ballerina-integrator/new-shopify-order-to-slack/.choreo/config-schema.json` around lines 11 - 30, Add meaningful non-empty "description" strings for each config property so Choreo UI shows helpful hints: update "shopifyApiSecretKey" to describe the Shopify secret/API key, "slackToken" to describe the Slack bot/user OAuth token, "slackChannelId" to explain the destination Slack channel ID, "customMessage" to note this is the optional message template sent to Slack, and "minimumOrderPrice" to explain it filters orders by minimum price (integer, currency implied). Keep descriptions concise (1–2 short sentences) and user-facing.ballerina-integrator/new-shopify-order-to-slack/functions.bal (1)
101-101: Support additional<br>variants in template normalization.Line 101 only converts lowercase
<br>. Consider also handling<br/>and<br />so user templates render consistently.💡 Suggested update
- slackMessage = re `<br>`.replaceAll(slackMessage, "\n"); + slackMessage = re `<br\s*/?>`.replaceAll(slackMessage, "\n");🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ballerina-integrator/new-shopify-order-to-slack/functions.bal` at line 101, Update the template normalization that currently only replaces lowercase "<br>" by changing the replaceAll call on slackMessage to match all common variants (case-insensitive) such as "<br>", "<br/>" and "<br />"; use a single regex like a case-insensitive pattern matching "<br" followed by optional whitespace and optional "/" then ">" (apply it in the existing replaceAll on slackMessage) so all variants convert to "\n".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@ballerina-integrator/new-shopify-order-to-slack/.choreo/config-schema.json`:
- Around line 27-30: The JSON Schema entry for minimumOrderPrice is incorrectly
typed as "integer"; update the schema for the property named minimumOrderPrice
in .choreo/config-schema.json to use "number" so it matches the decimal/float
usage in config.bal and accepts values like 99.99; ensure any validators or
consumers that reference minimumOrderPrice continue to treat it as a numeric
(decimal) value.
---
Nitpick comments:
In `@ballerina-integrator/new-shopify-order-to-slack/.choreo/config-schema.json`:
- Around line 11-30: Add meaningful non-empty "description" strings for each
config property so Choreo UI shows helpful hints: update "shopifyApiSecretKey"
to describe the Shopify secret/API key, "slackToken" to describe the Slack
bot/user OAuth token, "slackChannelId" to explain the destination Slack channel
ID, "customMessage" to note this is the optional message template sent to Slack,
and "minimumOrderPrice" to explain it filters orders by minimum price (integer,
currency implied). Keep descriptions concise (1–2 short sentences) and
user-facing.
In `@ballerina-integrator/new-shopify-order-to-slack/functions.bal`:
- Line 101: Update the template normalization that currently only replaces
lowercase "<br>" by changing the replaceAll call on slackMessage to match all
common variants (case-insensitive) such as "<br>", "<br/>" and "<br />"; use a
single regex like a case-insensitive pattern matching "<br" followed by optional
whitespace and optional "/" then ">" (apply it in the existing replaceAll on
slackMessage) so all variants convert to "\n".
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 63d2adc8-243d-4821-8bdb-edd7f7df296c
📒 Files selected for processing (5)
ballerina-integrator/new-shopify-order-to-slack/.choreo/config-schema.jsonballerina-integrator/new-shopify-order-to-slack/README.mdballerina-integrator/new-shopify-order-to-slack/config.balballerina-integrator/new-shopify-order-to-slack/functions.balballerina-integrator/new-shopify-order-to-slack/main.bal
🚧 Files skipped from review as they are similar to previous changes (3)
- ballerina-integrator/new-shopify-order-to-slack/config.bal
- ballerina-integrator/new-shopify-order-to-slack/README.md
- ballerina-integrator/new-shopify-order-to-slack/main.bal
|
Prebuilt Integration Checklist
|
Co-authored-by: Haritha Hasathcharu <42366642+hasathcharu@users.noreply.github.com>
Co-authored-by: Haritha Hasathcharu <42366642+hasathcharu@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds a new prebuilt “Integration as API” sample under ballerina-integrator/ that listens to Shopify orders/create webhooks and posts a formatted notification to Slack, with configurable message templating and minimum-order-price filtering.
Changes:
- Introduces a Shopify
OrdersServicewebhook listener that filters byminimumOrderPriceand posts to Slack. - Adds order-detail extraction + placeholder-based message templating (including
<br>→ newline handling). - Adds Devant/Choreo artifacts and end-user documentation for setup and deployment.
Reviewed changes
Copilot reviewed 12 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| ballerina-integrator/new-shopify-order-to-slack/main.bal | Shopify webhook handler; minimum price filter; Slack post with dedup field. |
| ballerina-integrator/new-shopify-order-to-slack/functions.bal | Extracts order fields; builds item list/address; template placeholder replacement + escaping. |
| ballerina-integrator/new-shopify-order-to-slack/types.bal | Defines OrderDetails record used across the integration. |
| ballerina-integrator/new-shopify-order-to-slack/config.bal | Configurables for Shopify secret, Slack token/channel, template, and minimum price. |
| ballerina-integrator/new-shopify-order-to-slack/connections.bal | Initializes Slack client and Shopify listener. |
| ballerina-integrator/new-shopify-order-to-slack/README.md | Setup/config/deploy documentation for Shopify + Slack + Devant. |
| ballerina-integrator/new-shopify-order-to-slack/Ballerina.toml | Package metadata for the new integration sample. |
| ballerina-integrator/new-shopify-order-to-slack/.gitignore | Ignores Ballerina build artifacts and local config. |
| ballerina-integrator/new-shopify-order-to-slack/.choreo/instructions.md | Choreo UI instructions for setup/configuration. |
| ballerina-integrator/new-shopify-order-to-slack/.choreo/diagram.md | Workflow diagram for the integration. |
| ballerina-integrator/new-shopify-order-to-slack/.choreo/config-schema.json | Config schema surfaced in Choreo/Devant. |
| ballerina-integrator/new-shopify-order-to-slack/.choreo/component.yaml | Public REST endpoint definition for the webhook listener. |
| ballerina-integrator/new-shopify-order-to-slack/data_mappings.bal | Empty placeholder file (no mappings defined). |
| ballerina-integrator/new-shopify-order-to-slack/automation.bal | Empty placeholder file. |
| ballerina-integrator/new-shopify-order-to-slack/agents.bal | Empty placeholder file. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Shall we fix these |
…ctions.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ctions.md Co-authored-by: Haritha Hasathcharu <42366642+hasathcharu@users.noreply.github.com>
…ctions.md Co-authored-by: Haritha Hasathcharu <42366642+hasathcharu@users.noreply.github.com>
pcnfernando
left a comment
There was a problem hiding this comment.
@sdmdg Please send a seperate PR with the suggestions addressed
Purpose
Resolves: https://github.com/wso2-enterprise/integration-engineering/issues/110
This PR introduces a new prebuilt integration for the WSO2 Integration Platform that automates sending Slack notifications whenever a new order is created in Shopify.
Goals
Provide a ready-to-use "Integration as API" template that allows users to seamlessly connect Shopify and Slack. It includes customizable features such as a dynamic message template (with placeholders for order data) and a minimum order price threshold to filter out low-value alerts.
Approach
Integration as APIproject using thetrigger.shopifyandslack(v5.0.0) connectors.orders/createtopic.customMessage(handling<br>for line breaks and replacing{tags}with live event data).minimumOrderPriceconfigurable before triggering the Slack API payload.Release note
Added a new prebuilt integration: Send a custom Slack notification when a Shopify order is created.
Documentation
All necessary documentation is self-contained within the
README.mdand.choreo/instructions.mdfiles included in this PR.Automation tests
Security checks
Samples
This PR itself introduces a new sample into the
ballerina-integratordirectory for the prebuilt integrations catalog.Test environment
Summary by CodeRabbit
New Features
Documentation
Chores