Sending Interactive Messages#
Send a message with selection keyboard#
You can use selection keyboard only with text messages.
The maximum number of section rows is 10.
1from pywa import WhatsApp
2from pywa.types import SectionList, Section, SectionRow
3
4wa = WhatsApp(phone_id='972123456789', token='xxxxx')
5recipient = '972987654321'
6
7wa.send_message(
8 to=recipient,
9 header='Select your favorite color',
10 text='Tap a button to select your favorite color:',
11 footer='⚡ Powered by PyWa',
12 buttons=SectionList(
13 button_title='Colors',
14 sections=[
15 Section(
16 title='Popular Colors',
17 rows=[
18 SectionRow(
19 title='🟥 Red',
20 callback_data='color:red',
21 description='The color of blood',
22 ),
23 SectionRow(
24 title='🟩 Green',
25 callback_data='color:green',
26 description='The color of grass',
27 ),
28 SectionRow(
29 title='🟦 Blue',
30 callback_data='color:blue',
31 description='The color of the sky',
32 )
33 ],
34 ),
35 Section(
36 title='Other Colors',
37 rows=[
38 SectionRow(
39 title='🟧 Orange',
40 callback_data='color:orange',
41 description='The color of an orange',
42 ),
43 SectionRow(
44 title='🟪 Purple',
45 callback_data='color:purple',
46 description='The color of a grape',
47 ),
48 SectionRow(
49 title='🟨 Yellow',
50 callback_data='color:yellow',
51 description='The color of the sun',
52 )
53 ]
54 )
55 ]
56 )
57)