You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pywa/types/base_update.py
+9-6Lines changed: 9 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -48,7 +48,7 @@
48
48
SentTemplate,
49
49
SentVoiceMessage,
50
50
)
51
-
from .templatesimportBaseParams, TemplateLanguage
51
+
from .templatesimportBaseParams, Template, TemplateLanguage
52
52
53
53
54
54
classStopHandling(Exception):
@@ -1052,10 +1052,11 @@ def reply_products(
1052
1052
1053
1053
defreply_template(
1054
1054
self,
1055
-
name: str,
1056
-
language: TemplateLanguage,
1057
-
params: list[BaseParams],
1055
+
name: str|None=None,
1056
+
language: TemplateLanguage|None=None,
1057
+
params: list[BaseParams|dict] |None=None,
1058
1058
*,
1059
+
template: Template|None=None,
1059
1060
use_mm_lite_api: bool=False,
1060
1061
message_activity_sharing: bool|None=None,
1061
1062
quote: bool=False,
@@ -1070,8 +1071,9 @@ def reply_template(
1070
1071
- Read more about `Template Messages <https://developers.facebook.com/docs/whatsapp/cloud-api/guides/send-message-templates>`_.
1071
1072
1072
1073
Args:
1073
-
name: The name of the template to send.
1074
-
language: The language of the template to send.
1074
+
name: The name of the template to send (optional when ``template`` is provided).
1075
+
language: The language of the template to send (optional when ``template`` is provided).
1076
+
template: The template object to validate the parameters against (optional, if not provided, ``name`` and ``language`` must be provided).
1075
1077
params: The parameters to fill in the template.
1076
1078
use_mm_lite_api: Whether to use `Marketing Messages Lite API <https://developers.facebook.com/docs/whatsapp/marketing-messages-lite-api>`_ (optional, default: False).
1077
1079
message_activity_sharing: Whether to share message activities (e.g. message read) for that specific marketing message to Meta to help optimize marketing messages (optional, only if ``use_mm_lite_api`` is True).
Copy file name to clipboardExpand all lines: pywa/types/templates.py
+50-11Lines changed: 50 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -94,8 +94,7 @@
94
94
from .othersimportProductsSection, Result, SuccessResult, _ItemFactory
95
95
96
96
ifTYPE_CHECKING:
97
-
frompywaimportfiltersaspywa_filters
98
-
97
+
from .. importfiltersaspywa_filters
99
98
from ..clientimportWhatsApp
100
99
from .sent_updateimportSentTemplate
101
100
@@ -740,6 +739,12 @@ class TemplateLanguage(utils.StrEnum):
740
739
AFRIKAANS="af"
741
740
ALBANIAN="sq"
742
741
ARABIC="ar"
742
+
ARABIC_EG="ar_EG"
743
+
ARABIC_AE="ar_AE"
744
+
ARABIC_LB="ar_LB"
745
+
ARABIC_MA="ar_MA"
746
+
ARABIC_QA="ar_QA"
747
+
ARABIC_SA="ar_SA"
743
748
AZERBAIJANI="az"
744
749
BENGALI="bn"
745
750
BULGARIAN="bg"
@@ -754,10 +759,15 @@ class TemplateLanguage(utils.StrEnum):
754
759
ENGLISH="en"
755
760
ENGLISH_UK="en_GB"
756
761
ENGLISH_US="en_US"
762
+
ENGLISH_AU="en_AU"
763
+
ENGLISH_CA="en_CA"
764
+
ENGLISH_IN="en_IN"
757
765
ESTONIAN="et"
758
766
FILIPINO="fil"
759
767
FINNISH="fi"
760
768
FRENCH="fr"
769
+
FRENCH_CA="fr_CA"
770
+
FRENCH_BE="fr_BE"
761
771
GEORGIAN="ka"
762
772
GERMAN="de"
763
773
GREEK="el"
@@ -797,6 +807,10 @@ class TemplateLanguage(utils.StrEnum):
797
807
SPANISH_ARG="es_AR"
798
808
SPANISH_SPA="es_ES"
799
809
SPANISH_MEX="es_MX"
810
+
SPANISH_CL="es_CL"
811
+
SPANISH_CO="es_CO"
812
+
SPANISH_PE="es_PE"
813
+
SPANISH_VE="es_VE"
800
814
SWAHILI="sw"
801
815
SWEDISH="sv"
802
816
TAMIL="ta"
@@ -847,6 +861,7 @@ class CreativeFeaturesSpec:
847
861
image_background_gen: Whether to generate backgrounds for images. Read more at `developers.facebook.com <https://developers.facebook.com/docs/whatsapp/marketing-messages-lite-api/sending-messages#image-background-generation>`_.
848
862
text_extraction_for_headline: Whether to extract text from images for headlines. Read more at `developers.facebook.com <https://developers.facebook.com/docs/whatsapp/marketing-messages-lite-api/sending-messages#headline-extraction>`_.
849
863
text_extraction_for_tap_target: Whether to extract text from images for tap targets. Read more at `developers.facebook.com <https://developers.facebook.com/docs/whatsapp/marketing-messages-lite-api/sending-messages#tap-target-title-extraction>`_.
864
+
auto_promotion_tag: Whether to automatically extract the promotion tag, like “30% off”, “50% discount”, “Free shipping” from messages to create a promotion tag and put it into the image to highlight promotion information. Read more at `developers.facebook.com <https://developers.facebook.com/documentation/business-messaging/whatsapp/marketing-messages/send-marketing-messages#auto-promotion-tag>`_.
850
865
"""
851
866
852
867
image_brightness_and_contrast: bool
@@ -858,8 +873,9 @@ class CreativeFeaturesSpec:
858
873
text_extraction_for_tap_target: bool
859
874
product_extensions: bool
860
875
text_formatting_optimization: bool
876
+
auto_promotion_tag: bool
861
877
862
-
_fields={
878
+
__slots__=(
863
879
"image_brightness_and_contrast",
864
880
"image_touchups",
865
881
"add_text_overlay",
@@ -869,7 +885,8 @@ class CreativeFeaturesSpec:
869
885
"text_extraction_for_tap_target",
870
886
"product_extensions",
871
887
"text_formatting_optimization",
872
-
}
888
+
"auto_promotion_tag",
889
+
)
873
890
874
891
def__init__(
875
892
self,
@@ -883,6 +900,7 @@ def __init__(
883
900
text_extraction_for_tap_target: bool|None=None,
884
901
product_extensions: bool|None=None,
885
902
text_formatting_optimization: bool|None=None,
903
+
auto_promotion_tag: bool|None=None,
886
904
):
887
905
"""
888
906
Initializes a CreativeFeaturesSpec instance.
@@ -897,25 +915,36 @@ def __init__(
897
915
text_extraction_for_tap_target: Whether to extract keywords or phrases from your message to create a title for the tap-target area to highlight key information. Read more at `developers.facebook.com <https://developers.facebook.com/docs/whatsapp/marketing-messages-lite-api/sending-messages#tap-target-title-extraction>`_.
898
916
product_extensions: Whether to encourage users to explore more products by appending additional catalog products to single-image creatives. Read more at `developers.facebook.com <https://developers.facebook.com/documentation/business-messaging/whatsapp/marketing-messages/send-marketing-messages#product-extensions>`_.
899
917
text_formatting_optimization: Whether to update the formatting of text (e.g. remove unnecessary spaces, bold phrases) to increase performance. No text content is changed - format only. Read more at `developers.facebook.com <https://developers.facebook.com/documentation/business-messaging/whatsapp/marketing-messages/send-marketing-messages#text-formatting>`_.
918
+
auto_promotion_tag: Whether to automatically extract the promotion tag, like “30% off”, “50% discount”, “Free shipping” from messages to create a promotion tag and put it into the image to highlight promotion information. Read more at `developers.facebook.com <https://developers.facebook.com/documentation/business-messaging/whatsapp/marketing-messages/send-marketing-messages#auto-promotion-tag>`_.
frompywa.types.base_updateimport*# noqa MUST BE IMPORTED FIRST
10
-
frompywa.types.templatesimportBaseParams
11
10
12
11
from .othersimportContact, ProductsSection, SuccessResult, User
13
12
@@ -34,7 +33,7 @@
34
33
SentTemplate,
35
34
SentVoiceMessage,
36
35
)
37
-
from .templatesimportTemplateLanguage
36
+
from .templatesimportBaseParams, Template, TemplateLanguage
38
37
39
38
40
39
class_ClientShortcutsAsync:
@@ -884,10 +883,11 @@ async def reply_products(
884
883
885
884
asyncdefreply_template(
886
885
self,
887
-
name: str,
888
-
language: TemplateLanguage,
889
-
params: list[BaseParams],
886
+
name: str|None=None,
887
+
language: TemplateLanguage|None=None,
888
+
params: list[BaseParams|dict] |None=None,
890
889
*,
890
+
template: Template|None=None,
891
891
use_mm_lite_api: bool=False,
892
892
message_activity_sharing: bool|None=None,
893
893
quote: bool=False,
@@ -902,8 +902,9 @@ async def reply_template(
902
902
- Read more about `Template Messages <https://developers.facebook.com/docs/whatsapp/cloud-api/guides/send-message-templates>`_.
903
903
904
904
Args:
905
-
name: The name of the template to send.
906
-
language: The language of the template to send.
905
+
name: The name of the template to send (optional when ``template`` is provided).
906
+
language: The language of the template to send (optional when ``template`` is provided).
907
+
template: The template object to validate the parameters against (optional, if not provided, ``name`` and ``language`` must be provided).
907
908
params: The parameters to fill in the template.
908
909
use_mm_lite_api: Whether to use `Marketing Messages Lite API <https://developers.facebook.com/docs/whatsapp/marketing-messages-lite-api>`_ (optional, default: False).
909
910
message_activity_sharing: Whether to share message activities (e.g. message read) for that specific marketing message to Meta to help optimize marketing messages (optional, only if ``use_mm_lite_api`` is True).
0 commit comments