This guide is intended for advanced Salesforce admins. For Salesforce education, contact Salesforce directly or use trailheads for specific knowledge.
Disclaimer:
Web-to-Lead and Flow Builder are native Salesforce functionalities. While this guide provides a baseline template for integrating these features with Natterbox, the setup, customization, and ongoing maintenance of the HTML form and Salesforce architecture remain the responsibility of your organization, not Natterbox.
Overview: This guide outlines a baseline/example configuration for automatically triggering a Natterbox phone call to an available agent whenever a prospect submits a web form. By combining a standard Salesforce HTML Web-to-Lead form, a Salesforce Custom Formula Field to respect business hours, a Salesforce Record-Triggered Flow, and a Natterbox Routing Policy, organizations can ensure web leads receive immediate phone follow-ups without dialing outside of operational hours.
Phase 1: Build the HTML Web-to-Lead Form
The first step is to generate the HTML for your web form so prospects can submit their details. (The form below is purely a baseline/example for the purposes of this guide) As this is a native Salesforce feature any customization/maintenance to the HTML form remain the responsibility of your organization, not Natterbox.
Generate your Web-to-Lead HTML within Salesforce (Setup > Web-to-Lead).
For the purpose of this guide and testing, we set the Return URL (
retURL) to a generic page (e.g.,http://google.com) and disable reCAPTCHA. (Note: In a live environment, the Return URL will often be your website homepage and you will most likely want to enable reCAPTCHA.)Ensure the form includes basic contact fields, with the Phone field being mandatory for the Natterbox call to function.
Include a hidden input field to force the
lead_sourceto capture as "Web" within the HTML Form.
Example HTML Structure that captures (First name, Last Name, Phone, And Email + Our hidden field for Lead Source = Web)
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=UTF-8">
<title>Salesforce Web-to-Lead Form</title>
</head>
<body>
<h2>Contact Us</h2>
<form action="https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8&orgId=YOUR_ORG_ID" method="POST">
<input type="hidden" name="lead_source" value="Web">
<input type="hidden" name="oid" value="YOUR_ORG_ID">
<input type="hidden" name="retURL" value="http://google.com">
<label for="first_name">First Name</label>
<input id="first_name" maxlength="40" name="first_name" size="20" type="text" /><br><br>
<label for="last_name">Last Name</label>
<input id="last_name" maxlength="80" name="last_name" size="20" type="text" /><br><br>
<label for="phone">Phone</label>
<input id="phone" maxlength="40" name="phone" size="20" type="text" /><br><br>
<label for="email">Email</label>
<input id="email" maxlength="80" name="email" size="20" type="text" /><br><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>Phase 2: Create the Business Hours Custom Field
To prevent the system from dialing leads in the middle of the night or outside of business hours, create a custom formula field on the Lead object to calculate the next available operational window that reflects your organization's open business hours.
Navigate to Object Manager > Lead > Fields & Relationships and create a new Formula field returning a DateTime value.
Field Label:
Next_Available_Call_TimeAPI Name:
Next_Available_Call_Time__cInsert the following formula logic to ensure calls only trigger between 09:00 and 18:00. If a lead is submitted before 09:00, it schedules for 09:00 today; if submitted after 18:00, it schedules for 09:00 the following day.
Note: You may need to change this formula to reflect your business’s opening hours. This example uses 9:00 AM - 6:00 PM, Monday-Sunday as a baseline.
How this formula works:
Before Business Hours (Midnight to 08:59): If a lead comes in at 3:00 AM, the formula shifts the time forward to exactly 09:00 that same morning.
After Business Hours (18:00 to 23:59): If a lead comes in at 8:00 PM, the formula shifts the time forward to 09:00 the next morning.
During Business Hours (09:00 to 17:59): If a lead comes in at 2:30 PM, it doesn't meet either of the "outside hours" criteria, so the formula simply returns the exact
CreatedDate(2:30 PM).
Formula:
IF(
VALUE(MID(TEXT(CreatedDate), 12, 2)) < 9,
DATETIMEVALUE( TEXT(DATEVALUE(CreatedDate)) & " 09:00:00" ),
IF(
VALUE(MID(TEXT(CreatedDate), 12, 2)) >= 18,
DATETIMEVALUE( TEXT(DATEVALUE(CreatedDate) + 1) & " 09:00:00" ),
CreatedDate
)
)Phase 3: Configure the Salesforce Flow
Next, build a Salesforce Flow to catch the new lead and trigger the Natterbox routing based on your business hours field.
Create a new Record-Triggered Flow on the Lead object.
Set the trigger to fire when A record is created.
Set the Entry Conditions to Any Condition is Met (OR) where Field:
Lead Source=Web.
.png?sv=2022-11-02&spr=https&st=2026-02-23T22%3A37%3A04Z&se=2026-02-23T22%3A53%3A04Z&sr=c&sp=r&sig=ohkmPLY9JhVPz3UgvpzvY%2BLgGjhqNvqXJSbISCeIXTM%3D)
Add a Scheduled Path to the Flow. Base the schedule on the
Next_Available_Call_Time__ccustom field you created in Phase 2 so the action waits for business hours. Configure it with the following settings:Path Label: Business Hours Call
API Name: Business_Hours_Call
Time Source:
Lead: Next_Available_Call_Time__c(This tells the Flow which specific date/time field to base its schedule on.)Offset Number: 0 (Setting this to zero ensures the Flow executes exactly at the time calculated by your formula, without adding any extra delay.)
Offset Options: Minutes After (Combined with the zero offset, this simply tells Salesforce to trigger precisely on the minute of your scheduled time.)
.png?sv=2022-11-02&spr=https&st=2026-02-23T22%3A37%3A04Z&se=2026-02-23T22%3A53%3A04Z&sr=c&sp=r&sig=ohkmPLY9JhVPz3UgvpzvY%2BLgGjhqNvqXJSbISCeIXTM%3D)
Under the scheduled path (e.g., "Business Hours Call"), add an Apex Action (Natterbox Phone Call) and set the Input Values(Called, Caller, Originator Object ID) with the following:
Label:
webleadAPI Name:
webleadCalled:
{!$Record.Phone}Caller:
webleadOriginator Object ID:
{!$Record.Id}
.png?sv=2022-11-02&spr=https&st=2026-02-23T22%3A37%3A04Z&se=2026-02-23T22%3A53%3A04Z&sr=c&sp=r&sig=ohkmPLY9JhVPz3UgvpzvY%2BLgGjhqNvqXJSbISCeIXTM%3D)
Press Save and Activate the flow. This will complete the flow build and your completed flow should look something like the following:
.png?sv=2022-11-02&spr=https&st=2026-02-23T22%3A37%3A04Z&se=2026-02-23T22%3A53%3A04Z&sr=c&sp=r&sig=ohkmPLY9JhVPz3UgvpzvY%2BLgGjhqNvqXJSbISCeIXTM%3D)
Phase 4: Set Up the Natterbox Routing Policy
Finally, configure what happens when Natterbox receives the triggered call from the Salesforce Flow.
Navigate to the Natterbox Routing Policies page and create a new policy.
Start Node (Invokable Destination): Set the entry point to match the EXACT Apex Action name from your Flow (e.g.,
weblead)..png?sv=2022-11-02&spr=https&st=2026-02-23T22%3A37%3A04Z&se=2026-02-23T22%3A53%3A04Z&sr=c&sp=r&sig=ohkmPLY9JhVPz3UgvpzvY%2BLgGjhqNvqXJSbISCeIXTM%3D)
Query Object (Optional): Add an action to query the Salesforce Lead object to pull the Lead ID and the prospect's Name.
Whisper Text (Optional): Use the queried data to configure a Whisper Text action (e.g., "New web lead for [Lead Name]") so the agent knows the context before being connected.
Lead Record Pop (Optional): Add a screen pop action using the queried Lead ID so the prospect's Salesforce record automatically opens on the agent's screen.
Data Analytics for Lead Owner Association (Optional): Include a To Policy node for a Data Analytics policy to update the Lead Owner Field with the agent that answers the phone. Please see (Phase 5) below for a detailed breakdown.
Call Queue: Route the final action to your desired Call Queue for an available agent to answer.
Overview:
.png?sv=2022-11-02&spr=https&st=2026-02-23T22%3A37%3A04Z&se=2026-02-23T22%3A53%3A04Z&sr=c&sp=r&sig=ohkmPLY9JhVPz3UgvpzvY%2BLgGjhqNvqXJSbISCeIXTM%3D)
Phase 5: Lead Owner Association (Data Analytics Policy) - (OPTIONAL)
To update the Lead Owner Field with the agent who actually answers the phone, you will need to build a secondary Data Analytics policy.
Create a new Natterbox policy. Set the Type to Data Analytics and Name this policy "Lead Owner Association"
At the beginning of the policy, add a Script Engine component with the following Lua script. This will capture the User ID of the agent who answered the call:
local userId = session.expand_macro('$(ConnectedUserId)') if userId == nil or userId == '' then return false else -- Creates Custom Macro for ConnectedUserId: $(Custom_UserQuery) session.set("UserQuery", userId) return true endNext, add a new Query Object component. This will be used to pull the Username and Name from the UserID output captured in the script above. Configure with the following settings:
Record Type: Natterbox User
Filter Results:
External Id=$(Custom_UserQuery)Selected Fields: Name, Salesforce User
.png?sv=2022-11-02&spr=https&st=2026-02-23T22%3A37%3A04Z&se=2026-02-23T22%3A53%3A04Z&sr=c&sp=r&sig=ohkmPLY9JhVPz3UgvpzvY%2BLgGjhqNvqXJSbISCeIXTM%3D)
Finally, add an Update a Record component. This will update the Lead Owner Field and assign it to the agent that answered the call.
Record Type: Lead
Record ID:
$(SForce_MyData.Id)(This is the created macro from the Query Object in step 3).Set Field Values:
Owner ID=$(SForce_MyData.nbavs__User__c)(This is the value pulled from the Natterbox User query).
.png?sv=2022-11-02&spr=https&st=2026-02-23T22%3A37%3A04Z&se=2026-02-23T22%3A53%3A04Z&sr=c&sp=r&sig=ohkmPLY9JhVPz3UgvpzvY%2BLgGjhqNvqXJSbISCeIXTM%3D)