--- title: "Custom Time Metric for Call Reporting" slug: "custom-time-metric-for-call-reporting" updated: 2025-11-12T15:14:14Z published: 2025-11-12T15:14:14Z canonical: "docs.natterbox.com/custom-time-metric-for-call-reporting" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.natterbox.com/llms.txt > Use this file to discover all available pages before exploring further. # Custom Time Metric for Call Reporting > [!NOTE] > These guides are intended for advanced Natterbox admins. The solutions involves scripts and is not an out-the-box solution. *This guide will give you the ability to report on the time taken for certain parts of the routing policy. This will involve creating 3 new custom fields and editing your Natterbox routing policies. Examples of ways to use the custom time metric:* - *How long does a caller take in the switchboard* - *How long from when a caller enters the phone system until the call is answered (excluding the time for greeting messages and switchboard presses)* #### **REQUIRED Editions, Packages & Licenses** - Skill set needed: Natterbox Admin and Salesforce Admin - Natterbox Call Centre 1.57 and Natterbox Admin (AVS) 1.49 or higher - Approx Time: 1 hour - Difficulty: 4/5 # Field Creation *You will need to create 3 fields on the call reporting object.* 1. First, to the setup cog, then object manager and search for ‘Call Reporting’ object 2. Go to the ‘Fields & Relationships’ tab and click ‘New’. 3. Here is how to create the first field: 1. Data Type = *Date/Time* 2. Field Label = *First Timestamp* 3. Description = *This is used in X routing policy* 4. Help Text = **add in where the stamp occurs** 5. Leave the rest as default and click *Next* 6. Edit field-level security as desired and click Next 7. We recommend adding to page layout then, click *Save & New*. 4. Here is how to create the second field: 1. Data Type = *Date/Time* 2. Field Label = *End Timestamp* 3. Description = *This is used in X routing policy* 4. Help Text = **add in where the stamp occurs** 5. Leave the rest as default and click *Next* 6. Edit field-level security as desired and click Next 7. We recommend adding to page layout then, click *Save & New*. 5. Here is how to create the third field: 1. Data Type = *Formula (Number)* 2. Decimal Places = *0* 3. Field Label = *Timestamp Calculation* 4. Click *Next* 5. Formula = ```lua UNIXTIMESTAMP(End_Timestamp__c) - UNIXTIMESTAMP(First_Timestamp__c) ``` # # # 6. Description = This is used in X routing policy 7. Help Text = In Seconds / Calculates from X to Y 8. Click Next 9. Edit field-level security as desired and click Next 10. We recommend adding to page layout then, click Save. # Routing Policy Changes 1. Go to the *Routing Policy* tab in the *Natterbox AVS Lighting* app. 2. Click on the policy you want to add the time metric. 3. Decide the 2 places where the timestamps will go. 4. Break the connectors by doubling clicking the grey line. 5. Add an *Action* container with a *Script Engine* app. 1. Name this item = *Start Time Script* 2. Lua Script = After ‘--continue your script here’ paste this: ```lua local dateTime = strftime('%Y-%m-%dT%H:%M:%SZ', '', '') session.set('Field_Goes_Here', tostring(dateTime)) ``` Example: ![](https://cdn.document360.io/c81c490c-daaa-4ebd-a3c3-1a2dee8b7617/Images/Documentation/custom-time-metric-for-call-reporting-image-v6ooss57.png?sv=2026-02-06&spr=https&st=2026-10-12T06%3A57%3A00Z&se=2026-10-12T07%3A57%3A00Z&sr=c&sp=r&sig=hn3tZfnm%2FwtTrnF6iVVIMJYQRuN6lLpuw1Mdc23uUi0%3D) 1. Now connect both grey lines onto the next container. 2. Do steps 4-6 again but where you want the time to stop and add the second field’s name into the script. 3. Make sure to click ***Save*** in the top right of the routing policy. 4. Make sure to test this by calling in and checking the fields populate! # Here are what the two action containers with script engine components might look like:![](https://cdn.document360.io/c81c490c-daaa-4ebd-a3c3-1a2dee8b7617/Images/Documentation/custom-time-metric-for-call-reporting-image-3eymf6wk.png?sv=2026-02-06&spr=https&st=2026-10-12T06%3A57%3A00Z&se=2026-10-12T07%3A57%3A00Z&sr=c&sp=r&sig=hn3tZfnm%2FwtTrnF6iVVIMJYQRuN6lLpuw1Mdc23uUi0%3D)![](https://cdn.document360.io/c81c490c-daaa-4ebd-a3c3-1a2dee8b7617/Images/Documentation/custom-time-metric-for-call-reporting-image-1x2yd4tm.png?sv=2026-02-06&spr=https&st=2026-10-12T06%3A57%3A00Z&se=2026-10-12T07%3A57%3A00Z&sr=c&sp=r&sig=hn3tZfnm%2FwtTrnF6iVVIMJYQRuN6lLpuw1Mdc23uUi0%3D) You could also stack them with reporting gates (a Manage Properties app) like this:![](https://cdn.document360.io/c81c490c-daaa-4ebd-a3c3-1a2dee8b7617/Images/Documentation/custom-time-metric-for-call-reporting-image-lqos0uja.png?sv=2026-02-06&spr=https&st=2026-10-12T06%3A57%3A00Z&se=2026-10-12T07%3A57%3A00Z&sr=c&sp=r&sig=hn3tZfnm%2FwtTrnF6iVVIMJYQRuN6lLpuw1Mdc23uUi0%3D) Here is what a simple routing policy might look like with the 2 new script engine apps in: ![](https://cdn.document360.io/c81c490c-daaa-4ebd-a3c3-1a2dee8b7617/Images/Documentation/custom-time-metric-for-call-reporting-image-z948xquw.png?sv=2026-02-06&spr=https&st=2026-10-12T06%3A57%3A00Z&se=2026-10-12T07%3A57%3A00Z&sr=c&sp=r&sig=hn3tZfnm%2FwtTrnF6iVVIMJYQRuN6lLpuw1Mdc23uUi0%3D) # Reporting 1. Go to the Salesforce *Reports* tabs. 2. Select Report Type = Call Reporting 3. Create a report on connected inbound calls, here is an example: 1. Filter on a time frame, e.g. **Conversation Answer Time** = *THIS WEEK, THIS MONTH*… 2. Filter on **Call Direction** = *Inbound* 3. Filter on **From Call Type** = *Connected* 4. Add the fields: **To Natterbox User, From Number, Contact, Time Ringing, Time Hunting, Time Talking, Wrapup Duration, Wrapup Label 0, Wrapup Label 1** 5. Add in the **Timestamp Calculation** field. 4. You can customise the report by using row-level formulas or more custom time metric fields. Example report: ![](https://cdn.document360.io/c81c490c-daaa-4ebd-a3c3-1a2dee8b7617/Images/Documentation/custom-time-metric-for-call-reporting-image-o97ocrup.png?sv=2026-02-06&spr=https&st=2026-10-12T06%3A57%3A00Z&se=2026-10-12T07%3A57%3A00Z&sr=c&sp=r&sig=hn3tZfnm%2FwtTrnF6iVVIMJYQRuN6lLpuw1Mdc23uUi0%3D)