Flow JSON#
Here you will find all the components that make up a Flow JSON object.
- class pywa.types.flows.FlowJSON#
Represents a WhatsApp Flow JSON.
Read more at developers.facebook.com.
- Variables:
screens (Iterable[pywa.types.flows.Screen]) β
The screens of the flow (Read more at developers.facebook.com).
version (str | float | Literal[<Version.FLOW_JSON: '3.1'>]) β
The Flow JSON version. Default to latest (Read more at developers.facebook.com).
data_api_version (str | float | Literal[<Version.FLOW_DATA_API: '3.0'>] | None) β The version to use during communication with the WhatsApp Flows Data Endpoint. Use
utils.Version.FLOW_DATA_API
to get the latest versionrouting_model (dict[str, Iterable[str]] | None) β
Defines the rules for the screen by limiting the possible state transition. (Read more at developers.facebook.com).
data_channel_uri (str | None) β The endpoint to use to communicate with your server (When using v3.0 or higher, this field need to be set via
WhatsApp.update_flow_metadata()
).
- class pywa.types.flows.Screen#
Represents a screen (page) in a WhatsApp flow.
The maximum number of components (children) per screen is 50.
Read more at developers.facebook.com.
Example
>>> from pywa.types.flows import Screen >>> screen = Screen( ... id='START', ... title='Welcome', ... data=[ScreenData(key='welcome', example='Welcome to my store!')], ... terminal=True, ... layout=Layout(children=[Form(children=[...])]), ... refresh_on_back=True ... )
- Variables:
id (str) β Unique identifier of the screen for navigation purposes.
SUCCESS
is a reserved keyword and should not be used as a screen id.title (str | None) β Screen level attribute that is rendered in the top navigation bar.
data (Iterable[pywa.types.flows.ScreenData] | dict[str, dict] | None) β Declaration of dynamic data that this screen should get from the previous screen or from the data endpoint. In the screen children and in
Action
.payload
, you can use the.data_key
orDataKey
to reference this data.terminal (bool | None) β Each Flow should have a terminal state where we terminate the experience and have the Flow completed. Multiple screens can be marked as terminal. Itβs mandatory to have a
Footer
on the terminal screen.refresh_on_back (bool | None) β
Whether to trigger a data exchange request with the data endpoint when the user presses the back button while on this screen (Read more at developers.facebook.com).
layout (pywa.types.flows.Layout) β
Associated screen UI Layout that is shown to the user (Read more at developers.facebook.com).
success (bool | None) β To indicate whether terminating on that screen results in a successful flow completion.
- class pywa.types.flows.ScreenData#
Represents a screen data that a screen should get from the previous screen or from the data endpoint.
You can use the
.data_key
property or theDataKey
to reference this data in the screen children or in the action payloads.Read more at developers.facebook.com.
Example
>>> from pywa.types.flows import ScreenData >>> dynamic_welcome = ScreenData(key='welcome', example='Welcome to my store!') >>> is_email_required = ScreenData(key='is_email_required', example=False) >>> screen = Screen( ... id='START', ... data=[dynamic_welcome, is_email_required], ... layout=Layout(children=[Form(children=[ ... TextHeading(text=dynamic_welcome.data_key, ...), ... TextInput(required=is_email_required.data_key, input_type=InputType.EMAIL, ...) ... ])]) ... )
- Variables:
key (str) β The key of the data (To use later in the screen children with
.data_key
or withDataKey
).example (str | int | float | bool | dict | pywa.types.flows.DataSource | Iterable[str | int | float | bool | dict | pywa.types.flows.DataSource]) β The example of the data that the screen should get from the previous screen or from the data endpoint (or the previous screen).
- class pywa.types.flows.Layout#
Layout is the top level component that holds the other components.
Read more at developers.facebook.com.
- Variables:
type (pywa.types.flows.LayoutType) β The type of layout that is used to display the components (Default:
LayoutType.SINGLE_COLUMN
).children (Iterable[pywa.types.flows.Form | pywa.types.flows.TextHeading | pywa.types.flows.TextSubheading | pywa.types.flows.TextBody | pywa.types.flows.TextCaption | pywa.types.flows.EmbeddedLink | pywa.types.flows.Image | pywa.types.flows.Footer | dict[str, Any]]) β The components that are part of the layout.
- class pywa.types.flows.LayoutType#
- The type of layout that is used to display the components.
Currently, only
LayoutType.SINGLE_COLUMN
is supported.
- Variables:
SINGLE_COLUMN β A single column layout.
- class pywa.types.flows.Form#
The form component is a container for other components that collects user input.
The following components must be inside Form:
TextInput
,TextArea
,CheckboxGroup
,RadioButtonsGroup
,OptIn
,Dropdown
andDatePicker
.Read more at developers.facebook.com.
- Variables:
name (str) β The name of the form (the convention is to use
"form"
).children (Iterable[pywa.types.flows.TextHeading | pywa.types.flows.TextSubheading | pywa.types.flows.TextBody | pywa.types.flows.TextCaption | pywa.types.flows.TextInput | pywa.types.flows.TextArea | pywa.types.flows.CheckboxGroup | pywa.types.flows.RadioButtonsGroup | pywa.types.flows.OptIn | pywa.types.flows.Dropdown | pywa.types.flows.DatePicker | pywa.types.flows.EmbeddedLink | pywa.types.flows.Image | pywa.types.flows.Footer | dict[str, Any]]) β The components that are part of the form.
init_values (dict[str, Any] | str | pywa.types.flows.DataKey | None) β
The initial values of the form (you can use
.init_value
property of each component to set the initial value instead of setting this attribute. Read more at developers.facebook.com).error_messages (dict[str, str] | str | pywa.types.flows.DataKey | None) β
The error messages of the form (you can use
.error_message
property of each component to set the error message instead of setting this attribute. Read more at developers.facebook.com).
- class pywa.types.flows.TextHeading#
Represents text that is displayed as a heading.
Read more at developers.facebook.com.
Example
>>> from pywa.types.flows import TextHeading >>> heading = TextHeading(text='Heading', visible=True)
- Variables:
text (str | pywa.types.flows.DataKey) β The text of the heading. Limited to 4096 characters. Can be dynamic.
visible (bool | str | pywa.types.flows.DataKey | None) β Whether the heading is visible or not. Default to
True
, Can be dynamic.
- class pywa.types.flows.TextSubheading#
Represents text that is displayed as a subheading.
Read more at developers.facebook.com.
Example
>>> from pywa.types.flows import TextSubheading >>> subheading = TextSubheading(text='Subheading', visible=True)
- Variables:
text (str | pywa.types.flows.DataKey) β The text of the subheading. Limited to 60 characters. Can be dynamic.
visible (bool | str | pywa.types.flows.DataKey | None) β Whether the subheading is visible or not. Default to
True
, Can be dynamic.
- class pywa.types.flows.TextBody#
Represents text that is displayed as a body.
Read more at developers.facebook.com.
Example
>>> from pywa.types.flows import TextBody, FontWeight >>> body = TextBody( ... text='Body', ... font_weight=FontWeight.BOLD, ... visible=True ... )
- Variables:
text (str | pywa.types.flows.DataKey) β The text of the body. Limited to 80 characters. Can be dynamic.
font_weight (pywa.types.flows.FontWeight | str | pywa.types.flows.DataKey | None) β The weight of the text. Can be dynamic.
strikethrough (bool | str | pywa.types.flows.DataKey | None) β Whether the text is strikethrough or not. Can be dynamic.
visible (bool | str | pywa.types.flows.DataKey | None) β Whether the body is visible or not. Default to
True
, Can be dynamic.
- class pywa.types.flows.TextCaption#
Represents text that is displayed as a caption.
Read more at developers.facebook.com.
Example
>>> from pywa.types.flows import TextCaption, FontWeight >>> caption = TextCaption( ... text='Caption', ... font_weight=FontWeight.ITALIC, ... strikethrough=True, ... )
- Variables:
text (str | pywa.types.flows.DataKey) β The text of the caption. Limited to 4096 characters. Can be dynamic.
font_weight (pywa.types.flows.FontWeight | str | pywa.types.flows.DataKey | None) β The weight of the text. Can be dynamic.
strikethrough (bool | str | pywa.types.flows.DataKey | None) β Whether to strike through the text or not. Can be dynamic.
visible (bool | str | pywa.types.flows.DataKey | None) β Whether the caption is visible or not. Default to
True
, Can be dynamic.
- class pywa.types.flows.FontWeight#
The text weight
- Variables:
BOLD β Bold text
ITALIC β Italic text
BOLD_ITALIC β Bold and italic text
NORMAL β Normal text
- class pywa.types.flows.TextInput#
Represents a text entry component that allows for a single line of text.
This component must be inside a
Form
.Read more at developers.facebook.com.
Example
>>> from pywa.types.flows import TextInput, InputType >>> text_input = TextInput( ... name='email', ... label='Email', ... input_type=InputType.EMAIL, ... required=True, ... min_chars=5, ... max_chars=50, ... helper_text='Enter your email address', ... )
- Variables:
name (str) β The unique name (id) for this component (to be used dynamically or in action payloads).
label (str | pywa.types.flows.DataKey) β The label of the text input. Limited to 20 characters. Can be dynamic.
input_type (pywa.types.flows.InputType | str | pywa.types.flows.DataKey | None) β The input type of the text input (for keyboard layout and validation rules). Can be dynamic.
required (bool | str | pywa.types.flows.DataKey | None) β Whether the text input is required or not. Can be dynamic.
min_chars (int | str | pywa.types.flows.DataKey | None) β The minimum number of characters allowed in the text input. Can be dynamic.
max_chars (int | str | pywa.types.flows.DataKey | None) β The maximum number of characters allowed in the text input. Can be dynamic.
helper_text (str | pywa.types.flows.DataKey | None) β The helper text of the text input. Limited to 80 characters. Can be dynamic.
enabled (bool | str | pywa.types.flows.DataKey | None) β Whether the text input is enabled or not. Default to
True
. Can be dynamic.visible (bool | str | pywa.types.flows.DataKey | None) β Whether the text input is visible or not. Default to
True
. Can be dynamic.init_value (str | pywa.types.flows.DataKey | None) β The default value of the text input. Shortcut for
init_values
of the parentForm
. Can be dynamic.error_message (str | pywa.types.flows.DataKey | None) β The error message of the text input. Shortcuts for
error_messages
of the parentForm
. Can be dynamic.
- class pywa.types.flows.InputType#
The input type of the text entry component.
This is used by the WhatsApp client to determine the keyboard layout and validation rules.
- Variables:
TEXT β A single line of text (for multi-line text use
TextArea
).NUMBER β A number (keyboard layout is numeric, with a decimal separator).
EMAIL β An email address (keyboard layout is alphanumeric, with a special character for the @ symbol).
PASSWORD β A password (the input is masked).
PASSCODE β A passcode (keyboard layout is numeric, the input is masked).
PHONE β A phone number (keyboard layout is numeric, with a special character for the + symbol).
- class pywa.types.flows.TextArea#
Represents a text entry component that allows for multiple lines of text.
This component must be inside a
Form
.Read more at developers.facebook.com.
Example
>>> from pywa.types.flows import TextArea >>> text_area = TextArea( ... name='description', ... label='Description', ... required=True, ... max_length=100, ... helper_text='Enter your description', ... )
- Variables:
name (str) β The unique name (id) for this component (to be used dynamically or in action payloads).
label (str | pywa.types.flows.DataKey) β The label of the text area. Limited to 20 characters. Can be dynamic.
required (bool | str | pywa.types.flows.DataKey | None) β Whether the text area is required or not. Can be dynamic.
max_length (int | str | pywa.types.flows.DataKey | None) β The maximum number of characters allowed in the text area. Can be dynamic.
helper_text (str | pywa.types.flows.DataKey | None) β The helper text of the text area. Limited to 80 characters. Can be dynamic.
enabled (bool | str | pywa.types.flows.DataKey | None) β Whether the text area is enabled or not. Default to
True
. Can be dynamic.visible (bool | str | pywa.types.flows.DataKey | None) β Whether the text area is visible or not. Default to
True
. Can be dynamic.init_value (str | pywa.types.flows.DataKey | None) β The default value of the text area. Shortcut for
init_values
of the parentForm
. Can be dynamic.error_message (str | pywa.types.flows.DataKey | None) β The error message of the text area. Shortcuts for
error_messages
of the parentForm
. Can be dynamic.
- class pywa.types.flows.CheckboxGroup#
CheckboxGroup component allows users to pick multiple selections from a list of options.
This component must be inside a
Form
.Read more at developers.facebook.com.
Example
>>> from pywa.types.flows import CheckboxGroup, DataSource >>> checkbox_group = CheckboxGroup( ... name='options', ... data_source=[ ... DataSource(id='1', title='Option 1'), ... DataSource(id='2', title='Option 2'), ... DataSource(id='3', title='Option 3'), ... ], ... label='Options', ... min_selected_items=1, ... max_selected_items=2, ... required=True, ... init_value=['1', '2'] ... )
- Variables:
name (str) β The unique name (id) for this component (to be used dynamically or in action payloads).
data_source (Iterable[pywa.types.flows.DataSource] | str | pywa.types.flows.DataKey) β The data source of the checkbox group. Can be dynamic.
label (str | pywa.types.flows.DataKey | None) β The label of the checkbox group. Limited to 30 characters. Can be dynamic.
min_selected_items (int | str | pywa.types.flows.DataKey | None) β The minimum number of items that can be selected. Minimum value is 1. Can be dynamic.
max_selected_items (int | str | pywa.types.flows.DataKey | None) β The maximum number of items that can be selected. Maximum value is 20. Can be dynamic.
required (bool | str | pywa.types.flows.DataKey | None) β Whether the checkbox group is required or not. Can be dynamic.
visible (bool | str | pywa.types.flows.DataKey | None) β Whether the checkbox group is visible or not. Default to
True
. Can be dynamic.enabled (bool | str | pywa.types.flows.DataKey | None) β Whether the checkbox group is enabled or not. Default to
True
. Can be dynamic.init_value (list[str] | str | pywa.types.flows.DataKey | None) β The default values (IDs of the data sources). Shortcut for
init_values
of the parentForm
. Can be dynamic.on_select_action (pywa.types.flows.Action | None) β The action to perform when an item is selected.
- class pywa.types.flows.RadioButtonsGroup#
RadioButtonsGroup component allows users to pick a single selection from a list of options.
This component must be inside a
Form
.Read more at developers.facebook.com.
Example
>>> from pywa.types.flows import RadioButtonsGroup, DataSource >>> radio_buttons_group = RadioButtonsGroup( ... name='options', ... data_source=[ ... DataSource(id='1', title='Option 1'), ... DataSource(id='2', title='Option 2'), ... DataSource(id='3', title='Option 3'), ... ], ... label='Options', ... required=True, ... init_value='1' ... )
- Variables:
name (str) β The unique name (id) for this component (to be used dynamically or in action payloads).
data_source (Iterable[pywa.types.flows.DataSource] | str | pywa.types.flows.DataKey) β The data source of the radio buttons group. Can be dynamic.
label (str | pywa.types.flows.DataKey | None) β The label of the radio buttons group. Limited to 30 characters. Can be dynamic.
required (bool | str | pywa.types.flows.DataKey | None) β Whether the radio buttons group is required or not. Can be dynamic.
visible (bool | str | pywa.types.flows.DataKey | None) β Whether the radio buttons group is visible or not. Default to
True
. Can be dynamic.enabled (bool | str | pywa.types.flows.DataKey | None) β Whether the radio buttons group is enabled or not. Default to
True
. Can be dynamic.init_value (str | pywa.types.flows.DataKey | None) β The default value (ID of the data source). Shortcut for
init_values
of the parentForm
. Can be dynamic.on_select_action (pywa.types.flows.Action | None) β The action to perform when an item is selected.
Footer component allows users to navigate to other screens or submit the flow.
Read more at developers.facebook.com.
Example
>>> from pywa.types.flows import Footer, Action, FlowActionType, ActionNext >>> submit_footer = Footer( ... label='Submit', ... on_click_action=Action( ... name=FlowActionType.COMPLETE, ... payload={'data': 'value'} ... ) ... )
>>> navigation_footer = Footer( ... label='Next', ... on_click_action=Action( ... name=FlowActionType.NAVIGATE, ... next=ActionNext(name='NEXT_SCREEN'), ... payload={'data': 'value'} ... )
- Variables:
label (str | pywa.types.flows.DataKey) β The label of the footer. Limited to 35 characters. Can be dynamic.
on_click_action (pywa.types.flows.Action) β The action to perform when the footer is clicked. Required.
left_caption (str | pywa.types.flows.DataKey | None) β Can set left_caption and right_caption or only center_caption, but not all 3 at once. Limited to 15 characters. Can be dynamic.
center_caption (str | pywa.types.flows.DataKey | None) β Can set center-caption or left-caption and right-caption, but not all 3 at once. Limited to 15 characters. Can be dynamic.
right_caption (str | pywa.types.flows.DataKey | None) β Can set right-caption and left-caption or only center-caption, but not all 3 at once. Limited to 15 characters. Can be dynamic.
enabled (bool | str | pywa.types.flows.DataKey | None) β Whether the footer is enabled or not. Default to
True
. Can be dynamic.
- class pywa.types.flows.OptIn#
OptIn component allows users to check a box to opt in for a specific purpose.
This component must be inside a
Form
.Max number of Opt-Ins Per Screen is 5.
Read more at developers.facebook.com.
Example
>>> from pywa.types.flows import OptIn >>> opt_in = OptIn( ... name='opt_in', ... label='I agree to the terms and conditions', ... required=True, ... init_value=True ... )
- Variables:
name (str) β The unique name (id) for this component (to be used dynamically or in action payloads).
label (str | pywa.types.flows.DataKey) β The label of the opt in. Limited to 30 characters. Can be dynamic.
required (bool | str | pywa.types.flows.DataKey | None) β Whether the opt in is required or not. Can be dynamic.
visible (bool | str | pywa.types.flows.DataKey | None) β Whether the opt in is visible or not. Default to
True
. Can be dynamic.init_value (bool | str | pywa.types.flows.DataKey | None) β The default value of the opt in. Shortcut for
init_values
of the parentForm
. Can be dynamic.on_click_action (pywa.types.flows.Action | None) β The action to perform when the opt in is clicked.
- class pywa.types.flows.Dropdown#
Dropdown component allows users to pick a single selection from a list of options.
This component must be inside a
Form
.Read more at developers.facebook.com.
Example
>>> from pywa.types.flows import Dropdown, DataSource >>> dropdown = Dropdown( ... name='options', ... data_source=[ ... DataSource(id='1', title='Option 1'), ... DataSource(id='2', title='Option 2'), ... DataSource(id='3', title='Option 3'), ... ], ... label='Options', ... required=True, ... init_value='1' ... )
- Variables:
name (str) β The unique name (id) for this component (to be used dynamically or in action payloads).
label (str | pywa.types.flows.DataKey) β The label of the dropdown. Limited to 30 characters. Can be dynamic.
data_source (Iterable[pywa.types.flows.DataSource] | str | pywa.types.flows.DataKey) β The data source of the dropdown. minimum 1 and maximum 200 items. Can be dynamic.
enabled (bool | str | pywa.types.flows.DataKey | None) β Whether the dropdown is enabled or not. Default to
True
. Can be dynamic.required (bool | str | pywa.types.flows.DataKey | None) β Whether the dropdown is required or not. Can be dynamic.
visible (bool | str | pywa.types.flows.DataKey | None) β Whether the dropdown is visible or not. Default to
True
. Can be dynamic.init_value (str | pywa.types.flows.DataKey | None) β The default value (ID of the data source). Shortcut for
init_values
of the parentForm
. Can be dynamic.on_select_action (pywa.types.flows.Action | None) β The action to perform when an item is selected.
- class pywa.types.flows.EmbeddedLink#
EmbeddedLink component allows users to navigate to another screen.
This component must be inside a
Form
.Max Number of Embedded Links Per Screen is 2.
Empty or Blank value is not accepted for the text field.
Read more at developers.facebook.com.
Example
>>> from pywa.types.flows import EmbeddedLink, Action, ActionNext >>> embedded_link = EmbeddedLink( ... text='Sign up', ... on_click_action=Action( ... name=FlowActionType.NAVIGATE, ... next=ActionNext(name='SIGNUP_SCREEN'), ... payload={'data': 'value'} ... ) ... )
- Variables:
text (str | pywa.types.flows.DataKey) β The text of the embedded link. Limited to 35 characters. Can be dynamic.
on_click_action (pywa.types.flows.Action) β The action to perform when the embedded link is clicked.
visible (bool | str | pywa.types.flows.DataKey | None) β Whether the embedded link is visible or not. Default to
True
. Can be dynamic.
- class pywa.types.flows.DatePicker#
DatePicker component allows users to select a date
This component must be inside a
Form
.Read more at developers.facebook.com.
Example
>>> from pywa.types.flows import DatePicker >>> date_picker = DatePicker( ... name='date', ... label='Appointment Date', ... min_date='1577829600000', ... max_date='1704060000000', ... unavailable_dates=[ ... '1609452000000', ... '1640988000000' ... ], ... helper_text='Select a date', ... required=True ... )
- Variables:
name (str) β The unique name (id) for this component (to be used dynamically or in action payloads).
label (str | pywa.types.flows.DataKey) β The label of the date picker. Limited to 40 characters. Can be dynamic.
min_date (str | pywa.types.flows.DataKey | None) β The minimum date (timestamp in ms) that can be selected. Can be dynamic.
max_date (str | pywa.types.flows.DataKey | None) β The maximum date (timestamp in ms) that can be selected. Can be dynamic.
unavailable_dates (Iterable[str] | str | pywa.types.flows.DataKey | None) β The dates (timestamp in ms) that cannot be selected. Can be dynamic.
helper_text (str | pywa.types.flows.DataKey | None) β The helper text of the date picker. Limited to 80 characters. Can be dynamic.
enabled (bool | str | pywa.types.flows.DataKey | None) β Whether the date picker is enabled or not. Default to
True
. Can be dynamic.required (bool | str | pywa.types.flows.DataKey | None) β Whether the date picker is required or not. Can be dynamic.
visible (bool | str | pywa.types.flows.DataKey | None) β Whether the date picker is visible or not. Default to
True
. Can be dynamic.init_value (str | pywa.types.flows.DataKey | None) β The default value. Shortcut for
init_values
of the parentForm
. Can be dynamic.error_message (str | pywa.types.flows.DataKey | None) β The error message of the date picker. Shortcuts for
error_messages
of the parentForm
. Can be dynamic.on_select_action (pywa.types.flows.Action | None) β The action to perform when a date is selected.
- class pywa.types.flows.Image#
Image component that displays an image.
Read more at developers.facebook.com.
Supported images formats are JPEG PNG
Recommended image size is up to 300kb
Max number of images per screen is 3
Example
>>> from pywa.types.flows import Image, ScaleType >>> image = Image( ... src='iVBORw0KGgoAAAANSUhEUgAAAlgAAAM...', ... width=100, ... height=100, ... scale_type=ScaleType.CONTAIN, ... aspect_ratio=1, ... alt_text='Image of a cat' ... )
- Variables:
src (str | pywa.types.flows.DataKey) β Base64 of an image. Can be dynamic.
width (int | str | pywa.types.flows.DataKey | None) β The width of the image. Can be dynamic.
height (int | str | pywa.types.flows.DataKey | None) β The height of the image. Can be dynamic.
scale_type (pywa.types.flows.ScaleType | str | pywa.types.flows.DataKey | None) β
The scale type of the image. Defaule to
ScaleType.CONTAIN
Can be dynamic. Read more at developers.facebook.com.aspect_ratio (int | str | pywa.types.flows.DataKey) β The aspect ratio of the image. Default to
1
. Can be dynamic.alt_text (str | pywa.types.flows.DataKey | None) β Alternative Text is for the accessibility feature, eg. Talkback and Voice over. Can be dynamic.
- class pywa.types.flows.ScaleType#
The scale type of the image.
Read more at developers.facebook.com.
- Variables:
COVER β Image is clipped to fit the image container.
CONTAIN β Image is contained within the image container with the original aspect ratio.
- class pywa.types.flows.DataSource#
The data source of a component.
Example
>>> from pywa.types.flows import DataSource >>> option_1 = DataSource(id='1', title='Option 1') >>> option_2 = DataSource(id='2', title='Option 2') >>> checkbox_group = CheckboxGroup(data_source=[option_1, option_2], ...)
- Variables:
id (str) β The ID of the data source.
title (str) β The title of the data source. Limited to 30 characters.
description (str | None) β The description of the data source. Limited to 300 characters.
metadata (str | None) β The metadata of the data source. Limited to 20 characters.
enabled (bool | None) β Whether the data source is enabled or not. Default to
True
.
- class pywa.types.flows.Action#
Action component allows users to trigger asynchronous actions that are handled by a client through interactive UI elements.
Read more at developers.facebook.com.
Example
>>> from pywa.types.flows import Action, FlowActionType, ActionNext >>> complete_action = Action( ... name=FlowActionType.COMPLETE, ... payload={'data': 'value'} ... ) >>> data_exchange_action = Action( ... name=FlowActionType.DATA_EXCHANGE, ... payload={'data': 'value'} ... ) >>> navigate_action = Action( ... name=FlowActionType.NAVIGATE, ... next=ActionNext(name='NEXT_SCREEN'), ... payload={'data': 'value'} ... )
- Variables:
name (pywa.types.flows.FlowActionType | str) β The type of the action
next (pywa.types.flows.ActionNext | None) β The next action to perform (only for
FlowActionType.NAVIGATE
)payload (dict[str, str | pywa.types.flows.DataKey | pywa.types.flows.FormRef] | None) β The payload of the action (Pass data to the next screen or to the WhatsApp Flows Data Endpoint). This payload can take data from form components or from the data of the screen.
- class pywa.types.flows.FlowActionType#
Flow JSON provides a generic way to trigger asynchronous actions handled by a client through interactive UI elements.
Read more at developers.facebook.com.
- Variables:
COMPLETE β
Triggers the termination of the Flow with the provided payload (Read more at developers.facebook.com).
DATA_EXCHANGE β
Sending Data to WhatsApp Flows Data Endpoint (Read more at developers.facebook.com).
NAVIGATE β
Triggers the next screen with the payload as its input. The CTA button will be disabled until the payload with data required for the next screen is supplied. (Read more at developers.facebook.com).
- class pywa.types.flows.ActionNext#
The next action
- Variables:
name (str) β The name of the next screen or plugin
type (pywa.types.flows.ActionNextType | str) β The type of the next action (Default:
ActionNextType.SCREEN
)
- class pywa.types.flows.ActionNextType#
The type of the next action
- Variables:
SCREEN β Navigate to the next screen
PLUGIN β Trigger a plugin
- class pywa.types.flows.DataKey#
- class pywa.types.flows.FormRef#