# Portal de IA

> Crea portales de búsqueda con experiencia tipo ChatGPT

Fuente: https://developers.plazbot.com/sdk/portal/

### Introducción

Con el **SDK de Plazbot** puedes crear **Portales de IA** con experiencia tipo ChatGPT para tus clientes. Implementa IA para Atención al Cliente, Ventas, Soporte y más.

### Inicialización

```ts Plazbot (recomendado)
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
import { Portal } from 'plazbot';

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

### Creación del Portal

Crea un nuevo portal con la configuración de interfaz (título, subtitulo, marca, tema).

> **Importante:** Es fundamental asociar al menos un agente a un portal para que funcione. Sin agentes asociados, el portal no se cargara.

> **Importante:** **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 opción activada por defecto.

> **Tip:** Con un portal puedes tener multiples agentes: uno para Ventas, otro para Soporte, otro para Atención al Cliente, etc.

```ts
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 | Descripción |
|-------|------|-------------|
| `name` | `string` | Nombre del portal |
| `title` | `string` | Título que aparece en la parte superior |
| `subtitle` | `string` | Texto descriptivo debajo del título |
| `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="/images/sdk/portal.png"
/>

<img
  style={{ borderRadius: '0.5rem' }}
  src="/images/sdk/portal-light.png"
/>

### Asociar Agente al Portal

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

### Remover Agente del Portal

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

### Agregar Links al Portal

Agrega enlaces externos al portal. Máximo 5 enlaces. Se abren en una nueva ventana.

```ts
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"
});
```

### Obtener Portal

```ts
const portalInfo = await plazbot.portal.getPortal(portalId);
```

### Limpiar Links

Elimina todos los links configurados del portal.

```ts
await plazbot.portal.clearLinks(portalId);
```

### Actualizar Portal

Solo cambian los campos que envías; el resto (acceso, tema, estado, marca, logos) se mantiene.

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

### Eliminar Portal

```ts
await plazbot.portal.deletePortal(portalId);
```
