Before you start
GoHighLevel works out of the box. ServiceTitan and anything else with an API can be connected, and this recipe is how: a custom function on your agent that calls an endpoint you run.
You need: a paid Leadlock plan with an API key, ServiceTitan API access for the one business you are wiring, and an endpoint you control that holds those ServiceTitan credentials. Leadlock never sees them.
How the pieces fit
-
The agent checks a date
The caller asks for a visit. The agent calls
st_check_availabilitywith the date. -
Your endpoint asks ServiceTitan
Leadlock posts the call to your endpoint. It looks up the open arrival windows and returns them.
-
The caller picks a window
The agent calls
st_book_appointmentwith the window's start time and the caller's details. -
The office confirms
Your endpoint creates the booking request in ServiceTitan. The office confirms it there.
Your endpoint is the only thing that talks to ServiceTitan. In our live setup the ServiceTitan connection is reachable only from one fixed server, so the endpoint runs on that server.
Function 1: check availability
Only the date. The description tells the agent to always check before it offers a time.
{
"name": "st_check_availability",
"description": "Check open appointment arrival windows for a date before offering times to the caller. Always call this before booking.",
"parameters": {
"type": "object",
"required": [
"date"
],
"properties": {
"date": {
"type": "string",
"description": "Date to check, format YYYY-MM-DD"
}
}
},
"webhook_url": "https://YOUR-ENDPOINT/check-availability",
"webhook_method": "POST",
"webhook_headers": {
"X-Webhook-Secret": "YOUR-OWN-SECRET"
},
"webhook_timeout_ms": 15000,
"speak_during_execution": true
} Function 2: book the appointment
Only date, time and name are required. Ask for the ZIP code: in the live
setup the address is dropped without it. Keep street and city in separate fields.
{
"name": "st_book_appointment",
"description": "Submit a booking request for a service visit. This creates a REQUEST the office confirms. Tell the caller their request is in and the office will confirm shortly. Do NOT say they are already booked. Use the START time of the arrival window the caller chose.",
"parameters": {
"type": "object",
"required": [
"date",
"time",
"name"
],
"properties": {
"date": {
"type": "string",
"description": "YYYY-MM-DD"
},
"time": {
"type": "string",
"description": "Start of the chosen arrival window, 24-hour HH:MM"
},
"name": {
"type": "string",
"description": "Caller full name"
},
"phone": {
"type": "string",
"description": "Callback phone number"
},
"email": {
"type": "string",
"description": "Email, if given"
},
"street": {
"type": "string",
"description": "Street address ONLY. Never put the city here."
},
"city": {
"type": "string",
"description": "City name ONLY"
},
"state": {
"type": "string",
"description": "Two-letter state code"
},
"zip": {
"type": "string",
"description": "5-digit ZIP code. Ask for it: the address is dropped without it."
},
"summary": {
"type": "string",
"description": "Brief description of the problem"
}
}
},
"webhook_url": "https://YOUR-ENDPOINT/book-appointment",
"webhook_method": "POST",
"webhook_headers": {
"X-Webhook-Secret": "YOUR-OWN-SECRET"
},
"webhook_timeout_ms": 15000,
"speak_during_execution": true
} webhook_timeout_ms can be 1,000 to 30,000 (the default is 5,000). The live functions use 15,000.
speak_during_execution lets the agent keep
talking while it waits.
Create, attach and test
Create each function in your library with /functions, then attach it to the agent. With an agency
key, add the X-Sub-Account-Id header for the client's sub-account.
POST /functions
body: the function JSON above, returns the function with its id
POST /agents/{agent_id}/functions/attach
body: { "function_id": "<id from the step above>" }
POST /functions/{function_id}/test
body: { "arguments": { "date": "YYYY-MM-DD" } } The test call is real. It sends a real request to your endpoint, so testing the booking function creates a real booking request in ServiceTitan. Test the availability check freely. Test booking only when the office expects it, and have them clear the test request.
What your endpoint receives and returns
Each call arrives as a POST with JSON. Leadlock also sends X-Leadlock-Function with the function name,
plus the headers you set. Check your own secret header before doing anything.
{
"function": "st_check_availability",
"arguments": {
"date": "YYYY-MM-DD"
},
"call_context": {
"call_sid": "...",
"agent_id": "...",
"tenant_id": "...",
"is_test": false
}
}
When the caller matches a GoHighLevel contact, call_context also carries
contact_id, contact_name, contact_email, contact_phone,
contact_company and contact_tags.
2xx from your endpoint -> the agent gets { "success": true, "data": <your JSON> }
any other status -> the agent gets { "success": false, "error": "Webhook returned HTTP <code>" }
no answer in time -> the agent gets { "success": false, "error": "Webhook timed out after <ms>ms" } The prompt rule
Put two rules in the agent's prompt as well as in the function descriptions. Always check availability before offering or booking a time. After booking, tell the caller their request is in and the office will confirm shortly, never that they are already booked.
Why it is wired per business
ServiceTitan's API terms limit a custom application to one ServiceTitan customer. So each business gets its own ServiceTitan API access and its own endpoint, and the functions point at that endpoint. Leadlock has no ServiceTitan Marketplace app.
Running today
Three home-service brands' voice agents run this pair of functions. Ben Franklin Plumbing's agent was wired on September 1, 2026, and its test bookings landed in ServiceTitan with status New, waiting for the office.
What this recipe does not cover: the inside of the endpoint. Which ServiceTitan API calls it makes, how it signs in, and the exact format of the arrival windows it returns are specific to each business and are not published here.