Geo Location Sample
π§ ai12z Geo Location Sample β Find a Bus Near Meβ
This guide shows how to build a chatbot experience that uses the browser's geolocation to return nearby information via a custom agent. The Endpoint is sorting the results. There is another example under Custom Carousle, a store finder where ai12z uses Python to sort locations.
β Step 1: Review the Integration Guideβ
Familiarize yourself with ai12z chatbot integration:
Chatbot Integration Docs
β Step 2: Create a Agentβ
In the ai12z portal, create a new Agent.
This sample does not require uploaded website content β itβs purely for testing the location integration.

β Step 3: Create a Custom Agent β Base Propertiesβ

| Setting | Value | Purpose |
|---|---|---|
| Name | Bus Locator | Agent name |
| Source | REST API or Graph API | API that returns bus info |
| Handle Response | LLM | LLM will process the API result |
β Step 4: Create Agent Parametersβ

The agent should support the following inputs:
latitudelongitudetype(e.g.,"bus")
β Step 5: Set Up the Agent Endpointβ
- Use a
POSTendpoint (typical) - Add any required headers (e.g., authentication)
- Ensure the endpoint accepts and responds to the following (or a similar) payload:
{
"latitude": "42.34",
"longitude": "-71.08",
"type": "bus"
}
β Step 6: Update the System Prompt (React LLM)β
Sample system prompt:
### Nearest Bus Request
Users may ask:
- "Where is my bus?"
- "When is the next bus arriving near me?"
To assist them:
- Explain you need their permission to request their locaton
- Insert a button. Clicking the button generates an event in the web page that triggers JavaScript to fetch the user's geolocation:
<button type="button" onclick="sendMessage('Bus Request use my current location')" class="ai12zBtn">
Use my current location
</button>
When this button is clicked:
1. You will receive from the Bot query: **"Request to use my current location"** Respond by saying, Collecting Geo Location information.
Do not insert Please click the button below to allow me to access your current location: or the button again
2. The Button click event in the bot causes an hook to that button click and javascript calls the navigator.geolocation.getCurrentPosition,
where the web browser generates a dialog to use my Location, (if not already granted).
3. Upon success, web page JavaScript will fetches the location and sends the data using ai12z `sendJSON`,
This will push a message `Use location data` to the Reasoning Engine, with the latitude and longitude
4. The reasoning engine when it detect `Use location data` should call the the GEO Location function, to find nearest bus.
π Ask: "Where is the Bus?"β
When the user asks βWhere is the Bus?β, the AI assistant responds by prompting the user to share their current location:
