sendInteractiveLists method
Implementation
Future<Request> sendInteractiveLists(
String phoneNumber,
String? headerText,
String bodyText,
String? footerText,
String buttonText,
List<Map<String, dynamic>> sections) async {
final Map<String, String> headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer $accessToken',
};
final Map<String, dynamic> body = {
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": phoneNumber,
"type": "interactive",
"interactive": {
"type": "list",
"body": {"text": bodyText},
"action": {
"sections": sections,
"button": buttonText,
}
}
};
if (headerText != null) {
body['interactive']['header'] = {"type": "text", "text": headerText};
}
if (footerText != null) {
body['interactive']['footer'] = {"text": footerText};
}
await request.post('$fromNumberId/messages', headers, body);
return request;
}