Skip to content

create_whats_app_flow

create_whats_app_flow(
    id: LinkedWhatsAppBusinessAccountId,
    flow_name: MetaFlowName,
    categories: MetaFlowCategoryList,
    *,
    config_overrides: Optional[SocialMessagingClientConfig] = None,
    flow_json: Optional[MetaFlowJsonBlob] = None,
    publish: Optional[bool] = None,
    clone_flow_id: Optional[MetaFlowId] = None,
    endpoint_uri: Optional[MetaFlowEndpointUri] = None,
) -> CreateWhatsAppFlowOutput

Creates a new WhatsApp Flow. Flows enable businesses to create rich, interactive forms and experiences that users can complete without leaving WhatsApp. The Flow is created in DRAFT status. If publish is set to true and a valid flowJson is provided, the Flow is published immediately.

Parameters:

  • id (LinkedWhatsAppBusinessAccountId) –

    The ID of the WhatsApp Business Account to associate with this Flow.

  • flow_name (MetaFlowName) –

    The name of the Flow. Must be unique within the WhatsApp Business Account.

  • categories (MetaFlowCategoryList) –

    The categories that classify the business purpose of the Flow. At least one category is required.

  • flow_json (Optional[MetaFlowJsonBlob], default: None ) –

    The Flow JSON definition that describes the screens, components, and logic of the Flow. Maximum size is 10 MB.

  • publish (Optional[bool], default: None ) –

    Set to true to publish the Flow immediately after creation. Requires a valid flowJson that passes Meta's validation.

  • clone_flow_id (Optional[MetaFlowId], default: None ) –

    The ID of an existing Flow within the same WhatsApp Business Account to clone.

  • endpoint_uri (Optional[MetaFlowEndpointUri], default: None ) –

    The HTTPS endpoint that Meta calls for a data exchange Flow.

Raises:

Source code in docs_src/capo_socialmessaging/_services/social_messaging.py
def create_whats_app_flow(
    self,
    id: "capo_socialmessaging.types.linked_whats_app_business_account_id.LinkedWhatsAppBusinessAccountId",
    flow_name: "capo_socialmessaging.types.meta_flow_name.MetaFlowName",
    categories: "capo_socialmessaging.types.meta_flow_category_list.MetaFlowCategoryList",
    *,
    config_overrides: Optional[SocialMessagingClientConfig] = None,
    flow_json: Optional[
        "capo_socialmessaging.types.meta_flow_json_blob.MetaFlowJsonBlob"
    ] = None,
    publish: Optional[bool] = None,
    clone_flow_id: Optional[
        "capo_socialmessaging.types.meta_flow_id.MetaFlowId"
    ] = None,
    endpoint_uri: Optional[
        "capo_socialmessaging.types.meta_flow_endpoint_uri.MetaFlowEndpointUri"
    ] = None,
) -> "capo_socialmessaging.types.create_whats_app_flow_output.CreateWhatsAppFlowOutput":
    """<p>Creates a new WhatsApp Flow. Flows enable businesses to create rich, interactive forms and experiences that users can complete without leaving WhatsApp. The Flow is created in DRAFT status. If <code>publish</code> is set to <code>true</code> and a valid <code>flowJson</code> is provided, the Flow is published immediately.</p>

    Args:
        id: <p>The ID of the WhatsApp Business Account to associate with this Flow.</p>
        flow_name: <p>The name of the Flow. Must be unique within the WhatsApp Business Account.</p>
        categories: <p>The categories that classify the business purpose of the Flow. At least one category is required.</p>
        flow_json: <p>The Flow JSON definition that describes the screens, components, and logic of the Flow. Maximum size is 10 MB.</p>
        publish: <p>Set to <code>true</code> to publish the Flow immediately after creation. Requires a valid <code>flowJson</code> that passes Meta's validation.</p>
        clone_flow_id: <p>The ID of an existing Flow within the same WhatsApp Business Account to clone.</p>
        endpoint_uri: <p>The HTTPS endpoint that Meta calls for a data exchange Flow.</p>

    Raises:
        capo_socialmessaging.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action.</p>
        capo_socialmessaging.errors.validation_exception.ValidationException: <p>The request contains an invalid parameter value. </p>
        capo_socialmessaging.errors.access_denied_by_meta_exception.AccessDeniedByMetaException: <p>You do not have sufficient access to perform this action.</p>
        capo_socialmessaging.errors.dependency_exception.DependencyException: <p>Thrown when performing an action because a dependency would be broken.</p>
        capo_socialmessaging.errors.internal_service_exception.InternalServiceException: <p>The request processing has failed because of an unknown error, exception, or failure.</p>
        capo_socialmessaging.errors.invalid_parameters_exception.InvalidParametersException: <p>One or more parameters provided to the action are not valid.</p>
        capo_socialmessaging.errors.resource_not_found_exception.ResourceNotFoundException: <p>The resource was not found.</p>
        capo_socialmessaging.errors.throttled_request_exception.ThrottledRequestException: <p>The request was denied due to request throttling.</p>
        capo_socialmessaging.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_socialmessaging.types.create_whats_app_flow_input.CreateWhatsAppFlowInput]",
    ) -> OperationResponse[
        "capo_socialmessaging.types.create_whats_app_flow_output.CreateWhatsAppFlowOutput"
    ]:
        import capo_socialmessaging._operations.social_messaging.create_whats_app_flow

        output, http_response = (
            capo_socialmessaging._operations.social_messaging.create_whats_app_flow.create_whats_app_flow(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateWhatsAppFlow")
    )
    input_: capo_socialmessaging.types.create_whats_app_flow_input.CreateWhatsAppFlowInput = {
        "id": id,
        "flow_name": flow_name,
        "categories": categories,
    }
    if flow_json is not None:
        input_["flow_json"] = flow_json
    if publish is not None:
        input_["publish"] = publish
    if clone_flow_id is not None:
        input_["clone_flow_id"] = clone_flow_id
    if endpoint_uri is not None:
        input_["endpoint_uri"] = endpoint_uri

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output