src/main/java/com/messageyes/facebook/messenger/FacebookMessengerClient.java
public MessageResponse sendGenericMessage(@NonNull String pageAccessToken, @NonNull String recipientId, @NonNull List<Element> elements, List<QuickReply> quickReplies) throws FacebookMessengerSendException {
        checkArgument(StringUtils.isNotBlank(pageAccessToken), "pageAccessToken cannot be blank");
        checkArgument(StringUtils.isNotBlank(recipientId), "recipientId cannot be blank");
        checkArgument(CollectionUtils.isNotEmpty(elements), "elements cannot be empty");

        checkArgument(CollectionUtils.size(quickReplies) <= 10, "Facebook only supports 10 or fewer quick replies per message");

        for (Element element : elements) {
            if (StringUtils.length(element.getTitle()) > MAX_GENERIC_MESSAGE_TITLE_LENGTH ||
                StringUtils.length(element.getSubtitle()) > MAX_GENERIC_MESSAGE_SUBTITLE_LENGTH) {
                log.warn("Element title or subtitle too long: {}", element);
            }
        }

        Attachment attachment = new Attachment();
        OutboundPayload payload = new OutboundPayload();
        payload.setTemplateType(PAYLOAD_TEMPLATE_TYPE_GENERIC);
        payload.setElements(elements);
        attachment.setPayload(payload);
        attachment.setType(ATTACHMENT_TYPE_TEMPLATE);

        OutboundMessage message = new OutboundMessage();
        message.setAttachment(attachment);
        if (CollectionUtils.isNotEmpty(quickReplies)) {
            message.setQuickReplies(quickReplies);
        }

        return sendOutboundMessage(pageAccessToken, recipientId, message);
    }
/**
     * Sends a generic template message to the given recipient. There must be at least one {@link Element}
     * to send, and may (or may not) include up to 10 quick replies.
     *
     * https://developers.facebook.com/docs/messenger-platform/send-api-reference/generic-template
     */
Sends a generic template message to the given recipient. There must be at least one  Element
to send, and may (or may not) include up to 10 quick replies.


Sends a generic template message to the given recipient . There must be at least one Element to send and may ( or may not ) include up to 10 quick replies .
public MessageResponse sendGenericMessage(@NonNull String pageAccessToken, @NonNull String recipientId, @NonNull List<Element> elements, List<QuickReply> quickReplies) throws FacebookMessengerSendException {
        checkArgument(StringUtils.isNotBlank(pageAccessToken), "pageAccessToken cannot be blank");
        checkArgument(StringUtils.isNotBlank(recipientId), "recipientId cannot be blank");
        checkArgument(CollectionUtils.isNotEmpty(elements), "elements cannot be empty");
        checkArgument(CollectionUtils.size(quickReplies) <= 10, "Facebook only supports 10 or fewer quick replies per message");
        for (Element element : elements) {
            if (StringUtils.length(element.getTitle()) > MAX_GENERIC_MESSAGE_TITLE_LENGTH ||
                StringUtils.length(element.getSubtitle()) > MAX_GENERIC_MESSAGE_SUBTITLE_LENGTH) {
                log.warn("Element title or subtitle too long: {}", element);
            }
        }
        Attachment attachment = new Attachment();
        OutboundPayload payload = new OutboundPayload();
        payload.setTemplateType(PAYLOAD_TEMPLATE_TYPE_GENERIC);
        payload.setElements(elements);
        attachment.setPayload(payload);
        attachment.setType(ATTACHMENT_TYPE_TEMPLATE);
        OutboundMessage message = new OutboundMessage();
        message.setAttachment(attachment);
        if (CollectionUtils.isNotEmpty(quickReplies)) {
            message.setQuickReplies(quickReplies);
        }
        return sendOutboundMessage(pageAccessToken, recipientId, message);
    }
public MessageResponse sendGenericMessage ( @ NonNull String pageAccessToken , @ NonNull String recipientId , @ NonNull List < Element > elements , List < QuickReply > quickReplies ) throws FacebookMessengerSendException { checkArgument ( StringUtils . isNotBlank ( pageAccessToken ) , "pageAccessToken cannot be blank" ) ; checkArgument ( StringUtils . isNotBlank ( recipientId ) , "recipientId cannot be blank" ) ; checkArgument ( CollectionUtils . isNotEmpty ( elements ) , "elements cannot be empty" ) ; checkArgument ( CollectionUtils . size ( quickReplies ) <= 10 , "Facebook only supports 10 or fewer quick replies per message" ) ; for ( Element element : elements ) { if ( StringUtils . length ( element . getTitle ( ) ) > MAX_GENERIC_MESSAGE_TITLE_LENGTH || StringUtils . length ( element . getSubtitle ( ) ) > MAX_GENERIC_MESSAGE_SUBTITLE_LENGTH ) { log . warn ( "Element title or subtitle too long: {}" , element ) ; } } Attachment attachment = new Attachment ( ) ; OutboundPayload payload = new OutboundPayload ( ) ; payload . setTemplateType ( PAYLOAD_TEMPLATE_TYPE_GENERIC ) ; payload . setElements ( elements ) ; attachment . setPayload ( payload ) ; attachment . setType ( ATTACHMENT_TYPE_TEMPLATE ) ; OutboundMessage message = new OutboundMessage ( ) ; message . setAttachment ( attachment ) ; if ( CollectionUtils . isNotEmpty ( quickReplies ) ) { message . setQuickReplies ( quickReplies ) ; } return sendOutboundMessage ( pageAccessToken , recipientId , message ) ; }
Sends a generic template message to the given recipient.
Sends a generic template message to the given recipient .