sendInteractiveReplayButtons method

Future<Request> sendInteractiveReplayButtons(
  1. String phoneNumber,
  2. Map<String, dynamic> headerInteractive,
  3. String bodyText,
  4. String footerText,
  5. List<Map<String, dynamic>> interactiveReplyButtons,
)

Implementation

Future<Request> sendInteractiveReplayButtons(
    String phoneNumber,
    Map<String, dynamic> headerInteractive,
    String bodyText,
    String footerText,
    List<Map<String, dynamic>> interactiveReplyButtons) 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": "button",
      "header": headerInteractive,
      "body": {"text": bodyText},
      "footer": {"text": footerText},
      "action": {"buttons": interactiveReplyButtons}
    }
  };

  await request.post('$fromNumberId/messages', headers, body);
  return request;
}