NowChatConfiguration: Android

  • リリースバージョン: Yokohama
  • 更新日 2025年01月30日
  • 所要時間:13分
  • NowChatConfiguration クラスを使用すると、チャットウィンドウを閉じる前にプロンプトを表示する、チャットの使用中に機能を無効にする、チャットを使用するときにさまざまな会話オプションを適用する、NowChat で UI コンポーネントを設定するなど、チャットセッションのオプションを設定できます。

    NowChatConfiguration:NowChatConfiguration(closePrompt: ClosePrompt? = null, disabledFeatures: List<Feature>? = null, conversationOptions: List<ConversationOption>? = null, uiConfiguration: UIConfiguration? = null)

    現在のチャットセッションのオプションを設定します。この方法を使用すると、チャットウィンドウを閉じる前にプロンプトを表示したり、チャットの使用中に機能を無効にしたり、チャットの使用時にさまざまな会話オプションを適用したり、NowChat で UI コンポーネントを設定したりできます。

    表 : 1. パラメーター
    名前 タイプ 説明
    プロンプトを閉じる ClosePrompt オブジェクト 関連するチャットウィンドウを閉じる前に表示するプロンプト。

    NowChatConfiguration.ClosePrompt() サブクラスを呼び出して、このパラメーターの値を定義します。

    例:
    closePrompt = NowChatConfiguration.ClosePrompt(
      header = null,
      message = "Are you sure you want to leave?",
      acceptButtonTitle = "Yes",
      declineButtonTitle = "No"
    )

    クローズプロンプトを表示しない場合は、null を渡します。

    disabledFeatures List<NowChatConfiguration。

    特徴>

    現在のチャットセッション内で無効にするチャット機能のリスト。

    有効な値:

    START_NEW_CONVERSATION:チャットウィンドウに表示される [ 新しい会話を開始 ] ボタンを非表示/無効にします。

    利用可能なチャット機能は、 NowChatConfiguration.Feature 列挙型クラスで定義されます。

    例:
    disabledFeatures = listOf(NowChatConfiguration.Feature.START_NEW_CONVERSATION)

    機能を無効にしない場合は、null を渡します。

    conversationOptions List<Conversation

    オプション>?

    NowChat に適用する会話オプションのリスト。
    有効な値:
    • END_CONVERSATION_ON_EXIT:NowChat ウィンドウを終了すると、進行中の会話が終了します。
    • FORCE_NEW_CONVERSATION:NowChat の起動時に新しいチャット会話を強制します。

    利用可能な会話オプションは、 NowChatConfiguration.ConversationOption 列挙型クラスで定義されます。

    例:
    conversationOptions = listOf(NowChatConfiguration.ConversationOption.FORCE_NEW_CONVERSATION),

    オプションを適用しない場合は、null を渡します。

    UI 構成 UIConfiguration? NowChat で UI コンポーネントを構成するために使用する UIConfiguration 値。
    有効な値:
    • attachmentUploadButton:ライブエージェントとの会話中にテキスト入力の横に表示される AttachmentUploadButton の構成。
    • closeButton:NowChat ツールバーの [戻る] ナビゲーションに使用される [閉じる] ボタン の構成。
    例:
    uiConfiguration = NowChatConfiguration.UIConfiguration(
      closeButton = NowChatConfiguration.CloseButton(
        icon = myDrawable
      ),
      attachmentUploadButton = NowChatConfiguration.AttachmentUploadButton(isVisible = false)
    )

    デフォルト構成を使用するには、null を渡します。

    表 : 2. 戻り値
    タイプ 説明
    NowChatConfiguration NowChatService - start(activity: Activity, themeColors: NowChatTheme = object: NowChatTheme{}, contextData: Map<String, Any> = mapOf(), chatConfiguration: NowChatConfiguration? = null) メソッドを呼び出すときに渡すことができる NowChatConfiguration オブジェクトを返します。

    次のコード例は、このメソッドを呼び出す方法を示しています。

    suspend fun launchChat() {
      val chatService = getNowChatService()
     
      //Drawable to use instead of the default NowChat back button.
      val myDrawable = ContextCompat.getDrawable(activity, R.drawable.my_drawable)
         
      val chatConfiguration = NowChatConfiguration(
        closePrompt = NowChatConfiguration.ClosePrompt(
          header = null,
          message = "Are you sure you want to leave?",
          acceptButtonTitle = "Yes",
          declineButtonTitle = "No"
        ),
        disabledFeatures = listOf(NowChatConfiguration.Feature.START_NEW_CONVERSATION),
        conversationOptions = listOf(NowChatConfiguration.ConversationOption.FORCE_NEW_CONVERSATION),
        uiConfiguration = NowChatConfiguration.UIConfiguration(
          closeButton = NowChatConfiguration.CloseButton(
            icon = myDrawable
          ),
          attachmentUploadButton = NowChatConfiguration.AttachmentUploadButton(isVisible = false)
        )
      )
    
      chatService?.start(activity, chatConfiguration)
    }

    NowChatConfiguration:AttachmentUploadButton (isVisible:ブール値 = true)

    ライブエージェントとの会話中にテキスト入力の横に表示される [添付ファイルのアップロード] ボタンに適用する UI 構成を定義します。

    AttachmentUploadButton は、 NowChatConfiguration クラスのサブクラスです。

    表 : 3. パラメーター
    名前 タイプ 説明
    isVisible ブール [添付ファイルのアップロード] ボタンのヴィジビリティを示すフラグ。
    有効な値:
    • true:[添付ファイルのアップロード] ボタンが表示されます。
    • false:[添付ファイルのアップロード] ボタンは非表示になります。

    デフォルト:true

    表 : 4. 返される内容
    タイプ 説明
    オブジェクト UI 構成オブジェクト。

    次のコード例は、AttachmentUploadButton を非表示にする方法を示しています。

    suspend fun launchChat() {
      val chatService = getNowChatService()
    
      val chatConfiguration = NowChatConfiguration(
        uiConfiguration = NowChatConfiguration.UIConfiguration(
          attachmentUploadButton = NowChatConfiguration.AttachmentUploadButton(isVisible = false)
        )
      )
     
      chatService?.start(activity, chatConfiguration)
    }

    NowChatConfiguration - CloseButton (アイコン:Drawable?)

    NowChat ツールバーの「戻る」ナビゲーションに使用する閉じるボタンの構成を定義します。次に、このオブジェクトを NowChatConfiguration() メソッドに渡して、チャットセッションで使用する [閉じる] ボタンを設定します。

    CloseButton() は、 NowChatConfiguration クラスのサブクラスです。

    表 : 5. パラメーター
    名前 タイプ 説明
    アイコン ドロウアブル。 閉じる (戻る) ボタンに使用する描画オブジェクト。

    ContextCompat.getDrawable() メソッドを使用して、この描画可能オブジェクトを取得できます。

    例:
    val myDrawable = ContextCompat.getDrawable(activity, R.drawable.my_drawable)

    デフォルトのドローアブルを使用するには、null を渡します。

    デフォルト:NowChat の戻るボタン

    表 : 6. 戻り値
    タイプ 説明
    オブジェクト [閉じる] ボタン構成オブジェクト。

    次のコード例は、NowChat ツールバーの [閉じる] ボタンにカスタムアイコンを設定する方法を示しています。

    suspend fun launchChat() {
      val chatService = getNowChatService()
     
      //Drawable to use instead of the default NowChat back button.
      val myDrawable = ContextCompat.getDrawable(activity, R.drawable.my_drawable)
    
      val chatConfiguration = NowChatConfiguration(
        uiConfiguration = NowChatConfiguration.UIConfiguration(
          closeButton = NowChatConfiguration.CloseButton(
            icon = myDrawable
          )
        )
      )
    
      chatService?.start(activity, chatConfiguration)
    }

    NowChatConfiguration - ClosePrompt(header: String, message: String, acceptButtonTitle: String, declineButtonTitle: String)

    渡されたパラメーターに基づいて ClosePrompt オブジェクトを作成して返します。次に、このオブジェクトを NowChatConfiguration() メソッドに渡して、チャットセッション内のプロンプトを閉じるオプションを設定します。

    表 : 7. パラメーター
    名前 タイプ 説明
    header 文字列 プロンプトのヘッダーに表示するテキスト。

    プロンプトヘッダーを表示しない場合は、null を渡します。

    メッセージ 文字列 プロンプトのメインテキストとして表示するテキスト。
    acceptButtonTitle 文字列 チャットウィンドウを閉じるためのプロンプトのプライマリボタンに表示するテキスト。
    declineButton タイトル 文字列 プロンプトを却下するプロンプトのセカンダリボタンに表示するテキスト。

    セカンダリ ボタンを表示しない場合は、null を渡します。

    表 : 8. 戻り値
    タイプ 説明
    オブジェクト 関連するチャットウィンドウを閉じる前に表示するプロンプト。

    次のコード例は、このメソッドを呼び出してクローズプロンプトを構成する方法を示しています。

    suspend fun launchChat() {
      val chatService = getNowChatService()
     
      val chatConfiguration = NowChatConfiguration(
        closePrompt = NowChatConfiguration.ClosePrompt(
          header = null,
          message = "Are you sure you want to leave?",
          acceptButtonTitle = "Yes",
          declineButtonTitle = "No"
        )
      )
      chatService?.start(activity, chatConfiguration)
    }

    NowChatConfiguration:UIConfiguration(closeButton:CloseButton? = null、attachmentUploadButton:AttachmentUploadButton? = null)

    渡されたパラメーターに基づいて UIConfiguration オブジェクトを作成して返します。次に、このオブジェクトを NowChatConfiguration() コンストラクターに渡して、NowChat で UI コンポーネントを構成します。

    UIConfigurationNowChatConfiguration クラスのサブクラスです。

    表 : 9. パラメーター
    名前 タイプ 説明
    閉じるボタン 閉じるボタン? NowChat ツールバーに表示され、「戻る」ナビゲーションに使用される 閉じるボタン の構成。

    NowChatConfiguration - CloseButton (アイコン:Drawable?)サブクラスを呼び出して、このパラメーターの値を定義します。

    例:
    val chatConfiguration = NowChatConfiguration( 
      uiConfiguration = NowChatConfiguration.UIConfiguration( 
        closeButton = NowChatConfiguration.CloseButton( 
          icon = myDrawable
      )
    )
    attachmentUploadButton AttachmentUploadButton? ライブエージェントとの会話中にテキスト入力の横に表示される AttachmentUploadButton の構成。

    NowChatConfiguration:AttachmentUploadButton (isVisible:ブール値 = true)サブクラスを呼び出して、このパラメーターの値を定義します。

    例:
    val chatConfiguration = NowChatConfiguration( 
      uiConfiguration = NowChatConfiguration.UIConfiguration(
        attachmentUploadButton = NowChatConfiguration.AttachmentUploadButton(isVisible = false)
      ) 
    )
    表 : 10. 返される内容
    タイプ 説明
    オブジェクト UI 構成オブジェクト。

    次のコード例は、 UIConfiguration サブクラスを呼び出して、closeButton のアイコンを設定し、添付ファイルのアップロード ボタンを非表示にする方法を示しています。

    suspend fun launchChat() {
      val chatService = getNowChatService() 
         
      //Drawable to use instead of the default NowChat back button. 
      val myDrawable = ContextCompat.getDrawable(activity, R.drawable.my_drawable) 
     
      val chatConfiguration = NowChatConfiguration( 
        uiConfiguration = NowChatConfiguration.UIConfiguration( 
          closeButton = NowChatConfiguration.CloseButton( 
            icon = myDrawable 
          ), 
          attachmentUploadButton = NowChatConfiguration.AttachmentUploadButton(isVisible = false)
        ) 
      ) 
     
      chatService?.start(activity, chatConfiguration) 
    }