> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trikon.tech/llms.txt
> Use this file to discover all available pages before exploring further.

# Google AI Studio

> Use Gemini in Google AI Studio with function calling so a model can start a Trikon Voice outbound call.

[Google AI Studio](https://aistudio.google.com) is the place to prototype Gemini prompts and **function declarations**. You define a tool that matches `POST /api/outbound-call`; Gemini fills in `to`, `name`, and metadata; your app (or a thin Cloud Function) performs the HTTP call with the workspace API key.

Do not put the Trikon API key in the AI Studio prompt. The model should only emit arguments. Your code holds the secret.

## Before you start

* A Gemini API key from AI Studio (**Get API key**).
* A Trikon workspace API key from **Settings → Developer API**.
* Outbound **agent ID**, **workspace slug**, and **from** phone-line UUID.

## 1. Declare a function that matches the API

In AI Studio, open **Tools → Function calling** (or add a function declaration in code) with this schema:

```json theme={null}
{
  "name": "start_trikon_outbound_call",
  "description": "Place an outbound phone call with a Trikon Voice agent.",
  "parameters": {
    "type": "object",
    "properties": {
      "to": {
        "type": "string",
        "description": "E.164 phone number, e.g. +919845012345"
      },
      "name": {
        "type": "string",
        "description": "Person's name; used as {{customer_name}} in the script"
      },
      "amount_due": {
        "type": "string",
        "description": "Optional amount the agent should mention"
      },
      "due_date": {
        "type": "string",
        "description": "Optional due date the agent should mention"
      }
    },
    "required": ["to"]
  }
}
```

Keep `agentId`, `enterprise`, and `from` in **your** environment, not in the model’s arguments. Those values should not change per customer.

## 2. Execute the function in your backend

When Gemini returns a `functionCall` for `start_trikon_outbound_call`, POST to Trikon:

```python theme={null}
import os
import requests

def start_trikon_outbound_call(to: str, name: str = "Customer", **metadata):
    body = {
        "to": to,
        "agentId": os.environ["TRIKON_AGENT_ID"],
        "enterprise": os.environ["TRIKON_ENTERPRISE"],
        "from": os.environ["TRIKON_FROM"],
        "name": name,
    }
    extra = {k: v for k, v in metadata.items() if v}
    if extra:
        body["metadata"] = extra

    res = requests.post(
        f"{os.environ['TRIKON_BASE_URL']}/api/outbound-call",
        headers={
            "Authorization": f"Bearer {os.environ['TRIKON_API_KEY']}",
            "Content-Type": "application/json",
        },
        json=body,
        timeout=30,
    )
    res.raise_for_status()
    return res.json()
```

Return `{ "success": true, "callUuid": "..." }` back to Gemini as the function response so the model can tell the user the call was placed.

## 3. Example prompt in AI Studio

```text theme={null}
You help a clinic collections desk. When the user gives a patient name,
phone number, amount due, and due date, call start_trikon_outbound_call.
Do not invent phone numbers. Confirm the number before calling.
```

Try: `Call Asha on +919845012345 about ₹4500 due 12 October.` Gemini should emit the function call; your executor hits Trikon; the agent rings Asha.

## 4. After the call

AI Studio does not receive Trikon webhooks by itself. Point **Settings → Developer API** at your own HTTPS endpoint, then (optionally) feed `intent` and `summary` from [webhook events](/developers/webhooks) back into Gemini for a follow-up message in your product.

<Warning>
  Gemini can hallucinate numbers or amounts. Require the user (or your CRM) to supply `to` and treat model-filled metadata as untrusted until you validate it.
</Warning>
