Good API documentation is rare. Most developers spend hours hunting for the right endpoint or trying to figure out why their authentication headers are failing. If your documentation is static and hard to search, you are losing integrations.
You need a way to make your docs interactive. You need an AI developer advocate.
In this tutorial, we will build a “DevRel Bot” using tochat. This agent acts as a senior engineer who knows your API inside out—instantly providing code snippets, debugging error messages, and explaining endpoints in any language.
Prerequisites
To build your developer agent, you need:
- A tochat account.
- A Google Gemini API Key. 👉 Need one? Check out our guide on how to get your free Google Gemini API Key in 2 minutes.
Step 1: Create Your Agent
From your Dashboard, click the + Agent button and input the Gemini API Key. After that, you’ll be redirected to add new agent page. Name it “API Copilot” or “DevRel Assistant.”
Step 2: The Persona (Tab: General)
This agent needs to speak “Code.” It should be concise, technical, and precise. It shouldn’t offer fluff; it should offer syntax.
Intro Text
Paste this hook into the Intro Text field to get straight to the point:
Ready to build? I'm [INSERT AGENT NAME], your API guide for [INSERT PRODUCT NAME]. I can help you find endpoints, debug authentication, or generate code snippets. Which endpoint or function are you working on right now?System Instruction
Paste the code below into the System Instruction field. This logic ensures the AI focuses on generating clean, formatted code blocks.
You are [INSERT AGENT NAME], the Senior Developer Advocate for [INSERT PRODUCT NAME].
**YOUR CORE VIBE:**
- You are technical, precise, and code-literate.
- You hate fluff. You give straight answers, correct syntax, and working code snippets.
- You speak to developers as a peer (e.g., using terms like "payload," "headers," "latency").
**LANGUAGE (GLOBAL SUPPORT):**
- **Rule:** Speak **ANY** language, but keep technical terms in English where standard (e.g., "API," "JSON," "Webhook").
- **Tone:** Technical, helpful, and concise.
**HOW TO INTERACT:**
1. **Endpoint Lookup:**
- If a user asks "How do I create a user?" or "Get order details," search the `source` knowledge base for the specific HTTP method and Endpoint (e.g., `POST /v1/users`).
- Provide the **Endpoint**, **Required Headers**, and a **Sample Request Body**.
2. **Code Generation:**
- If a user asks "Give me a Python example," use the logic from the `source` to write a clean, commented code snippet using the requested language (Python, Node.js, cURL).
3. **Debugging:**
- If a user pastes an error response, analyze it against the `source` error codes. Explain *why* it failed (e.g., "You missed the Authorization header").
**KEY KNOWLEDGE:**
- **Base URL:** [INSERT BASE URL].
- **Auth Method:** [INSERT AUTH METHOD, e.g., Bearer Token / API Key].
**RULE:**
- Always format code blocks with triple backticks (```) for readability.
- If a parameter is optional, mention that it is optional.Step 3: The Knowledge Base (Tab: Source)
This is where you upload your API Reference. The AI needs to know your Base URL, Authentication headers, and Endpoint structures to write code that actually works. Create *.txt file and copy paste text below:
### API OVERVIEW
**Base URL:** https://api.[INSERT DOMAIN].com/v1
**Authentication:**
- All requests must include the header: `Authorization: Bearer <YOUR_API_KEY>`
**Rate Limit:** [INSERT NUMBER] requests per minute per IP.
### ENDPOINTS: USERS
**GET /users**
- **Description:** Retrieve a list of users.
- **Parameters:** `limit` (int, optional), `page` (int, optional).
- **Response:** JSON array of user objects.
**POST /users**
- **Description:** Create a new user.
- **Required Body (JSON):**
```json
{
"email": "string",
"full_name": "string",
"role": "string"
}
````
### ENDPOINTS: DATA
**GET /data/{id}**
- **Description:** Get specific data object by ID.
- **Response 200:** Returns the data object.
- **Response 404:** Data not found.
### EXAMPLE CODE (PYTHON)
```python
import requests
url = "https://api.[INSERT DOMAIN].com/v1/users"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
response = requests.get(url, headers=headers)
print(response.json())
```
### SUPPORT
**Docs URL:** [INSERT URL TO FULL DOCS]
**Dev Community:** [INSERT DISCORD/SLACK LINK]Step 4: Integration (Tab: Embed)
For a Developer Advocate bot, placement is key. Go to the Embed tab and copy the script code. Place this widget directly on your Documentation page (e.g., docs.yourcompany.com).
This ensures that when a developer gets stuck, the help they need is right there next to the code.
Conclusion
An AI developer advocate dramatically improves your Developer Experience (DX). By unblocking developers instantly, you reduce churn and increase the likelihood of successful integrations.
Ready to upgrade your docs? Build your dev agent now.