# Requests

# agent.connect

# Request

Request must send immediately after successful connect to server to authenticate the connection. After reply on this request you start receiving events.

Device tokens are persisted even connection is closed or disconnected. To remove device token you must call request agent.logout

interface AgentConnectRequest {
  version: number
  id: string
  key: string
  authToken?: string
  authtoken?: string // legacy
  deviceType?: string
  deviceToken?: string
  devicePlatform?: string
  trackVisitors?: boolean
  bundleVersion?: string
}
PropertyDescription
versionUse value 5
idAgent Id
keyAccount key
authTokenAuth token (provided by auth api)
authtokenLegacy auth token (provided by auth api)
deviceTypeOne of mobile, browser, xmpp or other
devicePlatformDevice type when connecting from mobile device. One of ios, android
deviceTokenDevice token when connecting from mobile device
bundleVersionInfo about client version

# Reply

Returns info about connected agent and account data.

interface AgentConnectReply {
  serverVersion: number
  agent: Agent
  account: {
    agents: Array<{
      id: string
      nickname: string
      fullname: string
      description: string
      avatar: string
    }>
    groups: Array<{
      key: string
      name: string
    }>
  }
}

Request Example

["agent.connect", {
  "version": 5,
  "id": "345111",
  "key": "d57ad424c173ea4541bef97b766c168a83042788",
  "authToken": "6d267d6cd580a4c01afbb2f0b565ab7d",
  "authtoken": "33aab1d14b37a28237d61ec166d8ebb1",
  "deviceToken": null,
  "deviceType": null,
  "devicePlatform": null,
  "trackVisitors": false,
  "bundleVersion": "iOS (2.1.0)"
}]

Success Reply

[null, {
  "serverVersion": 3,
  "agent": {
    "id": "345111",
    "status": "online",
    "groups": [],
    "email": "dusan@smartsupp.com",
    "nickname": "morlok",
    "fullname": "Dusan Kmet",
    "description": "I am awesome!",
    "avatar": "https://files.smartsuppcdn.com/files/agents/63jdada.png",
    "connectedAt": "2019-10-04T14:03:21.877Z",
    "disabled": false
  },
  "account": {
    "agents": [
      {
        "id": "345111",
        "status": "online",
        "nickname": "morlok",
        "fullname": "Dusan Kmet",
        "description": "I am awesome!",
        "avatar": "https://files.smartsuppcdn.com/files/agents/63jdada.png",
        "groups": [],
      },
      {
        "id": "325144",
        "status": "offline",
        "nickname": "sandy",
        "fullname": "Vladimir Sandera",
        "description": "I have vision!",
        "avatar": "https://files.smartsuppcdn.com/files/agents/jkd09wks.png",
        "groups": []
      }
    ],
    "groups": [
      {
        "key": "g67soJw02",
        "name": "Support"
      },
      {
        "key": "p0d4uHoa",
        "name": "Invoices"
      }
    ]
  }
}]

Error Reply

[{
  "message": "Auth token is invalid",
  "event": "agent.connect",
  "type": "auth_failure"
}, null]

# agent.logout

# Request

Request must send when you want release connection and release device tokens (if you register them in agent.connect request)

interface AgentLogoutRequest {
  deviceToken?: string
  devicePlatform?: string
}
PropertyDescription
devicePlatformOne of ios, android
deviceTokenDevice token to remove

# Reply

boolean

Request Example

["agent.logout", {
  "devicePlatform": "ios",
  "deviceToken": "token"
}]

Success Reply

[null, true]

Error Reply

[{
  "message": "Agent not found",
  "event": "agent.logout",
  "type": "not_found"
}, null]

# agent.track_visitors

# Request

With this request you can enable or disable receiving all visitor related events. This configuration is per connection. When tracking is disabled and visitor have opened chat you will be still receiving visitor related events.

boolean

# Reply

This method has no reply.

Request Example

["agent.track_visitors", true]

# chat.typing

# Request

Request must send when agent start typing with property typing.is true. After stop typing call this request with typing.is false. Visitor receive event about agent activity.

interface ChatTypingRequest {
  chatId: string
  visitorId: string
  typing: {
    is: boolean
  }
}

# Reply

This method has no reply.

Request Example

["chat.typing", {
  "chatId": "co2wgLaNKxtOe",
  "visitorId": "viJqfKK4RIOh",
  "typing": {
    "is": true
  }
}]