Class AiPlansResource

Hierarchy

  • Resource
    • AiPlansResource

Constructors

Methods

  • Encola un plan. No devuelve publicaciones: devuelve el plan en pending y el presupuesto que se calculó para aceptarlo.

    Falla ANTES de gastar nada si no hay créditos para el coste imprescindible (941), si no queda cupo de publicaciones (924), si alguna cuenta no publica —WhatsApp, Google Business— (942), o si con los días elegidos no queda ningún hueco futuro en la semana (2108).

    const { ai_plan, estimate } = await pv.aiPlans.create(clientId, orgId, {
    prompt: "Pan de masa madre, horno de leña, barrio",
    accounts: [accountId],
    options: { publish_days: [1, 3, 5], timezone: "Europe/Madrid" },
    });

    Parameters

    • idClient: string
    • idOrganization: string
    • body: {
          accounts: string[];
          options?: {
              allow_images?: boolean;
              gallery_uploads?: string[];
              language?: string;
              max_images?: number;
              publish_days?: number[];
              shared?: boolean;
              timezone?: string;
              tone?: string;
              use_organization_context?: boolean;
              week_start?: string;
          };
          prompt: string;
      }
      • accounts: string[]

        Account ids (belonging to the organization) to generate the plan for.

      • Optionaloptions?: {
            allow_images?: boolean;
            gallery_uploads?: string[];
            language?: string;
            max_images?: number;
            publish_days?: number[];
            shared?: boolean;
            timezone?: string;
            tone?: string;
            use_organization_context?: boolean;
            week_start?: string;
        }
        • Optionalallow_images?: boolean

          Whether images may be generated. Each image costs 70 AI credits. Optional; defaults to true.

        • Optionalgallery_uploads?: string[]

          Upload ids from the organization's gallery used as visual reference for the generated images.

        • Optionallanguage?: string

          Language of the generated texts. Optional; defaults to "es".

        • Optionalmax_images?: number

          Optional cap on the number of images; the credit budget may reduce it further.

        • Optionalpublish_days?: number[]

          Days of the week the plan publishes on, in ISO 8601 numbering (1 = Monday ... 7 = Sunday). Defaults to the whole week. There is still at most ONE publication per day and account, so this is what bounds the size and the cost of the plan: the number of generated posts is (selected days x accounts). Must be a non-empty array of unique integers between 1 and 7, or the request is rejected with 2106. The 7-day window starts at week_start, so each ISO day appears exactly once: with a week_start in mid-week, day 1 (Monday) is the FOLLOWING Monday. If the selected days leave no future slot at all, the request is rejected with 2108. Optional; defaults to [1,2,3,4,5,6,7].

        • Optionalshared?: boolean

          Generate ONE piece of content per day and replicate it across every account, each scheduled at the best hour for ITS network, instead of one publication per account and day. Cheaper — one text and one image per day — and it caps images at 7. Optional; defaults to false.

        • Optionaltimezone?: string

          IANA timezone for the optimal publish slots (typically the user's browser timezone). publish_date is stored in UTC. Optional; defaults to "Europe/Madrid".

        • Optionaltone?: string

          Optional tone (e.g. 'cercano', 'profesional') passed to the prompt.

        • Optionaluse_organization_context?: boolean

          Use the organization's brand context in the prompts. It is copied into the plan as a SNAPSHOT when the plan is created, so a retry or a regeneration uses the context the plan was asked with even if the configuration changed meanwhile. Optional; defaults to true.

        • Optionalweek_start?: string

          Format: date-time

          Start of the week to plan (slots are generated between this date and +7 days). Defaults to now.

      • prompt: string

        Theme prompt written by the user.

    • options: RequestOptions = {}

    Returns Promise<
        {
            ai_plan: {
                _id: string;
                accounts: string[];
                attempts: number;
                creation_date: string;
                credits_spent: number;
                error?: {
                    code: number;
                    data?: { [key: string]: unknown };
                    message: string;
                };
                generation_end_date?: string;
                id_client: string;
                id_organization: string;
                keycloak_identifier?: string;
                options: {
                    allow_images: boolean;
                    gallery_uploads: string[];
                    language: string;
                    max_images?: number;
                    publish_days: number[];
                    shared: boolean;
                    timezone: string;
                    tone?: string;
                    use_organization_context: boolean;
                    week_start: string;
                };
                orchestrator_result?: Record<string, never>;
                organization_context?: {
                    audience?: string;
                    avoid?: string;
                    blog_url?: string;
                    brand_name?: string;
                    default_tone?: string;
                    description?: string;
                    keywords?: string[];
                    notes?: string;
                    products?: string;
                    sector?: string;
                    shop_url?: string;
                    social_urls?: string[];
                    value_proposition?: string;
                    website?: string;
                };
                prompt: string;
                publications: (
                    | string
                    | {
                        _id: string;
                        creation_date: string;
                        engagement_base?: "reach"
                        | "impressions"
                        | "followers";
                        external_identifier?: string;
                        files: {
                            _id: string;
                            cover_image?: { _id: string; cover_image?: ...; cover_offset?: number; creation_date: string; file_externals: { external_identifier: string; external_url: string; social_network: "facebook" | "instagram" | ... 7 more ... | "discord"; }[]; ... 6 more ...; public_path: string; };
                            cover_offset?: number;
                            creation_date: string;
                            file_externals: {
                                external_identifier: string;
                                external_url: string;
                                social_network:
                                    | (...)
                                    | (...)
                                    | (...)
                                    | (...)
                                    | (...)
                                    | (...)
                                    | (...)
                                    | (...)
                                    | (...)
                                    | (...);
                            }[];
                            file_format: "mp4"
                            | "jpeg"
                            | "gif"
                            | "png"
                            | "jpg";
                            file_properties: {
                                allowed_social_networks: string[];
                                aspect_ratio: { text: string; value: number };
                                duration: number;
                                height: number;
                                size_in_bytes: number;
                                width: number;
                            };
                            file_type: "video"
                            | "image";
                            id_organization: string;
                            is_temporal: boolean;
                            name: string;
                            public_path: string;
                        }[];
                        id_account: | string
                        | {
                            _id: string;
                            creation_date: string;
                            error_code: number;
                            followers_count?: number;
                            id_client: string;
                            id_organization: string;
                            image?: string;
                            name: string;
                            next_comments_update?: string;
                            next_stats_update?: string;
                            private_message_link?: string;
                            social_network: | "facebook"
                            | "instagram"
                            | "linkedin"
                            | "tiktok"
                            | "twitter"
                            | "whatsapp"
                            | "youtube"
                            | "google_business"
                            | "bluesky"
                            | "discord";
                            username?: string;
                        };
                        id_integration?: string;
                        id_organization: string;
                        metrics?: {
                            clicks?: number;
                            comments?: number;
                            engagement?: number;
                            followers?: number;
                            followers_gained?: number;
                            impressions?: number;
                            likes?: number;
                            profile_views?: number;
                            reach?: number;
                            saves?: number;
                            shares?: number;
                            video_views?: number;
                        };
                        name?: string;
                        next_stats_update?: string;
                        publication_errors: {
                            code: number;
                            data?: { [key: string]: unknown };
                            message: string;
                        }[];
                        publication_type: | "profile"
                        | "page"
                        | "group"
                        | "reels"
                        | "stories"
                        | "message";
                        publish_date?: string;
                        retries: number;
                        social_network: | "facebook"
                        | "instagram"
                        | "linkedin"
                        | "tiktok"
                        | "twitter"
                        | "whatsapp"
                        | "youtube"
                        | "google_business"
                        | "bluesky"
                        | "discord";
                        state: "ready"
                        | "withErrors"
                        | "sended"
                        | "draft"
                        | "publishing";
                        statistics?: {
                            angers?: number;
                            bookmarks?: number;
                            clicks?: number;
                            comments?: number;
                            engagement?: number;
                            follows?: number;
                            hahas?: number;
                            impressions?: number;
                            likes?: number;
                            loves?: number;
                            negative_feedback?: number;
                            page_likes?: number;
                            playback_0_count?: number;
                            playback_100_count?: number;
                            playback_25_count?: number;
                            playback_50_count?: number;
                            playback_75_count?: number;
                            profile_activity?: number;
                            profile_visits?: number;
                            quotes?: number;
                            reach?: number;
                            replys?: number;
                            retwets?: number;
                            saved?: number;
                            share?: number;
                            shareMentions?: number;
                            shares?: number;
                            sorrys?: number;
                            url_link_clicks?: number;
                            user_profile_clicks?: number;
                            video_views?: number;
                            views?: number;
                            wows?: number;
                        };
                        stats_updated_date?: string;
                        text?: string;
                        title?: string;
                        url?: string;
                    }
                )[];
                state: | "pending"
                | "generating"
                | "generated"
                | "validated"
                | "failed"
                | "cancelled";
            };
            estimate: {
                available_credits: number;
                base_cost: number;
                estimated_cost: number;
                images_target: number;
                texts_target: number;
            };
            estimated_cost: number;
        },
    >

  • Un plan, con sus publicaciones ya resueltas y con los ficheros de cada una.

    Es el endpoint que se sondea mientras state sea pending o generating. No hay webhook de esto todavía.

    Parameters

    • idClient: string
    • idOrganization: string
    • idAiPlan: string
    • options: RequestOptions = {}

    Returns Promise<
        {
            _id: string;
            accounts: string[];
            attempts: number;
            creation_date: string;
            credits_spent: number;
            error?: {
                code: number;
                data?: { [key: string]: unknown };
                message: string;
            };
            generation_end_date?: string;
            id_client: string;
            id_organization: string;
            keycloak_identifier?: string;
            options: {
                allow_images: boolean;
                gallery_uploads: string[];
                language: string;
                max_images?: number;
                publish_days: number[];
                shared: boolean;
                timezone: string;
                tone?: string;
                use_organization_context: boolean;
                week_start: string;
            };
            orchestrator_result?: Record<string, never>;
            organization_context?: {
                audience?: string;
                avoid?: string;
                blog_url?: string;
                brand_name?: string;
                default_tone?: string;
                description?: string;
                keywords?: string[];
                notes?: string;
                products?: string;
                sector?: string;
                shop_url?: string;
                social_urls?: string[];
                value_proposition?: string;
                website?: string;
            };
            prompt: string;
            publications: (
                | string
                | {
                    _id: string;
                    creation_date: string;
                    engagement_base?: "reach"
                    | "impressions"
                    | "followers";
                    external_identifier?: string;
                    files: {
                        _id: string;
                        cover_image?: { _id: string; cover_image?: ...; cover_offset?: number; creation_date: string; file_externals: { external_identifier: string; external_url: string; social_network: "facebook" | "instagram" | ... 7 more ... | "discord"; }[]; ... 6 more ...; public_path: string; };
                        cover_offset?: number;
                        creation_date: string;
                        file_externals: {
                            external_identifier: string;
                            external_url: string;
                            social_network:
                                | "facebook"
                                | "instagram"
                                | "linkedin"
                                | "tiktok"
                                | "twitter"
                                | "whatsapp"
                                | "youtube"
                                | "google_business"
                                | "bluesky"
                                | "discord";
                        }[];
                        file_format: "mp4"
                        | "jpeg"
                        | "gif"
                        | "png"
                        | "jpg";
                        file_properties: {
                            allowed_social_networks: string[];
                            aspect_ratio: { text: string; value: number };
                            duration: number;
                            height: number;
                            size_in_bytes: number;
                            width: number;
                        };
                        file_type: "video"
                        | "image";
                        id_organization: string;
                        is_temporal: boolean;
                        name: string;
                        public_path: string;
                    }[];
                    id_account: | string
                    | {
                        _id: string;
                        creation_date: string;
                        error_code: number;
                        followers_count?: number;
                        id_client: string;
                        id_organization: string;
                        image?: string;
                        name: string;
                        next_comments_update?: string;
                        next_stats_update?: string;
                        private_message_link?: string;
                        social_network: | "facebook"
                        | "instagram"
                        | "linkedin"
                        | "tiktok"
                        | "twitter"
                        | "whatsapp"
                        | "youtube"
                        | "google_business"
                        | "bluesky"
                        | "discord";
                        username?: string;
                    };
                    id_integration?: string;
                    id_organization: string;
                    metrics?: {
                        clicks?: number;
                        comments?: number;
                        engagement?: number;
                        followers?: number;
                        followers_gained?: number;
                        impressions?: number;
                        likes?: number;
                        profile_views?: number;
                        reach?: number;
                        saves?: number;
                        shares?: number;
                        video_views?: number;
                    };
                    name?: string;
                    next_stats_update?: string;
                    publication_errors: {
                        code: number;
                        data?: { [key: string]: unknown };
                        message: string;
                    }[];
                    publication_type: | "profile"
                    | "page"
                    | "group"
                    | "reels"
                    | "stories"
                    | "message";
                    publish_date?: string;
                    retries: number;
                    social_network: | "facebook"
                    | "instagram"
                    | "linkedin"
                    | "tiktok"
                    | "twitter"
                    | "whatsapp"
                    | "youtube"
                    | "google_business"
                    | "bluesky"
                    | "discord";
                    state: "ready"
                    | "withErrors"
                    | "sended"
                    | "draft"
                    | "publishing";
                    statistics?: {
                        angers?: number;
                        bookmarks?: number;
                        clicks?: number;
                        comments?: number;
                        engagement?: number;
                        follows?: number;
                        hahas?: number;
                        impressions?: number;
                        likes?: number;
                        loves?: number;
                        negative_feedback?: number;
                        page_likes?: number;
                        playback_0_count?: number;
                        playback_100_count?: number;
                        playback_25_count?: number;
                        playback_50_count?: number;
                        playback_75_count?: number;
                        profile_activity?: number;
                        profile_visits?: number;
                        quotes?: number;
                        reach?: number;
                        replys?: number;
                        retwets?: number;
                        saved?: number;
                        share?: number;
                        shareMentions?: number;
                        shares?: number;
                        sorrys?: number;
                        url_link_clicks?: number;
                        user_profile_clicks?: number;
                        video_views?: number;
                        views?: number;
                        wows?: number;
                    };
                    stats_updated_date?: string;
                    text?: string;
                    title?: string;
                    url?: string;
                }
            )[];
            state: | "pending"
            | "generating"
            | "generated"
            | "validated"
            | "failed"
            | "cancelled";
        },
    >

  • Los planes de la organización, encadenando páginas.

    Parameters

    Returns AsyncGenerator<
        {
            _id: string;
            accounts: string[];
            attempts: number;
            creation_date: string;
            credits_spent: number;
            error?: {
                code: number;
                data?: { [key: string]: unknown };
                message: string;
            };
            generation_end_date?: string;
            id_client: string;
            id_organization: string;
            keycloak_identifier?: string;
            options: {
                allow_images: boolean;
                gallery_uploads: string[];
                language: string;
                max_images?: number;
                publish_days: number[];
                shared: boolean;
                timezone: string;
                tone?: string;
                use_organization_context: boolean;
                week_start: string;
            };
            orchestrator_result?: Record<string, never>;
            organization_context?: {
                audience?: string;
                avoid?: string;
                blog_url?: string;
                brand_name?: string;
                default_tone?: string;
                description?: string;
                keywords?: string[];
                notes?: string;
                products?: string;
                sector?: string;
                shop_url?: string;
                social_urls?: string[];
                value_proposition?: string;
                website?: string;
            };
            prompt: string;
            publications: (
                | string
                | {
                    _id: string;
                    creation_date: string;
                    engagement_base?: "reach"
                    | "impressions"
                    | "followers";
                    external_identifier?: string;
                    files: {
                        _id: string;
                        cover_image?: { _id: string; cover_image?: ...; cover_offset?: number; creation_date: string; file_externals: { external_identifier: string; external_url: string; social_network: "facebook" | "instagram" | ... 7 more ... | "discord"; }[]; ... 6 more ...; public_path: string; };
                        cover_offset?: number;
                        creation_date: string;
                        file_externals: {
                            external_identifier: string;
                            external_url: string;
                            social_network:
                                | "facebook"
                                | "instagram"
                                | "linkedin"
                                | "tiktok"
                                | "twitter"
                                | "whatsapp"
                                | "youtube"
                                | "google_business"
                                | "bluesky"
                                | "discord";
                        }[];
                        file_format: "mp4"
                        | "jpeg"
                        | "gif"
                        | "png"
                        | "jpg";
                        file_properties: {
                            allowed_social_networks: string[];
                            aspect_ratio: { text: string; value: number };
                            duration: number;
                            height: number;
                            size_in_bytes: number;
                            width: number;
                        };
                        file_type: "video"
                        | "image";
                        id_organization: string;
                        is_temporal: boolean;
                        name: string;
                        public_path: string;
                    }[];
                    id_account: | string
                    | {
                        _id: string;
                        creation_date: string;
                        error_code: number;
                        followers_count?: number;
                        id_client: string;
                        id_organization: string;
                        image?: string;
                        name: string;
                        next_comments_update?: string;
                        next_stats_update?: string;
                        private_message_link?: string;
                        social_network: | "facebook"
                        | "instagram"
                        | "linkedin"
                        | "tiktok"
                        | "twitter"
                        | "whatsapp"
                        | "youtube"
                        | "google_business"
                        | "bluesky"
                        | "discord";
                        username?: string;
                    };
                    id_integration?: string;
                    id_organization: string;
                    metrics?: {
                        clicks?: number;
                        comments?: number;
                        engagement?: number;
                        followers?: number;
                        followers_gained?: number;
                        impressions?: number;
                        likes?: number;
                        profile_views?: number;
                        reach?: number;
                        saves?: number;
                        shares?: number;
                        video_views?: number;
                    };
                    name?: string;
                    next_stats_update?: string;
                    publication_errors: {
                        code: number;
                        data?: { [key: string]: unknown };
                        message: string;
                    }[];
                    publication_type: | "profile"
                    | "page"
                    | "group"
                    | "reels"
                    | "stories"
                    | "message";
                    publish_date?: string;
                    retries: number;
                    social_network: | "facebook"
                    | "instagram"
                    | "linkedin"
                    | "tiktok"
                    | "twitter"
                    | "whatsapp"
                    | "youtube"
                    | "google_business"
                    | "bluesky"
                    | "discord";
                    state: "ready"
                    | "withErrors"
                    | "sended"
                    | "draft"
                    | "publishing";
                    statistics?: {
                        angers?: number;
                        bookmarks?: number;
                        clicks?: number;
                        comments?: number;
                        engagement?: number;
                        follows?: number;
                        hahas?: number;
                        impressions?: number;
                        likes?: number;
                        loves?: number;
                        negative_feedback?: number;
                        page_likes?: number;
                        playback_0_count?: number;
                        playback_100_count?: number;
                        playback_25_count?: number;
                        playback_50_count?: number;
                        playback_75_count?: number;
                        profile_activity?: number;
                        profile_visits?: number;
                        quotes?: number;
                        reach?: number;
                        replys?: number;
                        retwets?: number;
                        saved?: number;
                        share?: number;
                        shareMentions?: number;
                        shares?: number;
                        sorrys?: number;
                        url_link_clicks?: number;
                        user_profile_clicks?: number;
                        video_views?: number;
                        views?: number;
                        wows?: number;
                    };
                    stats_updated_date?: string;
                    text?: string;
                    title?: string;
                    url?: string;
                }
            )[];
            state: | "pending"
            | "generating"
            | "generated"
            | "validated"
            | "failed"
            | "cancelled";
        },
    >

  • Los planes de la organización, del más reciente al más antiguo.

    Los cancelados no salen, y aquí publications son identificadores, no las publicaciones enteras: para eso está get. Sin limit vuelven todos.

    Parameters

    Returns Promise<
        Paginated<
            {
                _id: string;
                accounts: string[];
                attempts: number;
                creation_date: string;
                credits_spent: number;
                error?: {
                    code: number;
                    data?: { [key: string]: unknown };
                    message: string;
                };
                generation_end_date?: string;
                id_client: string;
                id_organization: string;
                keycloak_identifier?: string;
                options: {
                    allow_images: boolean;
                    gallery_uploads: string[];
                    language: string;
                    max_images?: number;
                    publish_days: number[];
                    shared: boolean;
                    timezone: string;
                    tone?: string;
                    use_organization_context: boolean;
                    week_start: string;
                };
                orchestrator_result?: Record<string, never>;
                organization_context?: {
                    audience?: string;
                    avoid?: string;
                    blog_url?: string;
                    brand_name?: string;
                    default_tone?: string;
                    description?: string;
                    keywords?: string[];
                    notes?: string;
                    products?: string;
                    sector?: string;
                    shop_url?: string;
                    social_urls?: string[];
                    value_proposition?: string;
                    website?: string;
                };
                prompt: string;
                publications: (
                    | string
                    | {
                        _id: string;
                        creation_date: string;
                        engagement_base?: "reach"
                        | "impressions"
                        | "followers";
                        external_identifier?: string;
                        files: {
                            _id: string;
                            cover_image?: { _id: string; cover_image?: ...; cover_offset?: number; creation_date: string; file_externals: { external_identifier: string; external_url: string; social_network: "facebook" | "instagram" | ... 7 more ... | "discord"; }[]; ... 6 more ...; public_path: string; };
                            cover_offset?: number;
                            creation_date: string;
                            file_externals: {
                                external_identifier: string;
                                external_url: string;
                                social_network:
                                    | (...)
                                    | (...)
                                    | (...)
                                    | (...)
                                    | (...)
                                    | (...)
                                    | (...)
                                    | (...)
                                    | (...)
                                    | (...);
                            }[];
                            file_format: "mp4"
                            | "jpeg"
                            | "gif"
                            | "png"
                            | "jpg";
                            file_properties: {
                                allowed_social_networks: string[];
                                aspect_ratio: { text: string; value: number };
                                duration: number;
                                height: number;
                                size_in_bytes: number;
                                width: number;
                            };
                            file_type: "video"
                            | "image";
                            id_organization: string;
                            is_temporal: boolean;
                            name: string;
                            public_path: string;
                        }[];
                        id_account: | string
                        | {
                            _id: string;
                            creation_date: string;
                            error_code: number;
                            followers_count?: number;
                            id_client: string;
                            id_organization: string;
                            image?: string;
                            name: string;
                            next_comments_update?: string;
                            next_stats_update?: string;
                            private_message_link?: string;
                            social_network: | "facebook"
                            | "instagram"
                            | "linkedin"
                            | "tiktok"
                            | "twitter"
                            | "whatsapp"
                            | "youtube"
                            | "google_business"
                            | "bluesky"
                            | "discord";
                            username?: string;
                        };
                        id_integration?: string;
                        id_organization: string;
                        metrics?: {
                            clicks?: number;
                            comments?: number;
                            engagement?: number;
                            followers?: number;
                            followers_gained?: number;
                            impressions?: number;
                            likes?: number;
                            profile_views?: number;
                            reach?: number;
                            saves?: number;
                            shares?: number;
                            video_views?: number;
                        };
                        name?: string;
                        next_stats_update?: string;
                        publication_errors: {
                            code: number;
                            data?: { [key: string]: unknown };
                            message: string;
                        }[];
                        publication_type: | "profile"
                        | "page"
                        | "group"
                        | "reels"
                        | "stories"
                        | "message";
                        publish_date?: string;
                        retries: number;
                        social_network: | "facebook"
                        | "instagram"
                        | "linkedin"
                        | "tiktok"
                        | "twitter"
                        | "whatsapp"
                        | "youtube"
                        | "google_business"
                        | "bluesky"
                        | "discord";
                        state: "ready"
                        | "withErrors"
                        | "sended"
                        | "draft"
                        | "publishing";
                        statistics?: {
                            angers?: number;
                            bookmarks?: number;
                            clicks?: number;
                            comments?: number;
                            engagement?: number;
                            follows?: number;
                            hahas?: number;
                            impressions?: number;
                            likes?: number;
                            loves?: number;
                            negative_feedback?: number;
                            page_likes?: number;
                            playback_0_count?: number;
                            playback_100_count?: number;
                            playback_25_count?: number;
                            playback_50_count?: number;
                            playback_75_count?: number;
                            profile_activity?: number;
                            profile_visits?: number;
                            quotes?: number;
                            reach?: number;
                            replys?: number;
                            retwets?: number;
                            saved?: number;
                            share?: number;
                            shareMentions?: number;
                            shares?: number;
                            sorrys?: number;
                            url_link_clicks?: number;
                            user_profile_clicks?: number;
                            video_views?: number;
                            views?: number;
                            wows?: number;
                        };
                        stats_updated_date?: string;
                        text?: string;
                        title?: string;
                        url?: string;
                    }
                )[];
                state: | "pending"
                | "generating"
                | "generated"
                | "validated"
                | "failed"
                | "cancelled";
            },
        >,
    >

  • Cancela el plan. No lo borra: pasa a cancelled, desaparece de list y get lo sigue devolviendo.

    Parameters

    • idClient: string
    • idOrganization: string
    • idAiPlan: string
    • options: RequestOptions = {}

    Returns Promise<void>

  • Vuelve a encolar un plan failed con los mismos datos. El estado regresa a pending y hay que volver a sondear.

    Usa el contexto de marca copiado al crear el plan, no el actual: el plan es reproducible aunque alguien haya editado la configuración entretanto.

    Parameters

    • idClient: string
    • idOrganization: string
    • idAiPlan: string
    • options: RequestOptions = {}

    Returns Promise<
        {
            _id: string;
            accounts: string[];
            attempts: number;
            creation_date: string;
            credits_spent: number;
            error?: {
                code: number;
                data?: { [key: string]: unknown };
                message: string;
            };
            generation_end_date?: string;
            id_client: string;
            id_organization: string;
            keycloak_identifier?: string;
            options: {
                allow_images: boolean;
                gallery_uploads: string[];
                language: string;
                max_images?: number;
                publish_days: number[];
                shared: boolean;
                timezone: string;
                tone?: string;
                use_organization_context: boolean;
                week_start: string;
            };
            orchestrator_result?: Record<string, never>;
            organization_context?: {
                audience?: string;
                avoid?: string;
                blog_url?: string;
                brand_name?: string;
                default_tone?: string;
                description?: string;
                keywords?: string[];
                notes?: string;
                products?: string;
                sector?: string;
                shop_url?: string;
                social_urls?: string[];
                value_proposition?: string;
                website?: string;
            };
            prompt: string;
            publications: (
                | string
                | {
                    _id: string;
                    creation_date: string;
                    engagement_base?: "reach"
                    | "impressions"
                    | "followers";
                    external_identifier?: string;
                    files: {
                        _id: string;
                        cover_image?: { _id: string; cover_image?: ...; cover_offset?: number; creation_date: string; file_externals: { external_identifier: string; external_url: string; social_network: "facebook" | "instagram" | ... 7 more ... | "discord"; }[]; ... 6 more ...; public_path: string; };
                        cover_offset?: number;
                        creation_date: string;
                        file_externals: {
                            external_identifier: string;
                            external_url: string;
                            social_network:
                                | "facebook"
                                | "instagram"
                                | "linkedin"
                                | "tiktok"
                                | "twitter"
                                | "whatsapp"
                                | "youtube"
                                | "google_business"
                                | "bluesky"
                                | "discord";
                        }[];
                        file_format: "mp4"
                        | "jpeg"
                        | "gif"
                        | "png"
                        | "jpg";
                        file_properties: {
                            allowed_social_networks: string[];
                            aspect_ratio: { text: string; value: number };
                            duration: number;
                            height: number;
                            size_in_bytes: number;
                            width: number;
                        };
                        file_type: "video"
                        | "image";
                        id_organization: string;
                        is_temporal: boolean;
                        name: string;
                        public_path: string;
                    }[];
                    id_account: | string
                    | {
                        _id: string;
                        creation_date: string;
                        error_code: number;
                        followers_count?: number;
                        id_client: string;
                        id_organization: string;
                        image?: string;
                        name: string;
                        next_comments_update?: string;
                        next_stats_update?: string;
                        private_message_link?: string;
                        social_network: | "facebook"
                        | "instagram"
                        | "linkedin"
                        | "tiktok"
                        | "twitter"
                        | "whatsapp"
                        | "youtube"
                        | "google_business"
                        | "bluesky"
                        | "discord";
                        username?: string;
                    };
                    id_integration?: string;
                    id_organization: string;
                    metrics?: {
                        clicks?: number;
                        comments?: number;
                        engagement?: number;
                        followers?: number;
                        followers_gained?: number;
                        impressions?: number;
                        likes?: number;
                        profile_views?: number;
                        reach?: number;
                        saves?: number;
                        shares?: number;
                        video_views?: number;
                    };
                    name?: string;
                    next_stats_update?: string;
                    publication_errors: {
                        code: number;
                        data?: { [key: string]: unknown };
                        message: string;
                    }[];
                    publication_type: | "profile"
                    | "page"
                    | "group"
                    | "reels"
                    | "stories"
                    | "message";
                    publish_date?: string;
                    retries: number;
                    social_network: | "facebook"
                    | "instagram"
                    | "linkedin"
                    | "tiktok"
                    | "twitter"
                    | "whatsapp"
                    | "youtube"
                    | "google_business"
                    | "bluesky"
                    | "discord";
                    state: "ready"
                    | "withErrors"
                    | "sended"
                    | "draft"
                    | "publishing";
                    statistics?: {
                        angers?: number;
                        bookmarks?: number;
                        clicks?: number;
                        comments?: number;
                        engagement?: number;
                        follows?: number;
                        hahas?: number;
                        impressions?: number;
                        likes?: number;
                        loves?: number;
                        negative_feedback?: number;
                        page_likes?: number;
                        playback_0_count?: number;
                        playback_100_count?: number;
                        playback_25_count?: number;
                        playback_50_count?: number;
                        playback_75_count?: number;
                        profile_activity?: number;
                        profile_visits?: number;
                        quotes?: number;
                        reach?: number;
                        replys?: number;
                        retwets?: number;
                        saved?: number;
                        share?: number;
                        shareMentions?: number;
                        shares?: number;
                        sorrys?: number;
                        url_link_clicks?: number;
                        user_profile_clicks?: number;
                        video_views?: number;
                        views?: number;
                        wows?: number;
                    };
                    stats_updated_date?: string;
                    text?: string;
                    title?: string;
                    url?: string;
                }
            )[];
            state: | "pending"
            | "generating"
            | "generated"
            | "validated"
            | "failed"
            | "cancelled";
        },
    >

  • Acepta el plan: las drafts generadas SIN errores pasan a ready y a partir de ahí las publica el robot como cualquier publicación programada.

    Sólo desde generated (error 2102 en cualquier otro estado). Las drafts que sí tienen errores se quedan en draft: se arreglan o se borran con pv.publications.

    Parameters

    • idClient: string
    • idOrganization: string
    • idAiPlan: string
    • options: RequestOptions = {}

    Returns Promise<
        {
            _id: string;
            accounts: string[];
            attempts: number;
            creation_date: string;
            credits_spent: number;
            error?: {
                code: number;
                data?: { [key: string]: unknown };
                message: string;
            };
            generation_end_date?: string;
            id_client: string;
            id_organization: string;
            keycloak_identifier?: string;
            options: {
                allow_images: boolean;
                gallery_uploads: string[];
                language: string;
                max_images?: number;
                publish_days: number[];
                shared: boolean;
                timezone: string;
                tone?: string;
                use_organization_context: boolean;
                week_start: string;
            };
            orchestrator_result?: Record<string, never>;
            organization_context?: {
                audience?: string;
                avoid?: string;
                blog_url?: string;
                brand_name?: string;
                default_tone?: string;
                description?: string;
                keywords?: string[];
                notes?: string;
                products?: string;
                sector?: string;
                shop_url?: string;
                social_urls?: string[];
                value_proposition?: string;
                website?: string;
            };
            prompt: string;
            publications: (
                | string
                | {
                    _id: string;
                    creation_date: string;
                    engagement_base?: "reach"
                    | "impressions"
                    | "followers";
                    external_identifier?: string;
                    files: {
                        _id: string;
                        cover_image?: { _id: string; cover_image?: ...; cover_offset?: number; creation_date: string; file_externals: { external_identifier: string; external_url: string; social_network: "facebook" | "instagram" | ... 7 more ... | "discord"; }[]; ... 6 more ...; public_path: string; };
                        cover_offset?: number;
                        creation_date: string;
                        file_externals: {
                            external_identifier: string;
                            external_url: string;
                            social_network:
                                | "facebook"
                                | "instagram"
                                | "linkedin"
                                | "tiktok"
                                | "twitter"
                                | "whatsapp"
                                | "youtube"
                                | "google_business"
                                | "bluesky"
                                | "discord";
                        }[];
                        file_format: "mp4"
                        | "jpeg"
                        | "gif"
                        | "png"
                        | "jpg";
                        file_properties: {
                            allowed_social_networks: string[];
                            aspect_ratio: { text: string; value: number };
                            duration: number;
                            height: number;
                            size_in_bytes: number;
                            width: number;
                        };
                        file_type: "video"
                        | "image";
                        id_organization: string;
                        is_temporal: boolean;
                        name: string;
                        public_path: string;
                    }[];
                    id_account: | string
                    | {
                        _id: string;
                        creation_date: string;
                        error_code: number;
                        followers_count?: number;
                        id_client: string;
                        id_organization: string;
                        image?: string;
                        name: string;
                        next_comments_update?: string;
                        next_stats_update?: string;
                        private_message_link?: string;
                        social_network: | "facebook"
                        | "instagram"
                        | "linkedin"
                        | "tiktok"
                        | "twitter"
                        | "whatsapp"
                        | "youtube"
                        | "google_business"
                        | "bluesky"
                        | "discord";
                        username?: string;
                    };
                    id_integration?: string;
                    id_organization: string;
                    metrics?: {
                        clicks?: number;
                        comments?: number;
                        engagement?: number;
                        followers?: number;
                        followers_gained?: number;
                        impressions?: number;
                        likes?: number;
                        profile_views?: number;
                        reach?: number;
                        saves?: number;
                        shares?: number;
                        video_views?: number;
                    };
                    name?: string;
                    next_stats_update?: string;
                    publication_errors: {
                        code: number;
                        data?: { [key: string]: unknown };
                        message: string;
                    }[];
                    publication_type: | "profile"
                    | "page"
                    | "group"
                    | "reels"
                    | "stories"
                    | "message";
                    publish_date?: string;
                    retries: number;
                    social_network: | "facebook"
                    | "instagram"
                    | "linkedin"
                    | "tiktok"
                    | "twitter"
                    | "whatsapp"
                    | "youtube"
                    | "google_business"
                    | "bluesky"
                    | "discord";
                    state: "ready"
                    | "withErrors"
                    | "sended"
                    | "draft"
                    | "publishing";
                    statistics?: {
                        angers?: number;
                        bookmarks?: number;
                        clicks?: number;
                        comments?: number;
                        engagement?: number;
                        follows?: number;
                        hahas?: number;
                        impressions?: number;
                        likes?: number;
                        loves?: number;
                        negative_feedback?: number;
                        page_likes?: number;
                        playback_0_count?: number;
                        playback_100_count?: number;
                        playback_25_count?: number;
                        playback_50_count?: number;
                        playback_75_count?: number;
                        profile_activity?: number;
                        profile_visits?: number;
                        quotes?: number;
                        reach?: number;
                        replys?: number;
                        retwets?: number;
                        saved?: number;
                        share?: number;
                        shareMentions?: number;
                        shares?: number;
                        sorrys?: number;
                        url_link_clicks?: number;
                        user_profile_clicks?: number;
                        video_views?: number;
                        views?: number;
                        wows?: number;
                    };
                    stats_updated_date?: string;
                    text?: string;
                    title?: string;
                    url?: string;
                }
            )[];
            state: | "pending"
            | "generating"
            | "generated"
            | "validated"
            | "failed"
            | "cancelled";
        },
    >