> For the complete documentation index, see [llms.txt](https://docs.zenfinder.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.zenfinder.ai/frontend-integration.md).

# Frontend Integration

Below are example flows and code snippets you can integrate into your web or mobile product.

#### Web: Replace current URL (recommended when you want the call page to fully replace the user session)

**Flow**

1. User clicks "Start Call" button.
2. Your frontend calls `POST /v1/calls` and receives `call_url`.
3. Your frontend navigates to `call_url` (e.g., `window.location.replace(call_url)`).

```html
<button id="start-call">Start Call</button>
<script>
    async function startCall() {
        try {
            const resp = await fetch('https://api.zenfinder.ai/v1/calls', {
                method: 'POST',
                headers: {
                'Authorization': 'Bearer YOUR_PARTNER_TOKEN',
                'Content-Type': 'application/json'
                },
                body: JSON.stringify({
                redirect_url: window.location.origin + '/after-call',
                location: { latitude: 40.7128, longitude: -74.0060 },
                caller_name: "David",
                query: "plumber",
                })
            });
            
            
            if (!resp.ok) throw resp;
            const data = await resp.json();
            
            
            // Replace current page with the Zenfinder call
            window.location.replace(data.call_url);
            
        } catch (err) {
            console.error('Failed to create call', err);
            alert('Unable to start call — please try again.');
        }
    }
    
    document.getElementById('start-call').addEventListener('click', startCall);
</script>
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.zenfinder.ai/frontend-integration.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
