---
sourceDocument: Xanadu API 참조
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/ko-KR/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - ko-KR

ft:publication_title :

    - Xanadu API 참조

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# 가상 및 라이브 에이전트 채팅 구현

# 가상 및 라이브 에이전트 채팅 구현 {#ariaid-title1}

* 릴리스 버전: Xanadu
* 
* 업데이트 날짜 2024년 08월 01일
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 소요 시간: 3분

를 Mobile SDK 사용하면 애플리케이션 내에서 가상 및 라이브 에이전트 채팅 서비스를 쉽게 구현할 수 있습니다 Android .
[NowChatSDK](https://servicenow-prod.fluidtopics.net/MGs6ehvfS_Tj~lDYGduUlw#NowChatSDKAndroidAPI "NowChatService 클래스는 NowChat과 상호 작용하는 NowChatService를 만드는 데 필요한 기능을 제공합니다. NowChat은 애플리케이션 내에 포함할 라이브 에이전트가상 에이전트 수 있는 기능을 제공합니다.") API를 사용하여 채팅 서비스를 생성합니다. 서비스가 생성되면 채팅 사용자 인터페이스를 시작해야 합니다.

다음은 채팅 서비스를 만들고 인터페이스를 시작하는 방법을 보여주는 스니펫입니다.

    /**
     * Helper class used to handle different Now service instances.
     */
    @Singleton
    class SdkManager @Inject constructor() {

        private var chatService: NowChatService? = null

        /**
         * Create the NowChatService once in the lifetime of the application, inside the Application class or another manager class
         * that will be injected into other classes via dagger/hilt.
         * NowChatService should be created after initializing the NowSDK.
         */
        suspend fun getNowChatService(): NowChatService? {
            if (chatService != null) return chatService

            return NowChatSDK.makeChatService(URL("https://instance-name.service-now.com"),
                object : NowChatSdkCallbacks {})
                .getOrThrow()
                .also { this.chatService = it }
        }
    }

    //Activity that will start the NowChat
    class MainActivity : AppCompatActivity() {

        @Inject
        lateinit var sdkManager: SdkManager

        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)

            //Start NowChat using the activity
            lifecycleScope.launch {
                sdkManager.getNowChatService()?.start(this@MainActivity)
            }
        }
    }

애플리케이션 내에서 채팅 기능을 활용하려면 먼저 인스턴스 ServiceNow 내에서 구성해야 가상 에이전트 합니다. 자세한 내용은 [Virtual Agent](https://www.servicenow.com/docs/access?context=virtual-agent-landing-page&version=xanadu&pubname=xanadu-conversational-interfaces&ft:locale=en-US) 문서를 참조하십시오.

## 및 채팅에 라이브 에이전트가상 에이전트 컨텍스트 변수 전달 {#mobsdk-and-imp-chat__section_tcq_3tj_k1c}

[NowChatService-start()](https://servicenow-prod.fluidtopics.net/rVb6nxXg9Q9KYQB3rfJEkA#NChatServA-start_O_O "지정된 NowChat 활동을 시작합니다.") 함수의 매개변수를 전달 contextData 하여 채팅 세션을 시작할 때 채팅 컨텍스트 변수를 전달할 수 있습니다. 채팅 컨텍스트 변수에 대한 자세한 내용은 을 참조하십시오 [Live agent chat context variables](https://www.servicenow.com/docs/access?context=live-agent-chat-context-vars&version=xanadu&pubname=xanadu-conversational-interfaces&ft:locale=en-US).  

    class MainActivity : AppCompatActivity() {
      @Inject

      lateinit var sdkManager: SdkManager

      override fun onCreate(savedInstanceState: Bundle?) { 
        super.onCreate(savedInstanceState)

        val contextData = mapOf("sys_id" to "123456789", "table" to "wm_task")
        //Start NowChat using the activity 
        lifecycleScope.launch {
          sdkManager.getNowChatService()?.start(this@MainActivity, contextData = contextData)
        }
      }
    }

## 채팅 사용자 인터페이스 테마

start() 호출에서 라이브 에이전트 테마 객체를 전달하여 및 가상 에이전트 채팅 UI의 색상을 사용자 지정할 수 있습니다. 사용자 지정할 수 있는 요소 목록은 을 참조하십시오 [NowChatService - launchIntent(context:Context, themeColors:NowChatTheme):Intent](https://servicenow-prod.fluidtopics.net/rVb6nxXg9Q9KYQB3rfJEkA#NChatServA-launchIntent_O_O "NowChat 활동을 여는 데 사용되는 의도를 시작합니다. 일반적으로 [android.app.PendingIntent]를 만드는 데 사용됩니다."). 기본적으로 채팅 UI는 모든 NowSDK UI 요소에 테마를 nowUIColor 사용합니다. 채팅 UI에 테마를 적용하는 방법에 대한 예는 샘플 애플리케이션을 참조하십시오.

