<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Kanesalingam Kanistan on Medium]]></title>
        <description><![CDATA[Stories by Kanesalingam Kanistan on Medium]]></description>
        <link>https://medium.com/@kkanistan874?source=rss-3664b7061e95------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*pzFZLMBoq-VV1zUw</url>
            <title>Stories by Kanesalingam Kanistan on Medium</title>
            <link>https://medium.com/@kkanistan874?source=rss-3664b7061e95------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 12:54:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kkanistan874/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Never Miss a Win Again: Salesforce to Slack notification pipeline — Built with WSO2 Integrator]]></title>
            <link>https://medium.com/@kkanistan874/never-miss-a-win-again-real-time-slack-notifications-when-salesforce-opportunities-closed-won-2dc06c46ee3f?source=rss-3664b7061e95------2</link>
            <guid isPermaLink="false">https://medium.com/p/2dc06c46ee3f</guid>
            <category><![CDATA[salesforce]]></category>
            <category><![CDATA[wso2-integration]]></category>
            <category><![CDATA[slack]]></category>
            <category><![CDATA[ballerina]]></category>
            <category><![CDATA[integration-events]]></category>
            <dc:creator><![CDATA[Kanesalingam Kanistan]]></dc:creator>
            <pubDate>Sun, 29 Mar 2026 06:01:59 GMT</pubDate>
            <atom:updated>2026-04-02T02:40:17.907Z</atom:updated>
            <content:encoded><![CDATA[<p>This article was written using <strong>Ballerina Swan Lake Update 13.2 (ballerina2201.13.2)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BbpFEDhsKRJKt2QlAGSkQA.png" /></figure><h3>The Story Every Sales Team Knows</h3><p>Picture this: it’s 4:47 PM on a Friday. Your sales rep has been chasing a $120,000 deal for six months — back-and-forth emails, four demo calls, two re-negotiations. And then finally, the customer signs. They log into Salesforce, change the stage to Closed Won, and close their laptop with a quiet sense of victory.</p><p>Meanwhile, their manager is in a meeting. The VP of Sales is on a flight. Marketing, supposed to draft a case study the moment this deal landed, has no idea it happened. Engineering won’t hear until Monday’s standup.</p><p>By the time everyone catches up — it’s Tuesday.</p><p>This is the <strong>notification gap</strong> — the lag between a deal closing and the right people knowing about it. It costs teams momentum, delays onboarding, and robs everyone of the chance to celebrate together.</p><p>This article closes that gap permanently. We’ll build a real-time, event-driven integration using <strong>Ballerina</strong> that listens to Salesforce Opportunity change events and fires a richly formatted Slack message the moment a deal hits Closed Won — with smart channel routing by deal size, owner @mentions, and configurable filters. No polling. No cron jobs. No manual copy-pasting. Just instant, automatic notifications.</p><h3>What We’re Building</h3><p>Here’s the full picture of what this integration does automatically, the instant a Salesforce rep marks an opportunity as Closed Won:</p><ul><li><strong>Listens</strong> to OpportunityChangeEvent in real-time using Ballerina&#39;s native Salesforce listener</li><li><strong>Validates</strong> — is this actually a “Closed Won” stage change? Does the deal meet our minimum amount threshold?</li><li><strong>Fetches</strong> complete opportunity details via SOQL — name, amount, owner, account, close date, lead source, competitor info, description</li><li><strong>Filters</strong> by allowed opportunity types and owner names, so only the notifications you care about get sent</li><li><strong>Routes</strong> to different Slack channels based on deal size tiers — a $150k deal and a $5k deal don’t need to land in the same channel</li><li><strong>Mentions</strong> the opportunity owner using their Slack @handle, so they get a personal ping</li><li><strong>Falls back</strong> gracefully from the Slack API to an incoming webhook if the primary delivery fails</li></ul><p>The output — a message that lands in Slack within 1–2 seconds of the stage change:</p><pre>Opportunity Closed Won<br>Deal: Acme Corp — Enterprise License<br>Amount: 120000<br>Close Date: 2025-03-15<br>Owner: @priya_sharma<br>Account: Acme Corporation<br>Type: New Customer<br>Lead Source: Webinar<br>Competitor: CompetitorX<br>Description: Full platform rollout across 4 departments</pre><p>Every field. Every relevant detail. Every time.</p><h3>Why Ballerina?</h3><p>Before we write a single line, let’s talk about why Ballerina is the right tool for this — not just because it works, but because it makes the <em>entire experience</em> of building integrations fundamentally better.</p><p>Think of integration work as wiring two rooms together. You could hack a cable through the wall yourself — deal with voltage mismatches, write custom adapters, handle auth refresh logic manually, and hope nothing breaks at 2 AM. Or you could use wiring that was <em>designed</em> for exactly this job.</p><p>Ballerina is that wiring:</p><ul><li><strong>Native connectors</strong> for Salesforce, Slack, and 200+ other services — no third-party SDKs to maintain</li><li><strong>First-class event listeners</strong> that subscribe to platform events and invoke handlers as they arrive</li><li><strong>Type-safe records</strong> that catch shape mismatches at compile time, not at 3 AM production failures</li><li><strong>Built-in OAuth2</strong> token refresh — you configure credentials once, Ballerina handles the rest</li><li><strong>Visual BI Editor</strong> in WSO2 Integration Platform that turns your Ballerina code into a live, clickable flow diagram</li><li><strong>Configurable variables</strong> with Config.toml and environment variable support, so secrets never live in code</li></ul><p>If you’ve built integrations in Node.js or Python and spent hours wrestling with HTTP clients, JSON parsing, and token refresh logic — <strong>Ballerina</strong> removes all of that friction and lets you focus on <em>the business problem</em>.</p><h3>Architecture: How the Pieces Fit</h3><p>The integration follows a clean, linear event-driven pipeline:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p2hIqOL68hviwmkPoRrrtw.png" /><figcaption>The integration’s event-driven architecture</figcaption></figure><p>No database. No queue. No intermediate service. A clean pipeline that processes each event as it arrives, discards what doesn’t match, and acts on what does.</p><h3>Setting Up Salesforce</h3><p>Before Ballerina can listen to your Salesforce events, there are three things to configure on the Salesforce side. Think of it as handing Ballerina a backstage pass with exactly the right access level.</p><h3>Step 1 — Enable Change Data Capture for Opportunities</h3><p>In Salesforce Setup, search for <em>Change Data Capture</em> and add Opportunity to the selected entities. This is the switch that tells Salesforce to start emitting real-time change events every time an Opportunity record is created, updated, or deleted.</p><p>Without this step, the Ballerina listener will connect successfully but never receive any events — a common source of confusion for first-time implementers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*14TDdEMwLdFC2Y7JRgdIKw.png" /><figcaption>Salesforce Change Data Capture enabled for the Opportunity object</figcaption></figure><h3>Step 2 — Create a Connected App with OAuth2</h3><p>Your Ballerina integration authenticates with Salesforce using OAuth2 refresh token flow. This means:</p><ol><li>Go to <strong>Setup → App Manager → New Connected App</strong></li><li>Enable <strong>OAuth Settings</strong> and set a callback URL (can be https://login.salesforce.com/services/oauth2/success for testing)</li><li>Add OAuth scopes: api, refresh_token, offline_access</li><li>After saving, copy the <strong>Consumer Key</strong> (your clientId) and <strong>Consumer Secret</strong> (your clientSecret)</li><li>Use the OAuth2 Authorization Code flow to obtain your initial <strong>refresh token</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p4miGZ9xsSb2V9hm0Ywoiw.png" /><figcaption>The Connected App OAuth2 configuration</figcaption></figure><p>For a complete walkthrough, see: <a href="https://medium.com/ballerina-techblog/seamless-salesforce-integration-with-ballerina-3d7a4a76d466">Seamless Salesforce Integration with Ballerina</a></p><h3>The Salesforce Configuration Block</h3><p>This is how Salesforce credentials are declared in config.bal. The = ? notation is Ballerina&#39;s way of saying: &quot;this value is required and must be supplied externally — don&#39;t bake it into the code.&quot;</p><pre>configurable record {<br>    string refreshToken;<br>    string clientId;<br>    string clientSecret;<br>    string refreshUrl;<br>    string baseUrl;<br>} salesforceConfig = ?;</pre><p>In production, you’ll supply these via a Config.toml file or environment variables. Nothing sensitive ever touches source control.</p><h3>Setting Up the Salesforce Listener</h3><p>This is where the real-time magic begins. In main.bal, we create a Salesforce listener using those credentials:</p><pre>import ballerina/log;<br>import ballerinax/salesforce;<br><br>listener salesforce:Listener salesforceListener = new (listenerConfig = {<br>    auth: {<br>        refreshUrl: salesforceConfig.refreshUrl,<br>        refreshToken: salesforceConfig.refreshToken,<br>        clientId: salesforceConfig.clientId,<br>        clientSecret: salesforceConfig.clientSecret<br>    },<br>    baseUrl: salesforceConfig.baseUrl<br>});</pre><p>Then we attach a service to that listener. The service path /data/OpportunityChangeEvent is the Salesforce streaming channel we&#39;re subscribing to. Ballerina&#39;s native Salesforce connector handles everything internally. You never see any of that.</p><pre>service &quot;/data/OpportunityChangeEvent&quot; on salesforceListener {<br><br>    // Handle updates to existing opportunities<br>    remote function onUpdate(salesforce:EventData payload) returns error|() {<br>        do {<br>            // Check if StageName was changed in this update<br>            string changedStageName = extractStageName(payload);<br><br>            // Only proceed if StageName was changed to Closed Won<br>            if changedStageName != STAGE_CLOSED_WON {<br>                return;<br>            }<br><br>            string opportunityId = extractOpportunityId(payload);<br><br>            // Guard: skip if recordId metadata missing<br>            if opportunityId == &quot;&quot; {<br>                log:printInfo(&quot;Event missing recordId; skipping processing&quot;);<br>                return;<br>            }<br><br>            OpportunityDetails opportunityDetails = check queryOpportunity(opportunityId);<br><br>            if opportunityDetails.amount &lt; minDealAmount {<br>                return;<br>            }<br><br>            // Apply configured filters<br>            if !passesFilters(opportunityDetails) {<br>                return;<br>            }<br><br>            string slackMessage = buildSlackMessage(opportunityDetails);<br>            string targetChannel = getChannelForDealSize(opportunityDetails.amount);<br><br>            error? sendResult = sendSlackMessage(messageText = slackMessage, channelName = targetChannel);<br><br>            if sendResult is error {<br>                log:printError(&quot;Failed to send notification&quot;, opportunityId = opportunityId, &#39;error = sendResult);<br>                return sendResult;<br>            }<br><br>            log:printInfo(&quot;Notification sent successfully&quot;, opportunityId = opportunityId);<br><br>        } on fail error err {<br>            log:printError(&quot;Failed to process opportunity update&quot;, &#39;error = err);<br>            return err;<br>        }<br>    }<br>}</pre><p>Notice how readable this is. Each step does one thing and reads almost like English. The do...on fail block wraps the entire processing pipeline so that any unexpected error is caught, logged with context, and returned — rather than silently dropped or crashing the listener.</p><h3>Setting Up Slack</h3><p>On the Slack side, you need a <strong>Slack App</strong> with bot capabilities. Here’s the setup:</p><h3>Step 1 — Create a Slack App</h3><ol><li>Go to <a href="https://api.slack.com/apps">api.slack.com/apps</a> and click <strong>Create New App → From Scratch</strong></li><li>Give it a name (e.g., “Salesforce Win Notifier”) and select your workspace</li><li>Under <strong>OAuth &amp; Permissions</strong>, add these bot token scopes:</li></ol><ul><li>chat:write — post messages to channels the bot is a member of</li><li>chat:write.public — post to channels without needing to join them first</li><li>incoming-webhook — Post messages to specific channels in Slack</li></ul><p>4. Click <strong>Install to Workspace</strong> and copy the <strong>Bot User OAuth Token</strong> (starts with xoxb-)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*8wca8rQDUm3LP-mSxy0Gdg.png" /><figcaption>Slack App OAuth configuration</figcaption></figure><h3>Step 2 — Get Your Channel IDs</h3><p>Channel names like #enterprise-wins are human-readable aliases. The Slack API uses <strong>channel IDs</strong> like C04ENTERPRISE. To find a channel&#39;s ID:</p><ol><li>Open the channel in Slack</li><li>Click the channel name at the top to open Channel Details</li><li>Scroll to the bottom of the details panel — the ID is shown there (and you can copy it)</li></ol><h3>Step 3 — Get Slack User IDs for @Mentions</h3><p>For owner mentions, you need the Slack <strong>Member ID</strong>, not the username:</p><ol><li>Click on user’s profile and Click More (three dots)</li><li>Click <strong>Copy member ID</strong></li></ol><p>The ID looks like U03XYZABC. This is what you&#39;ll use in the ownerSlackMapping config.</p><h3>Step 4 — Set Up an Incoming Webhook (Fallback)</h3><ol><li>In your Slack App settings, go to <strong>Incoming Webhooks</strong> and toggle it on</li><li>Click <strong>Add New Webhook to Workspace</strong> and choose a channel</li><li>Copy the webhook URL — it looks like <a href="https://hooks.slack.com/services/T.../B.../...">https://hooks.slack.com/services/T.../B.../...</a></li></ol><p>This webhook is your safety net. If the Slack API client ever fails (expired token, rate limit, network blip), the integration automatically retries via this webhook.</p><h3>Deep Dive: Integration Logic</h3><h4>Detecting a Closed Won Event</h4><p>We first validate the Change Data stage name to ensure that only “Closed Won” opportunities are sent to Slack</p><pre>// Reads the StageName from the Salesforce change event payload<br>function extractStageName(salesforce:EventData payload) returns string {<br>    json stageValue = payload.changedData[&quot;StageName&quot;];<br>    return stageValue is string ? stageValue : &quot;&quot;;<br>}<br><br>string changedStageName = extractStageName(payload);<br>if changedStageName is () || changedStageName != &quot;Closed Won&quot; {<br>    return; // Not a win or stage wasn&#39;t touched at all<br>}</pre><p>In a high-volume org where dozens of opportunities are updated every hour, this early exit is what keeps the system fast and the API call count low.</p><h4>Fetching Full Opportunity Details</h4><p>The change event gives us an ID and what changed. For the full deal picture, we query Salesforce directly:</p><pre>// Executes Salesforce query<br>function queryOpportunity(string opportunityId) returns OpportunityDetails|error {<br>    if !isValidSalesforceId(opportunityId) {<br>        return error(&quot;Invalid Salesforce opportunity Id format&quot;);<br>    }<br><br>    string soqlQuery = string `SELECT ${FIELD_ID}, ${FIELD_NAME}, ${FIELD_AMOUNT}, <br>        ${FIELD_STAGE_NAME}, ${FIELD_CLOSE_DATE}, ${FIELD_TYPE}, ${FIELD_LEAD_SOURCE}, <br>        ${FIELD_OWNER}.${FIELD_NAME}, ${FIELD_ACCOUNT}.${FIELD_NAME}, <br>        ${FIELD_MAIN_COMPETITORS}, ${FIELD_DESCRIPTION} <br>        FROM Opportunity <br>        WHERE ${FIELD_ID} = &#39;${opportunityId}&#39;`;<br><br>    stream&lt;OpportunityDetails, error?&gt; resultStream = check salesforceClient-&gt;query(soqlQuery);<br><br>    OpportunityDetails[] records = check from OpportunityDetails recordItem in resultStream<br>        select recordItem;<br><br>    if records.length() == 0 {<br>        return error(&quot;No opportunity found for Id: &quot; + opportunityId);<br>    }<br><br>    return parseOpportunityRecord(records[0]);<br>}</pre><p>The SOQL query fetches related objects — the Salesforce connector handles the cross-object join automatically.</p><pre>decimal amount = rawAmount is decimal ? rawAmount :<br>    (rawAmount is int ? &lt;decimal&gt;rawAmount : 0.0);</pre><p>Amount can come back as decimal or int depending on the Salesforce field configuration — this handles both without blowing up.</p><h4>Business Logic Filters</h4><p>This is where your team’s business rules live. Two independent filters, both configurable:</p><pre>// Checks if opportunity passes all configured filters<br>function passesFilters(OpportunityDetails details) returns boolean {<br>    // Filter by specific opportunity types<br>    if allowedTypes.length() &gt; 0 &amp;&amp; !allowedTypes.some(t =&gt; t == details.opportunityType) {<br>        return false;<br>    }<br><br>    // Filter by owner<br>    if allowedOwners.length() &gt; 0 &amp;&amp; !allowedOwners.some(o =&gt; o == details.owner) {<br>        return false;<br>    }<br><br>    return true;<br>}</pre><p>The design choice here is important: an empty array means “allow everything.” So a fresh deployment with empty allowedTypes = [] and allowedOwners = [] will notify on every closed won deal — which is usually the right starting point. You narrow the filters only when you need to.</p><p><strong>Real-world use case:</strong> A company with both a direct sales team and a channel partner team might set allowedOwners to only the direct reps, routing channel deals to a separate system. No code change — just config.</p><h4>Deal-Size Channel Routing</h4><p>This function implements tiered routing: the bigger the deal, the more specific the channel it lands in. The logic uses a “highest threshold wins” approach, so deal tiers stack correctly:</p><pre>// Determines the appropriate Slack channel based on deal size<br>function getChannelForDealSize(decimal amount) returns string {<br>    string selectedChannel = slackConfig.slackChannel;<br>    decimal highestThreshold = 0.0;<br>    regexp:RegExp separator = re `:`;<br><br>    foreach string tierConfig in dealSizeTierChannels {<br>        string[] parts = separator.split(tierConfig);<br>        if parts.length() == 2 {<br>            decimal|error threshold = decimal:fromString(parts[0].trim());<br>            if threshold is decimal &amp;&amp; amount &gt;= threshold &amp;&amp; threshold &gt; highestThreshold {<br>                highestThreshold = threshold;<br>                selectedChannel = parts[1].trim();<br>            }<br>        }<br>    }<br><br>    return selectedChannel;<br>}</pre><p>With this config:</p><pre>dealSizeTierChannels = [<br>    &quot;5000:C01ALLWINS&quot;,<br>    &quot;25000:C02MIDMARKET&quot;,<br>    &quot;100000:C03ENTERPRISE&quot;<br>]</pre><p>A $7,000 deal → #all-wins. A $40,000 deal → #mid-market. A $120,000 deal → #enterprise. A $4,999 deal → default channel.</p><h4>Building the Slack Message with @Mentions</h4><p>The message builder constructs a markdown-formatted Slack message and resolves owner names to Slack @mentions:</p><pre>// Builds formatted Slack message from opportunity details<br>function buildSlackMessage(OpportunityDetails details) returns string {<br>    string ownerDisplay = formatOwnerMention(details.owner);<br><br>    // Build optional fields<br>    string optionalFields = <br>        addOptionalField(&quot;Type&quot;, details.opportunityType) +<br>        addOptionalField(&quot;Lead Source&quot;, details.leadSource) +<br>        addOptionalField(&quot;Competitor&quot;, details.competitorInfo) +<br>        addOptionalField(&quot;Description&quot;, details.description) +<br>        addOptionalField(&quot;Won Reason&quot;, details.wonReason);<br><br>    string message = &quot;*Opportunity Closed Won*\n&quot; +<br>        &quot;*Deal:* &quot; + details.name + &quot;\n&quot; +<br>        &quot;*Amount:* &quot; + details.amount.toString() + &quot;\n&quot; +<br>        &quot;*Close Date:* &quot; + details.closeDate + &quot;\n&quot; +<br>        &quot;*Owner:* &quot; + ownerDisplay + &quot;\n&quot; +<br>        &quot;*Account:* &quot; + details.account + optionalFields;<br><br>    return message;<br>}</pre><p>addOptionalField silently skips empty fields:</p><pre>// Adds optional field to message if value exists<br>function addOptionalField(string label, string value) returns string {<br>    return value != &quot;&quot; ? string `*${label}:* ${value}` : &quot;&quot;;<br>}</pre><p>This means a deal with no competitor info won’t show a “Competitor: “ line — the message stays clean.</p><p>The @mention resolution:</p><pre>// Formats owner name with Slack mention if mapping exists<br>function formatOwnerMention(string ownerName) returns string {<br>    string slackHandle = getSlackHandleForOwner(ownerName);<br>    if slackHandle == &quot;&quot; {<br>        return ownerName;<br>    }<br>    // Mapping contains a Slack user ID (optionally prefixed with @)<br>    string userId = slackHandle.startsWith(&quot;@&quot;) ? slackHandle.substring(1) : slackHandle;<br>    return &quot;&lt;@&quot; + userId + &quot;&gt;&quot;;<br>}</pre><p>If a Salesforce owner isn’t in the mapping, their plain name appears — no broken &lt;@&gt; tags, no error. The fallback is always clean.</p><h3>Resilient Delivery: API Client with Webhook Fallback</h3><p>Production integrations fail. This one handles it with a two-tier delivery strategy:</p><pre>function sendSlackMessage(string messageText, string channelName) returns SlackSendResult|error {<br>    // Tier 1: Slack API client (supports channel routing)<br>    error? clientResult = sendViaSlackClient(messageText, channelName);<br>    if clientResult is error {<br>       log:printWarn(&quot;Slack client failed, falling back to webhook&quot;, &#39;error = clientResult);<br>       // Tier 2: Incoming webhook (fixed channel, but always works)<br>       error? webhookResult = sendViaWebhook(messageText);<br>       if webhookResult is error {<br>          return error(&quot;Both Slack client and webhook failed&quot;, webhookResult);<br>       }<br>       return {method: &quot;webhook&quot;};<br>    }<br>    return {method: &quot;client&quot;};<br>}</pre><p>Your logs tell you exactly <em>why</em> a delivery failed — not just that it did.</p><h3>Type Safety: The Records That Hold Everything Together</h3><p>Three record types define the data contracts flowing through the integration:</p><pre>// Everything we know about a deal<br>type OpportunityDetails record {<br>    string name;<br>    decimal amount;<br>    string owner;<br>    string account;<br>    string wonReason;<br>    string stageName;<br>    string closeDate;<br>    string opportunityType;<br>    string leadSource;<br>    string competitorInfo;<br>    string description;<br>};<br><br>// Payload shape for Slack webhook<br>type SlackWebhookPayload record {<br>    string text;<br>};<br><br>// Result of a send attempt - tells us which delivery path was used<br>type SlackSendResult record {<br>    string method; // &quot;client&quot; or &quot;webhook&quot;<br>};</pre><p>These records serve as compile-time contracts. When parseOpportunityRecord fills an OpportunityDetails, the Ballerina compiler verifies every field is present and correctly typed. If you rename a field or change a type, the compiler catches it immediately — not after deploying to production.</p><h3>The BI Editor View</h3><p>One of Ballerina’s standout features for integration developers is the <strong>WSO2 BI (Ballerina Integrator) Editor</strong> — a visual canvas that maps your code into a navigable, always-in-sync flow diagram.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*cl18RpZVhGey7VqHgl82Kg.png" /><figcaption>The BI Editor’s project overview</figcaption></figure><p>When you open this integration in the BI editor, you see:</p><p><strong>The listener as an event source</strong> — the Salesforce listener appears at the top of the canvas, with four downward arrows representing onCreate, onUpdate, onDelete, and onRestore. The onUpdate handler is visually distinct because it has actual logic in it.</p><p><strong>Decision nodes for each guard</strong> — the stage name check, the amount threshold check, and the filter check appear as diamond-shaped branch points. Each branch shows both the “proceed” path and the “return early” path.</p><p><strong>Client connections as outbound links</strong> — the SOQL query call to salesforceClient and the Slack send call appear as outbound arrows to their respective clients.</p><p><strong>Error paths clearly marked</strong> — the on fail block appears as a separate error path at the bottom of the onUpdate flow, distinct from the happy path.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*uNaaCkx5feGwzfNBtEWTiQ.gif" /><figcaption>BI Editor in action</figcaption></figure><p>This matters most when you’re onboarding a new team member. Instead of handing them 200 lines of Ballerina code and saying “figure it out,” you open the BI editor and walk through the flow visually in five minutes. The diagram is <em>generated from</em> the code — it never goes stale.</p><h3>Wait — There’s an Even Easier Way: WSO2 Integrator Copilot</h3><p>If you watched the GIF above closely, you may have noticed something sitting quietly on the right side of the screen — a tab labelled <strong>WSO2 Integrator Copilot</strong>. It wasn’t an accident that it was there.</p><p>That tab is the shortcut to everything we just built.</p><p>Instead of assembling the pipeline line by line, you describe what you want in plain language and the Copilot generates the integration flow on the visual canvas and writes the Ballerina code in your project files simultaneously.</p><p>You could hand this entire integration to the Copilot in a few sentences:</p><p>“Listen to Salesforce Opportunity change events. When a deal is marked Closed Won and the amount is above a configurable threshold, fetch the full opportunity details and send a formatted Slack message to a channel based on the deal size. Mention the owner by their Slack user ID.”</p><p>The scaffolding — listener, handler, guard conditions, SOQL query, message builder, delivery logic — lands on the canvas ready for you to review, refine, and push to Devant. No blank file. No syntax to memorise. The same integration, the same BI Editor diagram, just a dramatically shorter path to get there.</p><h3>Deploying on WSO2 Devant</h3><p>WSO2 Devant is the managed cloud platform for hosting Ballerina integrations. Deployment is a three-step process:</p><h4>Step 1 — Create the Integration</h4><ol><li>Sign in to your <strong>Devant</strong> account at <a href="https://console.devant.wso2.com/">console.devant.wso2.com</a></li><li>Click <strong>Create Integration</strong></li><li>Choose <strong>Import from Repository</strong> and connect your GitHub repo (<a href="https://wso2.com/devant/docs/references/import-a-repository/">Devant Import Guide</a>)</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zunP1FVWpiyYzRQ42UCEJw.png" /></figure><ul><li>Select Technology: <strong>WSO2 Integrator: BI</strong></li><li>Integration Type: <strong>Event Integration</strong></li><li>Click <strong>Create</strong> and wait for the initial build</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ePgeoNzgacekubC4iAiRCQ.png" /><figcaption>Creating the integration in Devant</figcaption></figure><h4>Step 2 — Configure Environment Variables</h4><p>After the build succeeds, Devant prompts you to configure the integration. Click <strong>Configure to Continue</strong> and set all required variables</p><h4>Step 3 — Deploy and Verify</h4><ol><li>Click <strong>Deploy</strong></li><li>Watch the deployment logs — you should see the Salesforce listener startup message</li><li>Open a Salesforce opportunity and change the stage to <strong>Closed Won</strong> (make sure it meets your minDealAmount)</li><li>Watch the Devant logs for confirmation — the notification should fire within 1–2 seconds</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jSqZAeLiVxGri1Q6i2VDlA.png" /><figcaption><em>Devant’s log view</em></figcaption></figure><h3>End-to-End Test Walkthrough</h3><p>After deploying, here’s the exact sequence to verify everything works:</p><ol><li><strong>Open Salesforce</strong> and navigate to any open opportunity</li><li><strong>Edit the Stage</strong> field — change it to “Closed Won”</li><li>Ensure the Amount field is populated and above your minDealAmount</li><li>If allowedTypes is non-empty, make sure the opportunity type matches</li><li><strong>Save</strong> the record</li></ol><p>Within 1–3 seconds, you should see the notification in your configured Slack channel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*XS0MUPZae5-j1vx8kLn8Hw.png" /><figcaption>The Slack notification as it appears in the channel</figcaption></figure><h3>Security Checklist for Production</h3><p>Before going live, run through this list:</p><ul><li><strong>Credentials in environment variables only</strong> — never commit Config.toml to source control. Use Devant&#39;s secrets management or your CI/CD secret store</li><li><strong>Rotate your Salesforce refresh token</strong> quarterly and update the Devant config variable — no downtime required</li><li><strong>Minimise Slack token scopes</strong> — chat:write and chat:write.public are all you need. Remove anything extra added during development</li><li><strong>Monitor for silent failures</strong> — alert on &quot;Both Slack client and webhook failed&quot; in Devant&#39;s logs, which include opportunityId on every line for easy tracing</li></ul><h3>Conclusion</h3><p>Let’s come back to sales rep. It’s 4:47 PM on a Friday. He (or She) marks the deal <strong>Closed Won</strong> in Salesforce.</p><p>Two seconds later:</p><pre><strong>Closed Won!</strong><br><strong>Deal:</strong> Acme Corp — Enterprise License<br><strong>Amount:</strong> 120000<br><strong>Close Date:</strong> 2025-03-15<br><strong>Owner:</strong> @Kanistan Kanesalingam<br><strong>Account:</strong> Acme Corporation<br><strong>Type:</strong> New Customer<br><strong>Lead Source:</strong> Webinar<br><strong>Competitor:</strong> CompetitorX<br><strong>Description:</strong> Success</pre><p>The manager replies from the meeting room, the VP reacts on the plane, marketing opens a case study doc, engineering starts the onboarding ticket — all within seconds. Nobody had to manually notify anyone. Nobody waited until Monday.</p><p>That’s the real value of integration done right: not just connecting systems, but building organizational reflexes. When information reaches the right people automatically, teams move faster, stay aligned, and frankly become more fun to work in.</p><p>Ballerina made this possible to build in an afternoon, readable enough to maintain next year, and flexible enough to grow with the business. The notification gap doesn’t have to exist — it can be closed permanently with a few dozen lines of well-designed code.</p><h3>Resources</h3><ul><li><a href="https://central.ballerina.io/ballerinax/salesforce/latest">Ballerina Salesforce Connector Documentation</a></li><li><a href="https://central.ballerina.io/ballerinax/slack/latest">Ballerina Slack Connector Documentation</a></li><li><a href="https://medium.com/ballerina-techblog/seamless-salesforce-integration-with-ballerina-3d7a4a76d466">Seamless Salesforce Integration with Ballerina — Deep Dive</a></li><li><a href="https://ballerina.io/learn">Ballerina Language Documentation</a></li><li><a href="https://wso2.com/devant/">WSO2 Devant Platform</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2dc06c46ee3f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>