Segment
  • 28 Jul 2022
  • 4 Minutes to read
  • Dark
    Light

Segment

  • Dark
    Light

Article Summary

Segment

You need the Manage Settings permission to manage Segment.

Segment JSON Format

Segment is represented as simple flat JSON objects with the following keys:

NameTypeDescription
alertToTypestringAllowed values are "department", "agent", "none".
conditionMetTypestringAllowed values are "all", "any", "logicalExpression".
logicalExpressionstringThe logical expression for conditions
idguidId of the segment.
namestringName of the segment.
isEnabledboolWhether this segment is enabled or not.
descriptionstringDescription of the segment.
colorstringColor of the segment.
orderintegerOrder of the segment.
segmentConditionssegmentConditions[]Reference to Segment Condition.
agentIdsarrayThe list of the segment identifiers, which the agent belongs to.
departmentIdsarrayThe list of the segment identifiers, which the department belongs to.

Segment Condition JSON Format:

NameTypeDescription
idguidId of the segment condition.
segmentIdguidId of the segment which the segment condition belongs to.
fieldNamestringName of the field.
nameoperator
{!Visitor.Number of visits}is/isNot/isMoreThan/isLessThan
{!Visitor.Number of chats}is/isNot/isMoreThan/isLessThan
{!Visitor.Current Page URL}is/isNot/contains/notContains/regularExpression
{!Visitor.Referrer URL}is/isNot/contains/notContains/regularExpression
{!Visitor.Landing Page URL}is/isNot/contains/notContains/regularExpression
{!Visitor.Search Engine}is/isNot/contains/notContains/regularExpression
{!Visitor.Search Keywords}is/isNot/contains/notContains/regularExpression
{!Visitor.Country/Region}is/isNot/contains/notContains/regularExpression
{!Visitor.State/Province}is/isNot/contains/notContains/regularExpression
{!Visitor.City}is/isNot/contains/notContains/regularExpression
{!Visitor.Operating System}is/isNot/contains/notContains/regularExpression
{!Visitor.Time Zone}isOneOf/isNotIn
{!Visitor.Language}is/isNot/contains/notContains/regularExpression
{!Visitor.Campaign}isOneOf/isNotIn
{!Chat.Request Page URL}is/isNot/contains/notContains/regularExpression
Other custom filters, allowed values are all fields of pre-chat,post-chat,offline message, e.g., {!Pre-Chat.Name}.Allowed values are "is", "contains", "notContains", "isMoreThan", "isLessThan", "isNot", "isNotLessThan", "isNotMoreThan", "regularExpression", "isOneOf", "isNotIn", e.g., contains.
operatorstringAllowed values are "is", "contains", "notContains", "isMoreThan", "isLessThan", "isNot", "isNotLessThan", "isNotMoreThan", "regularExpression", "isOneOf", "isNotIn", "dateNotEqualTo", "before", "after", "dateEqualTo".
valuestringValue of the segment condition.
orderintegerOrder of the segment condition.
descriptionstringDescription of the segment condition.

Get the list of Segments

GET livechat/segments

  • Parameters:

NameTypeinRequiredDescription
includestringquerynoAllowed values are "segmentCondition", "agent", "department".
  • Response:

An array of Segment

  • Example

Sample Request:

curl https://api11.comm100.io/v4/livechat/segments \ 
    -X 'GET' \ 
    -H 'Authorization: Bearer {access_token}' \ 

Response:

HTTP/1.1 200 OK

[
  {
      "alertToType": "none",
      "conditionMetType": "all",
      "logicalExpression": "",
      "id": "b797848b-0e86-41ac-b048-d72bd0f075ed",
      "name": "Segment One",
      "isEnabled": false,
      "description": "This is Segment One",
      "color": "#339FD9",
      "order": 2,
      "segmentConditions": [
          {
              "id": "76ec9bdb-854a-4536-8d5b-451b75b908b9",
              "segmentId": "51b60908-28db-427f-aebc-b3afa145f051",
              "fieldName": "{!Visitor.Number of visits}",
              "operator": "is",
              "value": "3",
              "order": 0,
              "description": "Segment - Number of visits"
          }
      ],
      "agentIds": [
          "4BA2EF45-7D46-EB11-8100-00155D081D0B"
      ],
      "departmentIds": [
          "6fd98c99-f183-4247-bdda-47491426e577"
      ]
  }
] 

Get a single Segment

GET livechat/segments/{id}

  • Parameters:

NameTypeinRequiredDescription
includestringquerynoAllowed values are "segmentCondition", "agent", "department".
  • Response:

Segment

  • Example

Sample Request:

curl https://api11.comm100.io/v4/livechat/segments/b797848b-0e86-41ac-b048-d72bd0f075ed \ 
    -X 'GET' \ 
    -H 'Authorization: Bearer {access_token}' \ 

Response:

HTTP/1.1 200 OK

{
  "alertToType": "none",
  "conditionMetType": "all",
  "logicalExpression": "",
  "id": "b797848b-0e86-41ac-b048-d72bd0f075ed",
  "name": "Segment One",
  "isEnabled": false,
  "description": "This is Segment One",
  "color": "#339FD9",
  "order": 2,
  "segmentConditions": [
      {
          "id": "76ec9bdb-854a-4536-8d5b-451b75b908b9",
          "segmentId": "51b60908-28db-427f-aebc-b3afa145f051",
          "fieldName": "{!Visitor.Number of visits}",
          "operator": "is",
          "value": "3",
          "order": 0,
          "description": "Segment - Number of visits"
      }
  ],
  "agentIds": [
      "4BA2EF45-7D46-EB11-8100-00155D081D0B"
  ],
  "departmentIds": [
      "6fd98c99-f183-4247-bdda-47491426e577"
  ]
} 

