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

# Portal de IA

> Crea portales de busqueda con experiencia tipo ChatGPT

### Introduccion

Con el **SDK de Plazbot** puedes crear **Portales de IA** con experiencia tipo ChatGPT para tus clientes. Implementa IA para Atencion al Cliente, Ventas, Soporte y mas.

### Inicializacion

<CodeGroup>
  ```ts Plazbot (recomendado) theme={null}
  import { Plazbot } from 'plazbot';

  const plazbot = new Plazbot({
    workspaceId: "YOUR_WORKSPACE_ID",
    apiKey: "YOUR_API_KEY",
    zone: "LA"
  });

  // Usar: plazbot.portal.addPortal(...)
  ```

  ```ts Portal individual theme={null}
  import { Portal } from 'plazbot';

  const portal = new Portal({
    workspaceId: "YOUR_WORKSPACE_ID",
    apiKey: "YOUR_API_KEY",
    zone: "LA"
  });
  ```
</CodeGroup>

### Creacion del Portal

Crea un nuevo portal con la configuracion de interfaz (titulo, subtitulo, marca, tema).

<Warning>
  Es fundamental asociar al menos un agente a un portal para que funcione. Sin agentes asociados, el portal no se cargara.
</Warning>

<Warning>
  **Importante:** Los agentes asociados a Portales deben tener `useToolCalling: true` activado para que el streaming SSE funcione correctamente. Los nuevos agentes ya se crean con esta opcion activada por defecto.
</Warning>

<Tip>
  Con un portal puedes tener multiples agentes: uno para Ventas, otro para Soporte, otro para Atencion al Cliente, etc.
</Tip>

```ts theme={null}
const portalCreated = await plazbot.portal.addPortal({
  name: "Portal de Busqueda",
  zone: "LA",
  title: "Centro de Ayuda",
  subtitle: "Pregunta lo que necesites",
  logo: "https://tu-dominio.com/logo.png",
  logodark: "https://tu-dominio.com/logo-dark.png",
  access: "direct",  // "direct" o "form"
  theme: "light",     // "light" o "dark"
  disabled: false,
  brandOff: false,
});

const portalId = portalCreated.id;
const portalUrl = portalCreated.url;
```

Al crear el portal recibiras la URL publica:

```
https://appla.plazbot.com/portal?id={PORTAL_ID}&workspaceId={WORKSPACE_ID}
```

**Campos del Portal**

| Campo      | Tipo      | Descripcion                             |
| ---------- | --------- | --------------------------------------- |
| `name`     | `string`  | Nombre del portal                       |
| `title`    | `string`  | Titulo que aparece en la parte superior |
| `subtitle` | `string`  | Texto descriptivo debajo del titulo     |
| `logo`     | `string`  | URL del logo en modo claro (PNG/JPG)    |
| `logodark` | `string`  | URL del logo en modo oscuro (PNG/JPG)   |
| `access`   | `string`  | `"direct"` o `"form"`                   |
| `theme`    | `string`  | `"light"` o `"dark"`                    |
| `disabled` | `boolean` | Activar/desactivar portal               |
| `brandOff` | `boolean` | Ocultar marca Plazbot                   |
| `zone`     | `string`  | `"LA"` o `"EU"`                         |

<img style={{ borderRadius: '0.5rem' }} src="https://mintcdn.com/plazbot/Hg1ZdNXWjISFp5fx/images/sdk/portal.png?fit=max&auto=format&n=Hg1ZdNXWjISFp5fx&q=85&s=f67fc1a0329aa2e82daf75ed34a84524" width="3972" height="2308" data-path="images/sdk/portal.png" />

<img style={{ borderRadius: '0.5rem' }} src="https://mintcdn.com/plazbot/Hg1ZdNXWjISFp5fx/images/sdk/portal-light.png?fit=max&auto=format&n=Hg1ZdNXWjISFp5fx&q=85&s=0c3e91f9b4446ce114c34f4034c8df32" width="3962" height="2320" data-path="images/sdk/portal-light.png" />

### Asociar Agente al Portal

```ts theme={null}
await plazbot.portal.addAgentToPortal({
  portalId: portalId,
  id: agentId
});
```

### Remover Agente del Portal

```ts theme={null}
await plazbot.portal.removeAgentFromPortal({
  portalId: portalId,
  id: agentId
});
```

### Agregar Links al Portal

Agrega enlaces externos al portal. Maximo 5 enlaces. Se abren en una nueva ventana.

```ts theme={null}
await plazbot.portal.addLinkToPortal({
  portalId: portalId,
  value: "Blog",
  url: "https://www.plazbot.com/blog"
});

await plazbot.portal.addLinkToPortal({
  portalId: portalId,
  value: "Documentacion",
  url: "https://docs.plazbot.com"
});

await plazbot.portal.addLinkToPortal({
  portalId: portalId,
  value: "Discord",
  url: "https://discord.gg/SgyAtrwzp7"
});
```

### Obtener Portal

```ts theme={null}
const portalInfo = await plazbot.portal.getPortal(portalId);
```

### Limpiar Links

Elimina todos los links configurados del portal.

```ts theme={null}
await plazbot.portal.clearLinks(portalId);
```

### Actualizar Portal

```ts theme={null}
await plazbot.portal.updatePortal({
  id: portalId,
  name: "Portal Actualizado",
  theme: "dark"
});
```

### Eliminar Portal

```ts theme={null}
await plazbot.portal.deletePortal(portalId);
```
