<?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 Yunpu Sheng on Medium]]></title>
        <description><![CDATA[Stories by Yunpu Sheng on Medium]]></description>
        <link>https://medium.com/@sjoan.syp?source=rss-6b8d818c0edd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dIYihYi3JxmDl8ASSbbEnw.jpeg</url>
            <title>Stories by Yunpu Sheng on Medium</title>
            <link>https://medium.com/@sjoan.syp?source=rss-6b8d818c0edd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 21:02:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sjoan.syp/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[How Relay Reduced Phone Wait-Times by Forecasting the Right Number of Agents]]></title>
            <link>https://medium.com/relay-financial/how-relay-reduced-phone-wait-times-by-forecasting-the-right-number-of-agents-840843fbc122?source=rss-6b8d818c0edd------2</link>
            <guid isPermaLink="false">https://medium.com/p/840843fbc122</guid>
            <category><![CDATA[call-center-optimization]]></category>
            <category><![CDATA[workforce-planning]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[customer-support]]></category>
            <category><![CDATA[data-analysis]]></category>
            <dc:creator><![CDATA[Yunpu Sheng]]></dc:creator>
            <pubDate>Thu, 07 Aug 2025 14:15:38 GMT</pubDate>
            <atom:updated>2025-08-07T14:15:38.155Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>How do you know if your call centre is actually under pressure or just staffed at the wrong times?</blockquote><p>by <a href="https://medium.com/@sjoan.syp">Yunpu Sheng</a> and <a href="https://medium.com/@abisoye.abidakun_7570">Abisoye Abidakun</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w7CtGSjKosEf4vjm_hT5iA.png" /></figure><p>At Relay, the Customer Experience team plays a critical role in supporting customers when they need us most. We’ve been consistently working on reducing call wait times, and a key part of that effort is optimizing staffing based on intraday volume to ensure timely and effective support for our customers. To make smarter staffing decisions, we needed a way to make intraday demand visible.</p><p>That’s where the <strong>Occupancy Heat Map</strong> comes in. It’s a data tool we built to visualize phone line activity across the day and forecast future load based on historical trends. At the heart of it is a surprisingly simple but powerful metric: Occupancy</p><blockquote><em>Occupancy is a measure of how busy our support line is at any given moment, calculated as the ratio of incoming demand to available staffing. It tells us whether agents are able to keep up with calls or whether queues and wait times are likely to form.</em></blockquote><blockquote><em>An occupancy over 1 means demand exceeds capacity, a signal for likely delays.</em></blockquote><p>With it, we can finally start answering the right questions:</p><ul><li>What happened at 10:30 AM when wait times spiked?</li><li>Are there consistent volume patterns we can plan around?</li><li>And how many agents do we <em>actually</em> need for each half-hour block?</li></ul><h3>How It Works: Modelling Agent Load</h3><p>To understand <strong>occupancy</strong>, imagine a supermarket checkout. If customers arrive faster than the cashier can serve, a queue builds. Similarly, in a call center, if calls come in faster than agents can handle, wait times increase.</p><p>We model this using the formula:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*55wHj_pfnnpBTFcrAQCudw.png" /></figure><ul><li>λ: Call arrival rate (calls per minute)</li><li>Tₛ: Average service time</li></ul><blockquote><em>u &gt; 1 indicates overload. The system can’t handle demand.</em></blockquote><p>But real-world call centres have <strong>multiple agents</strong>, so we adjust:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bWakAktBX1KD-5_d2JKFcw.png" /></figure><ul><li>m: Number of agents</li><li>ρ: Occupancy</li></ul><p>This gives us a normalized number across time blocks to compare how loaded the system is.</p><blockquote><em>✅ Occupancy &lt; 1 → capacity available</em></blockquote><blockquote><em>❌ Occupancy &gt; 1 → risk of queueing, longer wait times</em></blockquote><h3>Integrating Occupancy into Our Data Platform</h3><p>Occupancy is core to our support operations, so we wanted full control over how it’s represented, interpreted and linked to other metrics. This is why we chose to recreate an occupancy model directly in Snowflake and our BI layer (Metabase) even though it’s available in most common CX workforce management platforms.</p><p>It also made operational sense: the CX ops team already tracks key performance metrics in Metabase, so placing the occupancy heat map alongside those dashboards improved visibility and adoption. Most importantly, building in-house allows us to tie occupancy to broader business outcomes, like identifying when increased support load corresponds with downstream drops in user activity across our banking platform.</p><h3>Historical &amp; Forecast Heat Map</h3><p>We calculate occupancy <strong>in half-hour blocks</strong>, generating an easy-to-scan heat map for both <strong>historical performance</strong> and <strong>forecasted load</strong>.</p><h3>Historical View</h3><p>The historical view of the heat map is based on phone volume, agent efficiency and agent availability in the past at each 30 minute interval. This helps answer key operational questions such as:</p><ul><li>What happened at a specific time?</li><li>Were enough agents staffed?</li><li>Did calls spike unexpectedly?</li></ul><p>In Metabase, each time block is linked to granular metrics through a drill-down feature, enabling the team to investigate anomalies by examining details like inbound call volume, completion/drop-off rates and the number of agents available at the time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*UoyBhA7C9rL788nG_mO-PA.png" /><figcaption><em>Real-time updating phone line occupancy heat map</em></figcaption></figure><h3>Forecast View</h3><p>To forecast the future occupancy, we use a <strong>rolling 3-week average</strong> of call volume and average handle time. This allow us to project <strong>next week’s occupancy</strong> by combining historical data for the same weekday and time block with the scheduled headcount for upcoming days.</p><blockquote>When the project was first conceived, we explored more sophisticated forecasting approaches including LSTMs and specialized time series models. But after backtesting, we found that a rolling average performed comparably for our use case, with far less operational overhead.</blockquote><blockquote><strong>In the end, simplicity won.</strong> The 3-week average struck the right balance between performance, explainability, and maintainability.</blockquote><p>With these projections, the scheduling team can proactively identify time periods where additional staffing may be needed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*h9xLfz1BelNf1JhqltNDng.png" /><figcaption><em>Occupancy forecast heat map for next business week</em></figcaption></figure><h3>SLA Modelling with Erlang C</h3><p>Forecasted occupancy tells us <strong>how busy we expect the team to be</strong> in each 30-minute time block based on projected call volume, handle time, and scheduled agents.</p><p>But it does not tell us the customer’s experience. That’s where <strong>Erlang C</strong> comes in. It lets us estimate:</p><ul><li>The <strong>probability a caller will have to wait</strong></li><li>The <strong>expected average wait time</strong></li><li>Whether we’re on track to meet our <strong>SLA target</strong> (e.g. 80% of calls answered in under 3 minutes)</li></ul><p>We use Erlang C to simulate these outcomes, and then reverse it to <strong>solve for the minimum number of agents needed</strong> to consistently meet our SLA. If forecasted staffing falls short, we can flag that time block for proactive schedule adjustments.</p><p>Probability that a call has to wait → Ec​</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vFMgK8RAxKCl8KtcFZRjKw.png" /></figure><p>Estimated average waiting time derived</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d5ZKLjCD6EvoCWnejmsIZw.png" /></figure><p>Solve for required agent (m*) to meet service goal (e.g. 80% of calls answered in 3 mins)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AkUBgu2pCmgy7xy6gn7mSw.png" /></figure><p>Since SQL isn’t suitable for the iterative logic required by Erlang calculations, we implemented the formula in Python as <strong>user-defined functions (UDFs)</strong> within Snowflake. This allows us to use it natively in our dbt models — for example, to calculate the probability that a caller will have to wait given a forecasted occupancy and agent count.</p><pre>{% macro create_udf_erlang_c() %}<br><br>create or replace function erlangC_probability(agent_count float, intensity float)<br>returns float<br>language python<br>packages = (&#39;mpmath&#39;)<br>runtime_version = &#39;3.10&#39;<br>handler = &#39;calculate_erlangC_probability&#39;<br>as<br>$$<br>from math import factorial<br><br>def calculate_erlangC_probability(agent_count: float, intensity: float) -&gt; float:<br>    &quot;&quot;&quot;Computes the Erlang C probability.<br><br>    Args:<br>        agent_count (int): Number of agents. Must be a positive integer.<br>        intensity (float): Total offered load (traffic intensity) without considering agent count.<br><br>    Returns:<br>        float: The probability that an arriving customer must wait before being served.<br><br>    Raises:<br>        ValueError: If `agent_count` is not a positive integer.<br><br>    Formula Reference:<br>        The Erlang C formula is given by:<br><br>        .. math::<br>            Erlang C = \\frac{\\frac{intensity^m}{m!}}{\\frac{intensity^m}{m!} + (1 - \\rho) \\sum_{k=0}^{m-1} \\frac{intensity^k}{k!}}<br><br>        Where:<br>            - \( agent_count = \text{agent_count} \)<br>            - \( \\rho = \frac{\text{intensity}}{agent_count} \)<br>    &quot;&quot;&quot;<br><br>    agent_count = int(agent_count)<br>    if agent_count &lt;= 0:<br>        return 0.0<br><br>    rho = intensity / agent_count<br><br>    numerator = (intensity ** agent_count) / factorial(agent_count)<br><br>    partial_sum = sum((intensity ** i) / factorial(i) for i in range(agent_count))<br><br>    denominator = numerator + (1 - rho) * partial_sum<br><br>    if denominator &lt;= 0:<br>        return 0<br><br>    return float(numerator / denominator)<br><br><br>$$;<br><br>{% endmacro %}</pre><blockquote>Note: In the Erlang C formula, the term intensity refers to the total offered load, the product of call volume and handle time (λ × Tₛ), before accounting for available agents.</blockquote><blockquote>We use this as an input to the UDF, and combine it with agent count to derive <strong>occupancy</strong>, which drives queueing probability and expected wait time.</blockquote><p>This function powers our SLA modelling downstream, enabling us to simulate customer wait time outcomes, and reverse-solve for the required agent count to meet our service level targets.</p><h3>From Insight to Action: Agent Surplus &amp; Deficit View</h3><p>Once we determine how many agents we <em>should</em> have, we compare that against how many are actual scheduled to generate a <strong>surplus/deficit heat map</strong>.</p><p>This enables the team to quickly identify over- or under-staffed time blocks and make schedule adjustments as needed. The projected changes are then reflected in the next forecast refresh.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*hqEMzMKp1RJ-wOE-iE83kw.png" /></figure><h3>Under the Hood: The Data Infrastructure that Makes It Work</h3><p>Data team involvement for this project was broken down into two key phases</p><ol><li><strong>Data Engineering:</strong> Data pipelines which follows an <strong>ELT (Extract–Load–Transform)</strong> architecture to ingest and prepare data from source into the data warehouse</li><li><strong>Analytics Engineering:</strong> Business process and data modelling with dbt</li></ol><h3>Data Sources</h3><p>This system combines two primary data sources:</p><ul><li><a href="https://www.zendesk.com/"><strong>Zendesk</strong></a>: Our source of truth for inbound support activity (calls, wait times, handle durations)</li><li><a href="https://www.assembled.com/"><strong>Assembled</strong></a>: Our workforce management system, providing staffing schedules and agent activities</li></ul><p>For our ELT process into Snowflake, <strong>Fivetran</strong> provides connectors for both tools, and we used the connectors wherever possible. However, Assembled’s schedules are forward-looking and dynamic: team managers can add or modify shifts days in advance, and these updates directly affect our occupancy forecast. The Fivetran connector is designed to extract data snapshots from the <em>past or present</em>, but we needed visibility into the <em>future,</em> and to precisely detect when an already-ingested schedule was changed to rebuild downstream dbt models.</p><p>We prototyped with manual .CSV exports and imports to validate the approach with our CX Ops Stakeholders, but that approach was too slow and often stale. To solve this properly, we built a custom Python pipeline that polls the Assembled API multiple times per day, capturing the latest schedule changes to feed into our model.</p><p>Like every Data Engineering project ever conceived, we underestimated the complexity of integrating these multiple systems, but this hybrid approach — Fivetran based ELT where possible and custom code where necessary — was the optimal solution with minimal engineering overhead.</p><h3>1. Data Engineering: End-to-End Flow</h3><p>The source of the custom data is the <a href="https://docs.assembled.com/#get-v0-activities">Activities</a> endpoint provided by Assembled, which is queried using the Python requests library with credentials and a timestamp range (start_time and end_time). The endpoint returns a list of scheduled or generated activities within the specified time window in the form of raw JSON strings. These activity records include key metadata fields such as: id, id_with_timestamps, start_time, end_time, created_at, updated_at, agent_id, type_id.</p><h3>Extract</h3><ul><li>Calls the Assembled API for a specific partition date using an API key and timestamp range.</li><li>Retrieves scheduled and active activities for that date as a JSON response.</li></ul><h3>Load to S3</h3><ul><li>The raw JSON is stored in: s3://&lt;bucket&gt;/assembled/activities/raw/&lt;partition_date&gt;/&lt;partition_date&gt;.json</li><li>The data is converted to Parquet using DuckDB for efficient processing and stored in: s3://&lt;bucket&gt;/assembled/activities/converted/&lt;partition_date&gt;/&lt;partition_date&gt;.parquet</li><li>This dual-format storage allows for both Audit (raw JSON) and Performance-optimized ingestion (Parquet)</li></ul><h3>Load to Snowflake</h3><ul><li>A Snowflake table (ACTIVITIES) is created (if not already present).</li><li>Before loading new data: Any existing rows for the given partition_date are deleted to ensure the table always reflects the most recent state. This is necessary because activities can be modified up to the scheduled execution time, deleting and reloading ensures the latest version is captured until the activity is no longer pending/scheduled.</li><li>A COPY INTO operation loads the Parquet data into Snowflake from an external stage, preserving structure and metadata.</li></ul><h3>Logging, Validation &amp; Metadata</h3><p>Row counts from JSON → Parquet → Snowflake are compared to ensure integrity.</p><p>Rich logging tracks:</p><ul><li>Number of records processed</li><li>S3 file paths</li><li>Snowflake FQN</li><li>Timestamps for data load</li></ul><p>Failures trigger rollback and raise errors for investigation.</p><h3>Pipeline Orchestration &amp; Scheduling</h3><p>The data pipeline is orchestrated using Dagster which manages scheduling, asset lineage, partitioning, and metadata logging throughout the workflow and is structured as daily-partitioned assets. It is scheduled to run four times per day, allowing it to capture both current and future-dated activities data from the Assembled API endpoint.</p><p>On each run:</p><ul><li>The pipeline retrieves data for the current and next 7 days.</li><li>This repeated polling ensures that any changes to scheduled activities (e.g., reschedules, updates) are captured — whether those changes occurred within the last hour or since the previous run.</li></ul><p>If updates are detected:</p><p>The new or modified records are retrieved from the API and used to overwrite previously loaded data.</p><p>This overwrite occurs across all storage layers, ensuring consistency from:</p><ul><li>Raw JSON and Parquet files in AWS S3</li><li>To the corresponding tables in Snowflake, across raw, staging, and reporting layers.</li></ul><p>This design ensures that the data pipeline always reflects the most accurate and up-to-date view of scheduled activities.</p><h3>2. Analytics Engineering: Raw Data to Insights</h3><p>Following the extract and load process we use a layered dbt modeling approach — raw → staging → reporting — to keep logic modular and maintainable. This standard “layer cake” architecture lets us isolate business logic, reuse metrics, and keep pipeline complexity in check as the system evolves.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ogbS-CTaze3Qa6Rc-_fv5Q.png" /></figure><p>This project features:</p><ul><li><strong>Raw Layer</strong>: Source tables loaded from Parquet files into Snowflake, as well as Fivetran</li><li><strong>Staging Layer:</strong> Cleans, deduplicates, and models the data for downstream reuse. Here, Parquet/Snowflake data from the loading process is standardized</li><li><strong>Intermediate Layer</strong>: Implements join logic, window functions, moving averages, and other reusable transformations.</li><li>Reporting Layer: Transforms the staged models into business-facing metrics for dashboards and operational reporting. This stage leverages the Agent load model and the Python UDF dbt macros described in previous sections</li></ul><p>The output of the reporting layer feed into the forecasting heat maps and other BI reports used by the CX team to support real-time and forward-looking staffing decisions.</p><h3>Infrastructure Recap</h3><ul><li>Input Data: Zendesk call logs (volume, service time), Assembled staffing schedules</li><li>Metrics: Agent occupancy, SLA</li><li>Logic: Rolling averages, shrinkage, service goal UDFs in Python</li><li>Visualization: Metabase dashboards: Intensity heat map, Surplus/Deficit heat map</li><li>Feedback: CX team adjusts schedules → re-run forecasts next day via automated hourly data sync</li></ul><h3>👏 Final Thoughts</h3><p>Since rolling out the tool:</p><ul><li>Call wait times have meaningfully improved, and this system has been instrumental in helping us hit our SLA targets on most days.</li><li>Staffing has become more <strong>proactive than reactive</strong></li><li>Planning sessions now revolve around <strong>data, not guesswork</strong></li><li>The system supports a 40+ person CX team and has enabled us to expand with an offshore BPO partner, helping us maintain round-the-clock coverage with greater consistency.</li></ul><blockquote>“While we can’t control when customers call, we’ve reduced the unpredictability of how we respond.”</blockquote><p>This project is a great example of what happens when <strong>data and operations work together in lockstep,</strong> combining statistical modelling, a modern data stack, and close team collaboration to solve a real, messy business problem.</p><p>Special thanks to the data engineers who built the pipelines that unlocked forward-looking scheduling and to the CX leaders who leaned in to shape the product and own the outcome.</p><p>If CX operations is critical to the success of your business, and you find yourself wrestling with unpredictable call peaks, we hope this post gives you a few ideas to think outside the box of what off-the-shelf tools provide. And if you’re building data systems that support real-time operations, we’d love to hear how you’re tackling similar challenges.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=840843fbc122" width="1" height="1" alt=""><hr><p><a href="https://medium.com/relay-financial/how-relay-reduced-phone-wait-times-by-forecasting-the-right-number-of-agents-840843fbc122">How Relay Reduced Phone Wait-Times by Forecasting the Right Number of Agents</a> was originally published in <a href="https://medium.com/relay-financial">Relay Financial</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>