Create a new Segment

POST livechat/segments

  • Parameters:

NameTypeinRequiredDescription
alertToTypestringbodynoAllowed values are "department", "agent", "none".
conditionMetTypestringbodynoAllowed values are "all", "any", "logicalExpression".
logicalExpressionstringbodyyesThe logical expression for conditions
namestringbodyyesName of the segment.
isEnabledboolbodynoWhether this segment is enabled or not.
descriptionstringbodynoDescription of the segment.
colorstringbodynoColor of the segment.
orderintegerbodynoOrder of the segment.
segmentConditionssegmentConditions[]bodynoReference to Segment Condition.
agentIdsarraybodynoThe list of the segment identifiers, which the agent belongs to.
departmentIdsarraybodynoThe list of the segment identifiers, which the department belongs to.
  • Response:

Segment

  • Example

Sample Request:

curl https://api11.comm100.io/v4/livechat/segments \ 
    -X 'POST' \ 
    -H 'Authorization: Bearer {access_token}' \ 
    -H 'Content-Type: application/json' \ 
    -D '{"alertToType":"none","conditionMetType":"all","logicalExpression":"","name":"Segment One","isEnabled":false,"description":"This is Segment One","color":"#339FD9","order":2,"segmentConditions":[{"fieldName":"{!Visitor.Number of visits}","operator":"is","value":"3","order":0,"description":"Segment - Number of visits"}]}' 

Response:

HTTP/1.1 201 Created

{
  "alertToType": "none",
  "conditionMetType": "all",
  "logicalExpression": "",
  "id": "b797848b-0e86-41ac-b048-d72bd0f075ed",
  "name": "Segment One",
  "isEnabled": false,
  "description": "This is Segment One",
  "color": "#339FD9",
  "order": 2,
  "segmentConditions": [
      {
          "id": "76ec9bdb-854a-4536-8d5b-451b75b908b9",
          "segmentId": "51b60908-28db-427f-aebc-b3afa145f051",
          "fieldName": "{!Visitor.Number of visits}",
          "operator": "is",
          "value": "3",
          "order": 0,
          "description": "Segment - Number of visits"
      }
  ],
  "agentIds": [
      "4BA2EF45-7D46-EB11-8100-00155D081D0B"
  ],
  "departmentIds": [
      "6fd98c99-f183-4247-bdda-47491426e577"
  ]
} 

Update the Segment

PUT livechat/segments/{id}

  • Parameters:

NameTypeinRequiredDescription
alertToTypestringbodynoAllowed values are "department", "agent", "none".
conditionMetTypestringbodynoAllowed values are "all", "any", "logicalExpression".
logicalExpressionstringbodynoThe logical expression for conditions
namestringbodynoName of the segment.
isEnabledboolbodynoWhether this segment is enabled or not.
descriptionstringbodynoDescription of the segment.
colorstringbodynoColor of the segment.
orderintegerbodynoOrder of the segment.
segmentConditionssegmentConditions[]bodynoReference to Segment Condition.
agentIdsarraybodynoThe list of the segment identifiers, which the agent belongs to.
departmentIdsarraybodynoThe list of the segment identifiers, which the department belongs to.
  • Response:

Segment

  • Example

Sample Request:

curl https://api11.comm100.io/v4/livechat/segments/b797848b-0e86-41ac-b048-d72bd0f075ed \ 
    -X 'PUT' \ 
    -H 'Authorization: Bearer {access_token}' \ 
    -H 'Content-Type: application/json' \ 
    -D '{"alertToType":"none","conditionMetType":"all","logicalExpression":"","name":"Segment One","isEnabled":false,"description":"This is Segment One","color":"#339FD9","order":2,"segmentConditions":[{"fieldName":"{!Visitor.Number of visits}","operator":"is","value":"3","order":0,"description":"Segment - Number of visits"}]}' 

Response:

HTTP/1.1 200 OK

{
  "alertToType": "none",
  "conditionMetType": "all",
  "logicalExpression": "",
  "id": "b797848b-0e86-41ac-b048-d72bd0f075ed",
  "name": "Segment One",
  "isEnabled": false,
  "description": "This is Segment One",
  "color": "#339FD9",
  "order": 2,
  "segmentConditions": [
      {
          "id": "76ec9bdb-854a-4536-8d5b-451b75b908b9",
          "segmentId": "51b60908-28db-427f-aebc-b3afa145f051",
          "fieldName": "{!Visitor.Number of visits}",
          "operator": "is",
          "value": "3",
          "order": 0,
          "description": "Segment - Number of visits"
      }
  ],
  "agentIds": [
      "4BA2EF45-7D46-EB11-8100-00155D081D0B"
  ],
  "departmentIds": [
      "6fd98c99-f183-4247-bdda-47491426e577"
  ]
} 

Remove the Segment

DELETE livechat/segments/{id}

  • Parameters:

No Parameters

  • Response:

No Content

  • Example

Sample Request:

curl https://api11.comm100.io/v4/livechat/segments/b797848b-0e86-41ac-b048-d72bd0f075ed \ 
    -X 'DELETE' \ 
    -H 'Authorization: Bearer {access_token}' \ 

Response:

HTTP/1.1 204 No Content


Was this article helpful?

What's Next