NowChatConfiguration を渡して、NowChat の動作を変更します

  • リリースバージョン: Zurich
  • 更新日 2025年07月31日
  • 所要時間:3分
  • チャットセッションの開始時にオプションの NowChatConfiguration パラメーターを渡して、NowChat の動作の一部を変更できます。

    NowChatConfiguration オブジェクトには、次のオプションが含まれています。
    • closePrompt:チャットウィンドウを終了する前に表示されるプロンプトテキスト。このプロンプトテキストは、次のパラメーターを使用して定義します。
      • header:プロンプトのヘッダーに表示される null 許容文字列値。
      • message:プロンプトの本文に表示される文字列値。
      • acceptButtonTitle:プロンプトのプライマリボタンに表示される文字列値。このボタンをクリックすると、チャットウィンドウが閉じます。
      • declineButtonTitle:プロンプトのセカンダリボタンに表示される文字列値。このボタンは、チャットウィンドウを閉じずにプロンプトを閉じます。
    • disabledFeatures:無効にする NowChat 機能のリスト。無効にできる機能のリストについては、 NowChatConfiguration.Feature 列挙型クラスを参照してください。
    • conversationOptions:NowChat に適用する会話オプションのリスト。適用できるオプションのリストについては、 NowChatConvestation.ConversationOption 列挙型クラスを参照してください。
    • uiConfiguration:NowChat で UI コンポーネントを構成するために使用される UIConfiguration 値。

    次のコード例は、 NowChatConfiguration() を使用して NowChat を構成する方法を示しています。

    class MainActivity : AppCompatActivity() {
      @Inject
    
      lateinit var sdkManager: SdkManager
     
      override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
     
        //Drawable to use instead of the default NowChat back button.
        val myDrawable = ContextCompat.getDrawable(activity, R.drawable.my_drawable)
     
        val nowChatConfiguration = 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)
          )
        )
     
        //Start NowChat 
        lifecycleScope.launch { 
          sdkManager.getNowChatService()?.start(this@MainActivity, nowChatConfiguration = nowChatConfiguration) 
        }
      }
    } 

    詳細については、「 NowChatConfiguration: Android 」および「 NowChatService - start(activity: Activity, themeColors: NowChatTheme = object: NowChatTheme{}, contextData: Map<String, Any> = mapOf(), chatConfiguration: NowChatConfiguration? = null)」を参照してください。