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 authentication templates#
Python Code#
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)
JSON Code#
1{
2 "authentication_code_autofill_button": {
3 "name": "authentication_code_autofill_button",
4 "language": "en_US",
5 "category": "AUTHENTICATION",
6 "message_send_ttl_seconds": 60,
7 "components": [
8 {
9 "type": "BODY",
10 "add_security_recommendation": true
11 },
12 {
13 "type": "FOOTER",
14 "code_expiration_minutes": 10
15 },
16 {
17 "type": "BUTTONS",
18 "buttons": [
19 {
20 "type": "OTP",
21 "otp_type": "ONE_TAP",
22 "text": "Copy Code",
23 "autofill_text": "Autofill",
24 "supported_apps": [
25 {
26 "package_name": "com.example.luckyshrub",
27 "signature_hash": "K8a/AINcGX7"
28 },
29 {
30 "package_name": "com.example.luckyshrub",
31 "signature_hash": "K8a/AINcGX7"
32 }
33 ]
34 }
35 ]
36 }
37 ]
38 },
39 "authentication_code_copy_code_button": {
40 "name": "authentication_code_copy_code_button",
41 "language": "en_US",
42 "category": "AUTHENTICATION",
43 "message_send_ttl_seconds": 60,
44 "components": [
45 {
46 "type": "BODY",
47 "add_security_recommendation": true
48 },
49 {
50 "type": "FOOTER",
51 "code_expiration_minutes": 5
52 },
53 {
54 "type": "BUTTONS",
55 "buttons": [
56 {
57 "type": "OTP",
58 "otp_type": "COPY_CODE",
59 "text": "Copy Code"
60 }
61 ]
62 }
63 ]
64 },
65 "zero_tap_auth_template": {
66 "name": "zero_tap_auth_template",
67 "language": "en_US",
68 "category": "AUTHENTICATION",
69 "message_send_ttl_seconds": 60,
70 "components": [
71 {
72 "type": "BODY",
73 "add_security_recommendation": true
74 },
75 {
76 "type": "FOOTER",
77 "code_expiration_minutes": 5
78 },
79 {
80 "type": "BUTTONS",
81 "buttons": [
82 {
83 "type": "OTP",
84 "otp_type": "ZERO_TAP",
85 "text": "Copy Code",
86 "autofill_text": "Autofill",
87 "zero_tap_terms_accepted": true,
88 "supported_apps": [
89 {
90 "package_name": "com.example.luckyshrub",
91 "signature_hash": "K8a/AINcGX7"
92 }
93 ]
94 }
95 ]
96 }
97 ]
98 }
99}
Example of a carousel template#
Python Code#
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)
JSON Code#
1{
2 "carousel_template_media_cards_v1": {
3 "name": "carousel_template_media_cards_v1",
4 "language": "en_US",
5 "category": "MARKETING",
6 "components": [
7 {
8 "type": "BODY",
9 "text": "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 "example": {
11 "body_text": [
12 [
13 "Pablo",
14 "30%",
15 "30OFF"
16 ]
17 ]
18 }
19 },
20 {
21 "type": "CAROUSEL",
22 "cards": [
23 {
24 "components": [
25 {
26 "type": "HEADER",
27 "format": "IMAGE",
28 "example": {
29 "header_handle": [
30 "4::an..."
31 ]
32 }
33 },
34 {
35 "type": "BODY",
36 "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."
37 },
38 {
39 "type": "BUTTONS",
40 "buttons": [
41 {
42 "type": "QUICK_REPLY",
43 "text": "Send me more like this!"
44 },
45 {
46 "type": "URL",
47 "text": "Shop",
48 "url": "https://www.luckyshrub.com/rare-succulents/{{1}}",
49 "example": [
50 "BLUE_ELF"
51 ]
52 }
53 ]
54 }
55 ]
56 },
57 {
58 "components": [
59 {
60 "type": "HEADER",
61 "format": "IMAGE",
62 "example": {
63 "header_handle": [
64 "4::an..."
65 ]
66 }
67 },
68 {
69 "type": "BODY",
70 "text": "The Crassula Buddha's Temple is sure to be a conversation starter with its tiny temple shaped leaves, intricate details, and lacy texture."
71 },
72 {
73 "type": "BUTTONS",
74 "buttons": [
75 {
76 "type": "QUICK_REPLY",
77 "text": "Send me more like this!"
78 },
79 {
80 "type": "URL",
81 "text": "Shop",
82 "url": "https://www.luckyshrub.com/rare-succulents/{{1}}",
83 "example": [
84 "BUDDHA"
85 ]
86 }
87 ]
88 }
89 ]
90 },
91 {
92 "components": [
93 {
94 "type": "HEADER",
95 "format": "IMAGE",
96 "example": {
97 "header_handle": [
98 "4::an..."
99 ]
100 }
101 },
102 {
103 "type": "BODY",
104 "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."
105 },
106 {
107 "type": "BUTTONS",
108 "buttons": [
109 {
110 "type": "QUICK_REPLY",
111 "text": "Send me more like this!"
112 },
113 {
114 "type": "URL",
115 "text": "Shop",
116 "url": "https://www.luckyshrub.com/rare-succulents/{{1}}",
117 "example": [
118 "BLACK_PRINCE"
119 ]
120 }
121 ]
122 }
123 ]
124 }
125 ]
126 }
127 ]
128 },
129 "carousel_template_product_cards_v1": {
130 "name": "carousel_template_product_cards_v1",
131 "language": "en_US",
132 "category": "MARKETING",
133 "components": [
134 {
135 "type": "BODY",
136 "text": "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!",
137 "example": {
138 "body_text": [
139 [
140 "Pablo"
141 ]
142 ]
143 }
144 },
145 {
146 "type": "CAROUSEL",
147 "cards": [
148 {
149 "components": [
150 {
151 "type": "HEADER",
152 "format": "PRODUCT"
153 },
154 {
155 "type": "BUTTONS",
156 "buttons": [
157 {
158 "type": "SPM",
159 "text": "View"
160 }
161 ]
162 }
163 ]
164 },
165 {
166 "components": [
167 {
168 "type": "HEADER",
169 "format": "PRODUCT"
170 },
171 {
172 "type": "BUTTONS",
173 "buttons": [
174 {
175 "type": "SPM",
176 "text": "View"
177 }
178 ]
179 }
180 ]
181 }
182 ]
183 }
184 ]
185 }
186}
Example of a limited time offer template#
Python Code#
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)
JSON Code#
1{
2 "limited_time_offer_caribbean_pkg_2023": {
3 "name": "limited_time_offer_caribbean_pkg_2023",
4 "language": "en_US",
5 "category": "MARKETING",
6 "components": [
7 {
8 "type": "HEADER",
9 "format": "IMAGE",
10 "example": {
11 "header_handle": [
12 "4::aW..."
13 ]
14 }
15 },
16 {
17 "type": "LIMITED_TIME_OFFER",
18 "limited_time_offer": {
19 "text": "Expiring offer!",
20 "has_expiration": true
21 }
22 },
23 {
24 "type": "BODY",
25 "text": "Good news, {{1}}! Use code {{2}} to get 25% off all Caribbean Destination packages!",
26 "example": {
27 "body_text": [
28 [
29 "Pablo",
30 "CARIBE25"
31 ]
32 ]
33 }
34 },
35 {
36 "type": "BUTTONS",
37 "buttons": [
38 {
39 "type": "COPY_CODE",
40 "example": "CARIBE25"
41 },
42 {
43 "type": "URL",
44 "text": "Book now!",
45 "url": "https://awesomedestinations.com/offers?code={{1}}",
46 "example": [
47 "https://awesomedestinations.com/offers?ref=n3mtql"
48 ]
49 }
50 ]
51 }
52 ]
53 }
54}