Template Examples#
Tip
This page contains examples of template messages.
You can find the code in the tests/data/templates directory of the repository.
Example of a template with buttons#
1from pywa.types.templates import * # noqa: F403
2
3seasonal_promotion = Template(
4 name="seasonal_promotion",
5 language=TemplateLanguage.ENGLISH_US,
6 category=TemplateCategory.MARKETING,
7 components=[
8 HeaderText(
9 "Our {{1}} is on!",
10 "Summer Sale",
11 ),
12 BodyText(
13 "Shop now through {{1}} and use code {{2}} to get {{3}} off of all merchandise.",
14 "the end of August",
15 "25OFF",
16 "25%",
17 ),
18 FooterText(text="Use the buttons below to manage your MARKETING subscriptions"),
19 Buttons(
20 buttons=[
21 QuickReplyButton(text="Unsubscribe from Promos"),
22 QuickReplyButton(text="Unsubscribe from All"),
23 ]
24 ),
25 ],
26)
27
28order_confirmation = Template(
29 name="order_confirmation",
30 language=TemplateLanguage.ENGLISH_US,
31 category=TemplateCategory.UTILITY,
32 components=[
33 HeaderDocument(
34 example="4::YX...",
35 ),
36 BodyText(
37 "Thank you for your order, {{1}}! Your order number is {{2}}. Tap the PDF linked above to view your receipt. If you have any questions, please use the buttons below to contact support. Thank you for being a customer!",
38 "Pablo",
39 "860198-230332",
40 ),
41 Buttons(
42 buttons=[
43 PhoneNumberButton(text="Call", phone_number="15550051310"),
44 URLButton(
45 text="Contact Support", url="https://www.luckyshrub.com/support"
46 ),
47 ]
48 ),
49 ],
50)
51
52order_delivery_update = Template(
53 name="order_delivery_update",
54 language=TemplateLanguage.ENGLISH_US,
55 category=TemplateCategory.UTILITY,
56 components=[
57 HeaderLocation(),
58 BodyText(
59 "Good news {{1}}! Your order #{{2}} is on its way to the location above. Thank you for your order!",
60 "Mark",
61 "566701",
62 ),
63 FooterText(text="To stop receiving delivery updates, tap the button below."),
64 Buttons(
65 buttons=[
66 QuickReplyButton(text="Stop Delivery Updates"),
67 ]
68 ),
69 ],
70)
71
72abandoned_cart_offer = Template(
73 name="abandoned_cart_offer",
74 language=TemplateLanguage.ENGLISH_US,
75 category=TemplateCategory.MARKETING,
76 components=[
77 HeaderProduct(),
78 BodyText(
79 "Use code {{1}} to get {{2}} off our newest succulent!", "25OFF", "25%"
80 ),
81 FooterText(text="Offer ends September 30, 2024"),
82 Buttons(
83 buttons=[
84 SPMButton(text="View"),
85 ]
86 ),
87 ],
88)
89
90intro_catalog_offer = Template(
91 name="intro_catalog_offer",
92 language=TemplateLanguage.ENGLISH_US,
93 category=TemplateCategory.MARKETING,
94 components=[
95 BodyText(
96 "Now shop for your favourite products right here on WhatsApp! Get Rs {{1}} off on all orders above {{2}}Rs! Valid for your first {{3}} orders placed on WhatsApp!",
97 "100",
98 "400",
99 "3",
100 ),
101 FooterText(text="Best grocery deals on WhatsApp!"),
102 Buttons(
103 buttons=[
104 CatalogButton(text="View catalog"),
105 ]
106 ),
107 ],
108)
109
110coupon_code_fall2023_25off = Template(
111 name="coupon_code_fall2023_25off",
112 language=TemplateLanguage.ENGLISH_US,
113 category=TemplateCategory.MARKETING,
114 components=[
115 HeaderText(text="Our Fall Sale is on!"),
116 BodyText(
117 "Shop now through November and use code {{1}} to get {{2}} off of all merchandise!",
118 "25OFF",
119 "25%",
120 ),
121 Buttons(
122 buttons=[
123 QuickReplyButton(text="Unsubscribe"),
124 CopyCodeButton(example="250FF"),
125 ]
126 ),
127 ],
128)
129
130abandoned_cart = Template(
131 name="abandoned_cart",
132 language=TemplateLanguage.ENGLISH_US,
133 category=TemplateCategory.MARKETING,
134 components=[
135 HeaderText(
136 "Forget something, {{1}}?",
137 "Pablo",
138 ),
139 BodyText(
140 "Looks like you left these items in your cart, still interested? Use code {{1}} to get 10% off!",
141 "10OFF",
142 ),
143 Buttons(buttons=[MPMButton(text="View items")]),
144 ],
145)
Example of authentication templates#
1from pywa.types.templates import * # noqa: F403
2
3authentication_code_autofill_button = Template(
4 name="authentication_code_autofill_button",
5 language=TemplateLanguage.ENGLISH_US,
6 category=TemplateCategory.AUTHENTICATION,
7 message_send_ttl_seconds=60,
8 components=[
9 AuthenticationBody(add_security_recommendation=True),
10 AuthenticationFooter(code_expiration_minutes=10),
11 Buttons(
12 buttons=[
13 OneTapOTPButton(
14 text="Copy Code",
15 autofill_text="Autofill",
16 supported_apps=[
17 OTPSupportedApp(
18 package_name="com.example.luckyshrub",
19 signature_hash="K8a/AINcGX7",
20 ),
21 OTPSupportedApp(
22 package_name="com.example.luckyshrub",
23 signature_hash="K8a/AINcGX7",
24 ),
25 ],
26 )
27 ]
28 ),
29 ],
30)
31
32authentication_code_copy_code_button = Template(
33 name="authentication_code_copy_code_button",
34 language=TemplateLanguage.ENGLISH_US,
35 category=TemplateCategory.AUTHENTICATION,
36 message_send_ttl_seconds=60,
37 components=[
38 AuthenticationBody(add_security_recommendation=True),
39 AuthenticationFooter(code_expiration_minutes=5),
40 Buttons(
41 buttons=[
42 CopyCodeOTPButton(
43 text="Copy Code",
44 )
45 ]
46 ),
47 ],
48)
49
50zero_tap_auth_template = Template(
51 name="zero_tap_auth_template",
52 language=TemplateLanguage.ENGLISH_US,
53 category=TemplateCategory.AUTHENTICATION,
54 message_send_ttl_seconds=60,
55 components=[
56 AuthenticationBody(add_security_recommendation=True),
57 AuthenticationFooter(code_expiration_minutes=5),
58 Buttons(
59 buttons=[
60 ZeroTapOTPButton(
61 text="Copy Code",
62 autofill_text="Autofill",
63 zero_tap_terms_accepted=True,
64 supported_apps=[
65 OTPSupportedApp(
66 package_name="com.example.luckyshrub",
67 signature_hash="K8a/AINcGX7",
68 ),
69 ],
70 )
71 ]
72 ),
73 ],
74)
Example of a carousel template#
1from pywa.types.templates import * # noqa: F403
2
3carousel_template_media_cards_v1 = Template(
4 name="carousel_template_media_cards_v1",
5 language=TemplateLanguage.ENGLISH_US,
6 category=TemplateCategory.MARKETING,
7 components=[
8 BodyText(
9 "Rare succulents for sale! {{1}}, add these unique plants to your collection. Each of these rare succulents are {{2}} if you checkout using code {{3}}. Shop now and add some unique and beautiful plants to your collection!",
10 "Pablo",
11 "30%",
12 "30OFF",
13 ),
14 Carousel(
15 cards=[
16 CarouselCard(
17 components=[
18 HeaderImage(example="4::an..."),
19 BodyText(
20 text="Add a touch of elegance to your collection with the beautiful Aloe 'Blue Elf' succulent. Its deep blue-green leaves have a hint of pink around the edges."
21 ),
22 Buttons(
23 buttons=[
24 QuickReplyButton(text="Send me more like this!"),
25 URLButton(
26 text="Shop",
27 url="https://www.luckyshrub.com/rare-succulents/{{1}}",
28 example="BLUE_ELF",
29 ),
30 ]
31 ),
32 ]
33 ),
34 CarouselCard(
35 components=[
36 HeaderImage(example="4::an..."),
37 BodyText(
38 text="The Crassula Buddha's Temple is sure to be a conversation starter with its tiny temple shaped leaves, intricate details, and lacy texture."
39 ),
40 Buttons(
41 buttons=[
42 QuickReplyButton(text="Send me more like this!"),
43 URLButton(
44 text="Shop",
45 url="https://www.luckyshrub.com/rare-succulents/{{1}}",
46 example="BUDDHA",
47 ),
48 ]
49 ),
50 ]
51 ),
52 CarouselCard(
53 components=[
54 HeaderImage(example="4::an..."),
55 BodyText(
56 text="The Echeveria 'Black Prince' is a stunning succulent, with near-black leaves, adorned with a hint of green around the edges, giving it its striking appearance."
57 ),
58 Buttons(
59 buttons=[
60 QuickReplyButton(text="Send me more like this!"),
61 URLButton(
62 text="Shop",
63 url="https://www.luckyshrub.com/rare-succulents/{{1}}",
64 example="BLACK_PRINCE",
65 ),
66 ]
67 ),
68 ]
69 ),
70 ]
71 ),
72 ],
73)
74
75
76carousel_template_product_cards_v1 = Template(
77 name="carousel_template_product_cards_v1",
78 language=TemplateLanguage.ENGLISH_US,
79 category=TemplateCategory.MARKETING,
80 components=[
81 BodyText(
82 "Rare succulents for sale! {{1}}, add these unique plants to your collection. All three of these rare succulents are available for purchase on our website, and they come with a 100% satisfaction guarantee. Whether you're a seasoned succulent enthusiast or just starting your plant collection, these rare succulents are sure to impress. Shop now and add some unique and beautiful plants to your collection!",
83 "Pablo",
84 ),
85 Carousel(
86 cards=[
87 CarouselCard(
88 components=[
89 HeaderProduct(),
90 Buttons(buttons=[SPMButton(text="View")]),
91 ]
92 ),
93 CarouselCard(
94 components=[
95 HeaderProduct(),
96 Buttons(buttons=[SPMButton(text="View")]),
97 ]
98 ),
99 ]
100 ),
101 ],
102)
Example of a limited time offer template#
1from pywa.types.templates import * # noqa: F403
2
3limited_time_offer_caribbean_pkg_2023 = Template(
4 name="limited_time_offer_caribbean_pkg_2023",
5 language=TemplateLanguage.ENGLISH_US,
6 category=TemplateCategory.MARKETING,
7 components=[
8 HeaderImage(example="4::aW..."),
9 LimitedTimeOffer(text="Expiring offer!", has_expiration=True),
10 BodyText(
11 "Good news, {{1}}! Use code {{2}} to get 25% off all Caribbean Destination packages!",
12 "Pablo",
13 "CARIBE25",
14 ),
15 Buttons(
16 buttons=[
17 CopyCodeButton(example="CARIBE25"),
18 URLButton(
19 text="Book now!",
20 url="https://awesomedestinations.com/offers?code={{1}}",
21 example="https://awesomedestinations.com/offers?ref=n3mtql",
22 ),
23 ]
24 ),
25 ],
26)