User Segment

ChatBot automatically collects all users that chat with the bot and stores their data in the Users section. You can browse this section to find a particular person or a group that meets specified criteria.

List all segments

Returns list of Segments.

GET https://api.chatbot.com/users/segments

Request URL

curl --request GET \
	--url https://api.chatbot.com/users/segments \
	--header 'authorization: Bearer ${DEVELOPER_ACCESS_TOKEN}'

Segment object

parameter type
id String
name String
users Number
createdAt String

Response Example

    [
      {
        "id": "5b7ff8476f7g3fb33c9249a8",
        "name": "Foo",
        "users": 0,
        "createdAt": "2019-01-23 13:32:30.163Z"
      }
    ]

Create segment

Creates new segment.

POST https://api.chatbot.com/users/egments

Request URL

curl --request POST \
	--url https://api.chatbot.com/users/segments \
	--header 'authorization: Bearer ${DEVELOPER_ACCESS_TOKEN}' \
	--header 'content-type: application/json'
	--data-raw '{
		"name": "MySegment"
	}'

Properties

parameter type required
name String(1, 256) required

Response Example

    {
      "id": "\<ID\>",
      "timestamp": "2018-01-19T11:55:07.552Z",
      "status": {
        "code": 200,
        "type": "success"
      }
    }

Add users to Segment

Adds one or more Users to one or more Segments.

POST https://api.chatbot.com/users/segments/members

Request URL

curl --request POST \
	--url https://api.chatbot.com/users/segments/members \
	--header 'authorization: Bearer ${DEVELOPER_ACCESS_TOKEN}' \
	--header 'content-type: application/json'
	--data-raw '{
		"segments": [
			"628dfb166750400007ae9089",
			"628dfb1aeb662f0007f3e02f"
		],
		"users": [
			"628df988024ffc000778f534",
			"628df978f3fdab0007e15445"
		]
	}'

Properties

parameter type required
segments String[1,100] required
users String[1,1000] required

Response Example

    {
      "timestamp": "2018-01-19T11:55:07.552Z",
      "status": {
        "code": 200,
        "type": "success"
      }
    }

Update segment

Update Segment name.

PUT https://api.chatbot.com/users/segments/:id

Request URL

curl --request PUT \
	--url https://api.chatbot.com/users/segments/:id \
	--header 'authorization: Bearer ${DEVELOPER_ACCESS_TOKEN}' \
	--header 'content-type: application/json'
	--data-raw '{
		"name": "NewFancySegmentName"
	}'

URL Parameters

Parameter Type Description
id Alphanumeric required Segment ID

Properties

parameter type required Description
name String(1, 256) required Segment’s new name

Response Example

    {
      "timestamp": "2018-01-19T11:55:07.552Z",
      "status": {
        "code": 200,
        "type": "success"
      }
    }

Remove segment

Remove segment.

DEL https://api.chatbot.com/users/segments/:id

Request URL

curl --request DELETE \
	--url https://api.chatbot.com/users/segments/:id \
	--header 'authorization: Bearer ${DEVELOPER_ACCESS_TOKEN}' \
	--header 'content-type: application/json'

URL Parameters

Parameter Type Description
id Alphanumeric required Segment ID

Response Example

    {
      "timestamp": "2018-01-19T11:55:07.552Z",
      "status": {
        "code": 200,
        "type": "success"
      }
    }

Start a free ChatBot trial
and build your first chatbot today!

Free 14-day trial No credit card required

Discover our text| products