# CIAPI - Chat Interface API

CIAPI in Bootstrap Code provide clients a way to build there own chat window.

- ##### CIAPI.onC2CClicked(dx,callback)

  Allowing client Javascript to let Nuance Framework know that c2c button is clicked
  * @param {number} c2cId - id of the c2c
  * @param {c2cClickedCB} callback - callback that is fired upon receving a response for requesting an engagement

- ##### CIAPI.chatDisplayed(displayedParams)

  Allowing client CI to register with nuance framework for various callbacks
  * @property {function(Array.<Object>)} displayedParams.previousMessagesCb - This callback is invoked with all the previous chat messages upon user reloading the page or navigating to a new page.
  * @property {function} displayedParams.disconnectCb - This callback will be invoked when Nuance SDK detects a network problem connecting to the chat server.
  * @property {function} displayedParams.reconnectCb - This callback is invoked to let client JavaScript know when SDK reestablish the connection.
  * @property {function} displayedParams.failedCb - This callback is invoked to let client JS know that connection with server is permanently failed.
  * @property {Array.<string>} displayedParams.openerScripts - Opener messages that is presented to the user, parameter should be an array of strings.
  * @property {string} displayedParams.defaultAgentAlias - Agent Name that is displayed for opener script * @property {string} displayedParams.customerName - Name of the customer to be displayed to agent

- ##### CIAPI.engageChat(initialMessage, callback)

  Allowing client Chat interface to start an engagment
  * @param {string} text - initial text that is send you agent upon creation of the engagement
  * @param {engageStatusCB} callback - callback that is fired upon receving a response for starting an engagment

- ##### CIAPI.getMessages(callback)

  Allowing client CI to listen to agent messages

- ##### CIAPI.closeChat()

  Allowing client CI close the chat

- ##### CIAPI.sendMessage(msg)

  Allowing client CI to send new customer mesage

- ##### CIAPI.sendActivityMessage(type)

  Allowing client CI to send customer activity message - activityType: startTyping | stopTyping | minimize | restore

- ##### CIAPI.requestEmailTranscript(emailAddress)

  Allowing client CI to request the transcript in an email

- ##### CIAPI.isChatInProgress(callback)

  Allowing client CI to retrieve the chat progress state
  * @param {function} callback - boolean state value will be the argument of the callback

- ##### CIAPI.getOpenerScripts(callback)

  Allowing client CI to request the openers configured in portal
  * @param {function} callback - array of strings will be the argument of the callback

- ##### CIAPI.sendDataPass(dpObject)

  Allowing client CI to send custom data pass
  * @param {object} dpObject - object which contains data pass key value information

- ##### CIAPI.sendVALinkMessage(event, customerMsgCB)

  Handles the processing the virtual agent dialoges or links
  * @param {Event} event - pass the click event to the API
  * @param {customerMsgCB} callback - callback will be fired with the text as the argument that need to displed in the chat window

- ##### CIAPI.sendRichContentMessage(text, data)

  Allowing client CI to send rich media response
  * @param {string} text - text information that displayed to agent
  * @param {object} data - json rich media object

- ##### CIAPI.getPreviousAsyncTranscript(callback)

  Allowing client CI to retreive previous conversation transcript for async messaging
  * @param {function} callback - callback will be fired with array of conversations

- ##### CIAPI.isLastConversationActive(callback)

  Allowing client CI to retreive the state of last conversation
  * @param {function} callback - callback will be fired with state of last conversation.

- ##### CIAPI.getAsyncUnReadMsgCount(callback)

  Allowing client c2c to retrieve the unread messages of an active async chat .This must be called after c2c is dislayed
  * @param {function} callback - callback will be fired with an object containing pending message count.

- ##### CIAPI.checkIfMinimized(callback)

  Allowing client javascript detect if chat was minimized before a page refresh
  * @param {function} callback - callback will be fired with an object containing minimized state and minimized message count.