Interface MessageBuilder

  • All Known Implementing Classes:
    MessageBuilderImpl

    public interface MessageBuilder
    The message builder API to create messages to be sent to a conversation using the send(String) method within the builder. Make sure to at least add a message content using mainContent(String). You can optionally set the user to send that message from using the senderId(String) method.
    Author:
    Filip Hrisafov, Joram Barrez, Micha Kiener
    • Method Detail

      • actionDefinitionId

        MessageBuilder actionDefinitionId​(String actionDefinitionId)
        Optionally reference an action definition given by its id. The message will then reference that action definition by creating an action instance based on it within the send method. You might want to set an explicit scope for the action instance too using scope(String, String), if not set, the conversation is automatically used as the scope for the action instance.
        Parameters:
        actionDefinitionId - the id of the action definition to create an action instance for, which is then referenced by this message
        Returns:
        the message builder for method chaining
      • actionDefinitionKey

        MessageBuilder actionDefinitionKey​(String key)
        Optionally reference an action definition given by its key. The message will then reference that action definition by creating an action instance based on it within the send method. You might want to set an explicit scope for the action instance too using scope(String, String), if not set, the conversation is automatically used as the scope for the action instance.
        Parameters:
        key - the key of the action definition to create an action instance for, which is then referenced by this message
        Returns:
        the message builder for method chaining
      • mainContentTemplate

        @Deprecated
        MessageBuilder mainContentTemplate​(String messageCode,
                                           String language,
                                           Map<String,​Object> payload)
        Deprecated.
        always use the method with the template key instead and provide your own key
        Adds content being rendered from the specified template (uses "standardMessage" as the template key and the provided message code and optional language as the variation). If the template has placeholders, then the payload needs to be provided as well in order to let the template engine render it.
        Parameters:
        messageCode - the message code to be used for the variation of the template
        language - the language or null to use the default one
        payload - the optional payload containing the values for the placeholder of the template, if needed
        Returns:
        the message builder for method chaining
      • mainContentTemplate

        MessageBuilder mainContentTemplate​(String templateKey,
                                           String messageCode,
                                           String language,
                                           Map<String,​Object> payload)
        Adds content being rendered from the specified template (uses "standardMessage" as the template key and the provided message code and optional language as the variation). If the template has placeholders, then the payload needs to be provided as well in order to let the template engine render it.
        Parameters:
        templateKey - the key of the template to be used (will be "standardMessage", if none provided explicitly)
        messageCode - the message code to be used for the variation of the template
        language - the language or null to use the default one
        payload - the optional payload containing the values for the placeholder of the template, if needed
        Returns:
        the message builder for method chaining
      • media

        MessageBuilder media​(ContentItem contentItem)
        Send a media message with a provisional content item
        Parameters:
        contentItem - the provisional content
      • privateMessage

        MessageBuilder privateMessage​(String recipientId)
        The message should be a private message for the user with the recipientId.
        Parameters:
        recipientId - the id of the recipient user
      • privateGroupMessage

        MessageBuilder privateGroupMessage​(String recipientGroupId)
        The message should be a private message for the group with the recipientGroupId
        Parameters:
        recipientGroupId - the id of the recipient group
      • scope

        MessageBuilder scope​(String scopeId,
                             String scopeType)
        Set an explicit scope for a referenced action definition to be passed on to the action instance, if created when posting this message. If not explicitly set, the conversation is used as the scope this message is sent to.
        Parameters:
        scopeId - the id of the scope a referenced action definition should be bound to
        scopeType - the type of the scope for the referenced action definition
        Returns:
        the message builder for method chaining
      • send

        Message send​(String conversationId)
        Creates and sends the message to the specified conversation.
        Parameters:
        conversationId - the id of the conversation to send the message to
        Returns:
        the created and sent message object