Flow Completion

Flow Completion#

The FlowCompletion class represents an update that arrives when user completes a flow.

class pywa.types.FlowCompletion#

A flow completion message. This update arrives when a user completes a flow.

Variables:
  • id (str) – The message ID (If you want to reply to the message, use message_id_to_reply instead).

  • metadata (Metadata) – The metadata of the message (to which phone number it was sent).

  • type (MessageType) – The message type (Always MessageType.INTERACTIVE).

  • from_user (User) – The user who sent the message.

  • timestamp (datetime.datetime) – The timestamp when the message was sent.

  • reply_to_message (ReplyToMessage | None) – The message to which this message is a reply to.

  • body (str) – The body of the message.

  • token (str | None) – The token of the flow. can be None in some cases :|

  • response (dict[str, Any]) – The response from the flow.

get_media(media_cls: Type[BaseMedia], key: str) BaseMedia#

Get the media object from the response.

Example

>>> from pywa import WhatsApp, types
>>> wa = WhatsApp(...)
>>> @wa.on_flow_completion()
... def on_flow_completion(_: WhatsApp, flow: types.FlowCompletion):
...     img = flow.get_media(types.Image,key="image")
...     img.download()
Parameters:
  • media_cls – The media class to create the media object (e.g. types.Image).

  • key – The key of the media in the response.

Returns:

The media object.

Raises:

KeyError – If the key is not found in the response.