Interface of chat window library

This topic describes the interface of chat window library.

Methods of chat-window

Name Description Params
sendMessage You can send messages to chat bot by this function. string
init You can initialize your chat-window by this function. InitOption
InitOption:
option required description default
chatopsWebChatEndpoint yes Specifies the web socket endpoint of web chat in Z ChatOps server. For more information, see Step 3. -
chatopsAccessTokenCallback yes Specifies the callback function to retrieve and return the JWT token to access ZChatOps server. This can be an asynchronous function.  
integratingAppUserCallback yes Specifies one callback function to retrieve and return information of the current user that log in the your web application, which is optionally encrypted by the public key provided by Z ChatOps server: ({userId: ’’, username: ‘‘}). This can be an asynchronous function. -
integratingAppId no Specifies one unique identifier of the integrating web application instance, the name must be same with Step 5. location.host
theme no ‘light‘ | ‘dark‘ light
For example,
chatwindow.init({
                theme: 'light',
                integratingAppId: 'localhost:10001',
                integratingAppUserCallback: fetchApi('http://localhost:10001/user/info'),
                chatopsAccessTokenCallback: fetchApi('https://your host name:4001/user/login'),
                chatopsWebChatEndpoint: 'wss://your ip address:6001',
            });
For more information about how to get access token of Z ChatOps and integrating app user information, see Authenticating.

Events of chat-window

Name Description Params
webChatNotification You will get some notifications by the chat-window. Action
Action:
  • type: string
  • payload: object
Currently supported action:
  • type: 'page-switch'
  • payload: {path: "the path of the page which will be driven"}
For more information about driven page, see Generating driven pages.