Skip to main content
Questa pagina fa parte di una skill per agenti IA di programmazione ed è scritta per gli agenti, non per gli umani. Per la documentazione Base44 leggibile dagli umani, consulta la documentazione per sviluppatori.

Modulo Integrations

Accedi a servizi di terze parti tramite base44.integrations.

Tipi di integrazioni

  1. Core/integrate: IA, email, upload di file (disponibili di default)
  2. Integrazioni dal catalogo: connettori predefiniti dal catalogo Base44
  3. Integrazioni personalizzate: le tue integrazioni basate su OpenAPI

Accedere alle integrazioni

// Core integrations
base44.integrations.Core.FunctionName(params)

// Custom integrations
base44.integrations.custom.call(slug, operationId, params)

Integrazioni core

InvokeLLM (generazione di testo con IA)

Genera testo o dati JSON strutturati usando modelli di IA.
// Basic prompt - returns string
const response = await base44.integrations.Core.InvokeLLM({
  prompt: "Summarize this text: ..."
});

// With internet context (uses Google Search, Maps, News)
const response = await base44.integrations.Core.InvokeLLM({
  prompt: "What's the current weather in NYC?",
  add_context_from_internet: true
});

// Structured JSON response - returns object
const response = await base44.integrations.Core.InvokeLLM({
  prompt: "Analyze the sentiment of: 'Great product but slow shipping'",
  response_json_schema: {
    type: "object",
    properties: {
      sentiment: { type: "string", enum: ["positive", "negative", "mixed"] },
      score: { type: "number", description: "Score from 1-10" },
      key_points: { type: "array", items: { type: "string" } }
    }
  }
});
// Returns: { sentiment: "mixed", score: 7, key_points: ["great product", "slow shipping"] }

// With file attachments (uploaded via UploadFile)
const response = await base44.integrations.Core.InvokeLLM({
  prompt: "Describe what's in this image",
  file_urls: ["https://...uploaded_image.png"]
});
Parametri:
  • prompt (string, obbligatorio): il testo del prompt da inviare al modello
  • add_context_from_internet (boolean, opzionale): se true, usa Google Search/Maps/News per contesto in tempo reale
  • response_json_schema (object, opzionale): schema JSON per output strutturato
  • file_urls (string[], opzionale): URL di file caricati come contesto

GenerateImage

Crea immagini generate dall’IA a partire da prompt testuali.
const { url } = await base44.integrations.Core.GenerateImage({
  prompt: "A serene mountain landscape with a lake"
});
console.log(url); // https://...generated_image.png

SendEmail

Invia email agli utenti registrati. Ogni app riceve questa integrazione (non serve aggiornare il piano).
await base44.integrations.Core.SendEmail({
  to: "user@example.com",
  subject: "Welcome!",
  body: "<h1>Hello</h1><p>Welcome to our app.</p>",
  from_name: "My App"  // optional, defaults to app name
});
Parametri:
  • to (string, obbligatorio): indirizzo email del destinatario
  • subject (string, obbligatorio): oggetto dell’email
  • body (string, obbligatorio): corpo dell’email in testo semplice o HTML
  • from_name (string, opzionale): nome del mittente mostrato al destinatario
Limitazioni:
  • 1 credito per email (2 crediti con dominio personalizzato)

UploadFile (pubblico)

Carica file nello storage pubblico.
const fileInput = document.querySelector('input[type="file"]');
const { file_url } = await base44.integrations.Core.UploadFile({
  file: fileInput.files[0]
});
console.log(file_url); // https://...uploaded_file.pdf

UploadPrivateFile

Carica file in uno storage privato che richiede un URL firmato per l’accesso.
const { file_uri } = await base44.integrations.Core.UploadPrivateFile({
  file: fileInput.files[0]
});
console.log(file_uri); // "private/user123/document.pdf"

// Create a signed URL to access the file
const { signed_url } = await base44.integrations.Core.CreateFileSignedUrl({
  file_uri,
  expires_in: 3600  // URL expires in 1 hour (default: 300 seconds)
});
console.log(signed_url); // Temporary URL to access the private file

CreateFileSignedUrl

Genera link di accesso temporanei per i file privati.
const { signed_url } = await base44.integrations.Core.CreateFileSignedUrl({
  file_uri: "private/user123/document.pdf",
  expires_in: 7200  // 2 hours
});
Parametri:
  • file_uri (string, obbligatorio): URI ottenuto da UploadPrivateFile
  • expires_in (number, opzionale): tempo di scadenza in secondi (default: 300)

ExtractDataFromUploadedFile

Estrai dati strutturati da file caricati usando l’IA.
// First upload the file
const { file_url } = await base44.integrations.Core.UploadFile({ file });

// Then extract structured data
const result = await base44.integrations.Core.ExtractDataFromUploadedFile({
  file_url,
  json_schema: {
    type: "object",
    properties: {
      invoice_number: { type: "string" },
      total_amount: { type: "number" },
      date: { type: "string" },
      vendor_name: { type: "string" }
    }
  }
});
console.log(result); // { invoice_number: "INV-12345", total_amount: 1250.00, ... }

Integrazioni personalizzate

Le integrazioni personalizzate permettono agli amministratori del workspace di collegare qualsiasi API esterna importando una specifica OpenAPI. Usa base44.integrations.custom.call() per invocarle.

Sintassi

const response = await base44.integrations.custom.call(
  slug,        // Integration identifier (set by admin)
  operationId, // Endpoint in "method:path" format (e.g. "get:/contacts", "post:/repos/{owner}/{repo}/issues")
  params       // Optional: payload, pathParams, queryParams
);

