createWhatsAppFlow method

Future<CreateWhatsAppFlowOutput> createWhatsAppFlow({
  1. required List<MetaFlowCategory> categories,
  2. required String flowName,
  3. required String id,
  4. String? cloneFlowId,
  5. Uint8List? flowJson,
  6. bool? publish,
})

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.

May throw AccessDeniedByMetaException. May throw DependencyException. May throw InternalServiceException. May throw InvalidParametersException. May throw ResourceNotFoundException. May throw ThrottledRequestException.

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

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

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

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

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

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

Implementation

Future<CreateWhatsAppFlowOutput> createWhatsAppFlow({
  required List<MetaFlowCategory> categories,
  required String flowName,
  required String id,
  String? cloneFlowId,
  Uint8List? flowJson,
  bool? publish,
}) async {
  final $payload = <String, dynamic>{
    'categories': categories.map((e) => e.value).toList(),
    'flowName': flowName,
    'id': id,
    if (cloneFlowId != null) 'cloneFlowId': cloneFlowId,
    if (flowJson != null) 'flowJson': base64Encode(flowJson),
    if (publish != null) 'publish': publish,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/v1/whatsapp/flow/create',
    exceptionFnMap: _exceptionFns,
  );
  return CreateWhatsAppFlowOutput.fromJson(response);
}