Bold360 and BoldChat Developer Center

BoldChatSession.Builder

com.boldchat.sdk

Class BoldChatSession.Builder

  • java.lang.Object
    • com.boldchat.sdk.BoldChatSession.Builder
  • Enclosing class:
    BoldChatSession


    public static class BoldChatSession.Builder
    extends java.lang.Object
    The builder class used to set up all the UI components for use by the BoldChatSession object.
    • Constructor Summary

      Constructors 
      Constructor and Description
      BoldChatSession.Builder(BoldChatView boldChatView)
      Constructs a BoldChatSession that will make use of a BoldChatView that will be added to the layout.
      BoldChatSession.Builder(BoldChatView boldChatView, java.lang.String apiKey)
      Constructs a BoldChatSession that will make use of a BoldChatView that will be added to the layout.
      BoldChatSession.Builder(android.content.Context context, long accountID, java.lang.String chatAPIAccessKey)
      Creates a builder object, with the minimum required arguments.
      BoldChatSession.Builder(android.content.Context context, java.lang.String apiKey)
      Constructs a builder instance without any containers using the indicated context and api key string.
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      BoldChatSession build()
      Combine all of the options that have been set and return a new BoldChatSession object.
      BoldChatSession.Builder setChatFormListener(BoldChatSession.ChatFormListener chatFormListener)
      Sets the listener that will be called before a form is shown.
      BoldChatSession.Builder setExtraData(java.util.Map<java.lang.String,java.lang.Object> extraData)
      Allows you to pre-fill out values for the chat pre and post chat forms, as well as set visitor reference and visitor info fields.
      BoldChatSession.Builder setHideKeyboardOnSend(boolean hideKeyboardOnSend)
      Controls the behavior of the keyboard after a message gets sent.
      BoldChatSession.Builder setListener(BoldChatSession.BoldChatSessionListener boldChatSessionListener)
      Sets a listener that will be notified on status changes of the chat session.
      BoldChatSession.Builder setServerSet(java.lang.String serverSet)
      Deprecated. 
      For BoldChat development purposes only. Do not use.
      BoldChatSession.Builder setSharedPreferences(android.content.SharedPreferences sharedPrefs)
      Allows the control of which SharedPreferences is used for saving the visitor ID value returned from the server.
      BoldChatSession.Builder setSkipPreChat(boolean skipPreChat)
      Allows you to skip the pre-chat form entirely even if one is configured.
      BoldChatSession.Builder setTimeFormat(java.text.DateFormat timeFormat)
      Sets the time format to be used for the time label that appears on each message.
      BoldChatSession.Builder setViewContainers(android.view.ViewGroup busyView, android.view.ViewGroup formView, android.view.ViewGroup mainChatView)
      This sets the three primary views that are used for the chat.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BoldChatSession.Builder

        public BoldChatSession.Builder(BoldChatView boldChatView)
        Constructs a BoldChatSession that will make use of a BoldChatView that will be added to the layout. This will also attempt to load the boldchat:apiKey attribute from the layout if it was set.
        Parameters:
        boldChatView - The BoldChatView instance.
      • BoldChatSession.Builder

        public BoldChatSession.Builder(BoldChatView boldChatView,
                               java.lang.String apiKey)
        Constructs a BoldChatSession that will make use of a BoldChatView that will be added to the layout. This will also attempt to load the boldchat:apiKey attribute from the layout if it was set.
        Parameters:
        boldChatView - The BoldChatView instance.
      • BoldChatSession.Builder

        public BoldChatSession.Builder(android.content.Context context,
                               java.lang.String apiKey)
        Constructs a builder instance without any containers using the indicated context and api key string. This instance will not be usable for a chat session unless a call is made to setViewContainers(android.view.ViewGroup, android.view.ViewGroup, android.view.ViewGroup), however this instance is usable for receiving the online/offline status using BoldChatSession.getChatAvailability(com.boldchat.visitor.api.ChatAvailabilityListener).
        Parameters:
        context - The context for this builder
        apiKey - The api key string from the BoldChat setup interface.
      • BoldChatSession.Builder

        public BoldChatSession.Builder(android.content.Context context,
                               long accountID,
                               java.lang.String chatAPIAccessKey)
        Creates a builder object, with the minimum required arguments. and if it does then it will attempt to restore any persisted chats.
        Parameters:
        context - The context for the components.
        accountID - The accountID assigned by BoldChat
        chatAPIAccessKey - The API access key assigned by BoldChat
    • Method Detail

      • setServerSet

        public BoldChatSession.Builder setServerSet(java.lang.String serverSet)
        Deprecated. For BoldChat development purposes only. Do not use.
      • setChatFormListener

        public BoldChatSession.Builder setChatFormListener(BoldChatSession.ChatFormListener chatFormListener)
        Sets the listener that will be called before a form is shown. This will give the listener an opportunity to pre-fill field values, hide fields, or prevent the form from showing entirely.
        Parameters:
        chatFormListener - The listener to receive form events.
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • setListener

        public BoldChatSession.Builder setListener(BoldChatSession.BoldChatSessionListener boldChatSessionListener)
        Sets a listener that will be notified on status changes of the chat session.
        Parameters:
        boldChatSessionListener - The listener to receive the status events.
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • setHideKeyboardOnSend

        public BoldChatSession.Builder setHideKeyboardOnSend(boolean hideKeyboardOnSend)
        Controls the behavior of the keyboard after a message gets sent. By default the value is false (do not hide).
        Parameters:
        hideKeyboardOnSend - true if the keyboard should hide on send, or false to keep it open.
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • setTimeFormat

        public BoldChatSession.Builder setTimeFormat(java.text.DateFormat timeFormat)
        Sets the time format to be used for the time label that appears on each message. By default it uses the format "h:mm a".
        Parameters:
        timeFormat - The format to use for the time.
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • setSharedPreferences

        public BoldChatSession.Builder setSharedPreferences(android.content.SharedPreferences sharedPrefs)
        Allows the control of which SharedPreferences is used for saving the visitor ID value returned from the server. The key it will use is "bc_VisitorID".
        Parameters:
        sharedPrefs - The shared preferences to save data in.
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • setViewContainers

        public BoldChatSession.Builder setViewContainers(android.view.ViewGroup busyView,
                                                android.view.ViewGroup formView,
                                                android.view.ViewGroup mainChatView)
        This sets the three primary views that are used for the chat. When one of these views is visible, the other two will set the visibility to View.GONE. It is more common to call BoldChatSession.Builder#Builder(BoldChatView) to set up the UI view for a chat, but this method allows for you to manually set up the three primary views yourself if you choose.
        Parameters:
        busyView - The busyView will be shown while the chat is performing an action and the outcome is unknown, such as submitting the values for a form, or starting a new chat.
        formView - The form View is used as a generic container that will be emptied, and filled with the values of a form (pre or post chat) when one needs to be displayed.
        mainChatView - The mMainView is the primary chat interface for an active chat. This view be visible while a visitor is waiting for a chat to be answered, is actively talking to an operator, or the operator has ended the chat, but the visitor has not yet touched the close button.
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • setExtraData

        public BoldChatSession.Builder setExtraData(java.util.Map<java.lang.String,java.lang.Object> extraData)
        Allows you to pre-fill out values for the chat pre and post chat forms, as well as set visitor reference and visitor info fields. The current list of available parameters keys are:
        mLanguage - Language of the visitor (e.g., en-US). If the window does not support the locale, it will fallback to the default mLanguage of the window.
        department - The ID of the department of the chat
        first_name - The name of the visitor
        name - The name of the visitor (synonymous with first_name)
        last_name - The last name of the visitor
        phone - The phone number of the visitor
        email - The email of the visitor
        initial_question - The initial question for the chat (which will show as the first chat message in the chat from the visitor)
        reference - The visitor reference value that appears in the client
        information - The visitor info value that appears in the client
        overall - Survey overall response value
        knowledge - Survey knowledge response value
        responsiveness - Survey responsiveness response value
        professionalism - Survey professionalism response value
        comments - Survey comments response value
        custom_[name] - Sets the custom field (either pre- or post-chat) with the given name to the given value
        Parameters:
        extraData - A map containing the extra information to be passed when creating the chat.
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • setSkipPreChat

        public BoldChatSession.Builder setSkipPreChat(boolean skipPreChat)
        Allows you to skip the pre-chat form entirely even if one is configured. This method is usually paired with setExtraData(java.util.Map) to manually set the values for a pre-chat session, and skip presenting the pre-chat form to the user.
        Parameters:
        skipPreChat - true to skip the pre-chat form, or false to display one if configured.
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • build

        public BoldChatSession build()
        Combine all of the options that have been set and return a new BoldChatSession object.
        Returns:
        An instance of a BoldChatSession that has been configured as indicated.