Esempi

// GET request with query params
const response = await base44.integrations.custom.call(
  "my-crm",
  "get:/contacts",
  { queryParams: { limit: 10, status: "active" } }
);

// POST request with body
const response = await base44.integrations.custom.call(
  "my-crm",
  "post:/contacts",
  { payload: { name: "John Doe", email: "john@example.com" } }
);

// Request with path parameters
const response = await base44.integrations.custom.call(
  "github",
  "post:/repos/{owner}/{repo}/issues",
  {
    pathParams: { owner: "myorg", repo: "myrepo" },
    payload: { title: "Bug report", body: "Something is broken" }
  }
);

Struttura della risposta

{
  success: true,      // Whether external API returned 2xx
  status_code: 200,   // HTTP status code
  data: { ... }       // Response from external API
}

Requisiti

  • Integrazioni core: disponibili su tutti i piani
  • Integrazioni dal catalogo/personalizzate: richiedono il piano Builder o superiore

Definizioni dei tipi

Parametri delle integrazioni core

/** Parameters for the InvokeLLM function. */
interface InvokeLLMParams {
  /** The prompt text to send to the model. */
  prompt: string;
  /** If true, uses Google Search/Maps/News for real-time context. */
  add_context_from_internet?: boolean;
  /** JSON schema for structured output. If provided, returns object instead of string. */
  response_json_schema?: object;
  /** File URLs (from UploadFile) to provide as context. */
  file_urls?: string[];
}

/** Parameters for the GenerateImage function. */
interface GenerateImageParams {
  /** Description of the image to generate. */
  prompt: string;
}

/** Result from GenerateImage. */
interface GenerateImageResult {
  /** URL of the generated image. */
  url: string;
}

/** Parameters for the UploadFile function. */
interface UploadFileParams {
  /** The file object to upload. */
  file: File;
}

/** Result from UploadFile. */
interface UploadFileResult {
  /** URL of the uploaded file. */
  file_url: string;
}

/** Parameters for the SendEmail function. */
interface SendEmailParams {
  /** Recipient email address. */
  to: string;
  /** Email subject line. */
  subject: string;
  /** Plain text or HTML email body. */
  body: string;
  /** Sender name (defaults to app name). */
  from_name?: string;
}

/** Parameters for ExtractDataFromUploadedFile. */
interface ExtractDataFromUploadedFileParams {
  /** URL of the uploaded file. */
  file_url: string;
  /** JSON schema defining fields to extract. */
  json_schema: object;
}

/** Parameters for UploadPrivateFile. */
interface UploadPrivateFileParams {
  /** The file object to upload. */
  file: File;
}

/** Result from UploadPrivateFile. */
interface UploadPrivateFileResult {
  /** URI of the private file (used for signed URLs). */
  file_uri: string;
}

/** Parameters for CreateFileSignedUrl. */
interface CreateFileSignedUrlParams {
  /** URI from UploadPrivateFile. */
  file_uri: string;
  /** Expiration time in seconds (default: 300). */
  expires_in?: number;
}

/** Result from CreateFileSignedUrl. */
interface CreateFileSignedUrlResult {
  /** Temporary signed URL to access the file. */
  signed_url: string;
}

CoreIntegrations

/** Core package containing built-in Base44 integration functions. */
interface CoreIntegrations {
  InvokeLLM(params: InvokeLLMParams): Promise<string | object>;
  GenerateImage(params: GenerateImageParams): Promise<GenerateImageResult>;
  UploadFile(params: UploadFileParams): Promise<UploadFileResult>;
  SendEmail(params: SendEmailParams): Promise<any>;
  ExtractDataFromUploadedFile(params: ExtractDataFromUploadedFileParams): Promise<object>;
  UploadPrivateFile(params: UploadPrivateFileParams): Promise<UploadPrivateFileResult>;
  CreateFileSignedUrl(params: CreateFileSignedUrlParams): Promise<CreateFileSignedUrlResult>;
}

Integrazioni personalizzate

/** Parameters for calling a custom integration method. */
interface CustomIntegrationCallParams {
  /** Request body payload. */
  payload?: Record<string, any>;
  /** Path parameters to substitute in the URL. For example, { owner: "user", repo: "repo" }. */
  pathParams?: Record<string, string>;
  /** Query string parameters. */
  queryParams?: Record<string, any>;
}

/** Response from a custom integration call. */
interface CustomIntegrationCallResponse {
  /** Whether the external API returned a 2xx status code. */
  success: boolean;
  /** The HTTP status code from the external API. */
  status_code: number;
  /** The response data from the external API. */
  data: any;
}

/** Module for calling custom pre-configured API integrations. */
interface CustomIntegrationsModule {
  /**
   * Call a custom integration method.
   * @param slug - The integration's unique identifier (set by workspace admin).
   * @param operationId - The endpoint in "method:path" format (e.g. "get:/contacts", "post:/users/{id}").
   * @param params - Optional payload, pathParams, queryParams.
   */
  call(slug: string, operationId: string, params?: CustomIntegrationCallParams): Promise<CustomIntegrationCallResponse>;
}

IntegrationsModule

/** Integrations module for calling integration methods. */
type IntegrationsModule = {
  /** Core package with built-in integrations. */
  Core: CoreIntegrations;
  /** Custom integrations module. */
  custom: CustomIntegrationsModule;
  /** Additional integration packages (dynamic). */
  [packageName: string]: any;
};
Questa pagina è stata tradotta utilizzando l’IA. Per informazioni più accurate e aggiornate, consulta la versione inglese.