Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

1.7 KB
Raw Blame
import { createAction } from '@activepieces/pieces-framework';
import {
  HttpMethod,
  AuthenticationType,
  httpClient,
} from '@activepieces/pieces-common';
import { lobstermailCommon, inboxIdDropdown } from '../common';
import { lobstermailAuth } from '../..';

export const getInbox = createAction({
  auth: lobstermailAuth,
  name: 'get_inbox',
  classification: 'READ',
  displayName: 'Get Inbox',
  description: 'Get details for a single inbox including its address, status, and settings.',
  audience: 'both',
  aiMetadata: { description: 'Looks up one LobsterMail inbox by its id and returns its address, active status, and settings. Use to resolve or verify an inbox before sending or reading mail. Requires a known inbox id (obtain it via List Inboxes). Read-only and idempotent.', idempotent: true },
  props: {
    inbox_id: inboxIdDropdown,
  },
  async run(context) {
    const response = await httpClient.sendRequest<{
      id: string;
      address: string;
      localPart: string;
      domain: string;
      displayName?: string;
      active: boolean;
      autoExtract?: boolean;
      createdAt: string;
    }>({
      method: HttpMethod.GET,
      url: `${lobstermailCommon.baseUrl}/v1/inboxes/${context.propsValue.inbox_id}`,
      authentication: {
        type: AuthenticationType.BEARER_TOKEN,
        token: context.auth.secret_text,
      },
    });

    const inbox = response.body;
    return {
      id: inbox.id,
      address: inbox.address,
      local_part: inbox.localPart,
      domain: inbox.domain,
      display_name: inbox.displayName ?? null,
      active: inbox.active,
      auto_extract: inbox.autoExtract ?? null,
      created_at: inbox.createdAt,
    };
  },
});