# Training

It’s challenging to predict all the queries coming to the chatbot every day. People communicate in different styles, using different words and phrases. Stop guessing what your clients are going to say and start listening and using the data you have to train your bot.

## List items

Returns list of [Training object](https://www.chatbot.com/docsv1/training/#training-object) items.

GET https://api.chatbot.com/training

#### Request URL

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

#### Response Example

```json
{
    "items": [
        {
            "id": "5acb6abf0fe82bf4d13a5f98",
            "storyId": "5a8aa27ec7266a0007a00764",
            "conversationId": "5b0ba763c8bb5a339cfb10fc",
            "date": "2018-04-09T13:29:32.999Z",
            "text": "Foo Bar",
            "unmatched": 1
        }
    ],
    "count": 1
}
```

#### Properties

| Property           | Type                       | Required | Default |
|--------------------|----------------------------|----------|---------|
| `page`             | Number(1, 1024)           | optional | 1       |
| `sort[field]`      | (`date`, `unmatched`)      | optional | date    |
| `sort[order]`      | (`asc`, `desc`)           | optional | desc    |
| `filter[ignored]`  | Boolean                    | optional | false   |
| `filter[stories]`  | String(24), String[]      | optional |         |
| `filter[text]`     | String(3,256)             | optional |         |
| `filter[from]`     | Date, Timestamp, Miliseconds | optional | 1974-1-1 |
| `filter[to]`       | Date, Timestamp, Miliseconds | optional | now     |
| `filter[period]`   | Period                     | optional |         |

Periods: `yesterday`,`last7days`,`last30days`, `thisMonth`,`lastMonth`,`last3Months`, `thisMonth`, `lastMonth`,`last3Months`, `thisYear`, `lastYear`

### Training object

| parameter       | type   |
|------------------|--------|
| `id`             | String |
| `storyId`       | String |
| `conversationId` | String |
| `date`           | String |
| `text`           | String |
| `unmatched`      | Number |

## Delete items

Removes provided items.

DELETE https://api.chatbot.com/training

#### Request URL

```bash
curl --request DELETE \
	--url https://api.chatbot.com/training \
	--header 'authorization: Bearer ${DEVELOPER_ACCESS_TOKEN}' \
	--header 'content-type: application/json' \
	--data '
[
  "5acb6abf0fe82bf4d13a5f98"
]
'
```

#### Response Example

```json
{
    "timestamp": "2017-04-12T13:41:47.020Z",
    "status": {
        "code": 200,
        "type": "success"
    }
}
```

## Ignore items

Marks provided items as ignored.

PUT https://api.chatbot.com/training/ignore

#### Request URL

```bash
curl --request PUT \
	--url https://api.chatbot.com/training/ignore \
	--header 'authorization: Bearer ${DEVELOPER_ACCESS_TOKEN}' \
	--header 'content-type: application/json' \
	--data '
[
  "5acb6abf0fe82bf4d13a5f98"
]
'
```

#### Response Example

```json
{
    "timestamp": "2017-04-12T13:41:47.020Z",
    "status": {
        "code": 200,
        "type": "success"
    }
}
```

## Train items

Move training items to interaction.

PUT https://api.chatbot.com/training/train/:interactionID

#### Request URL

```bash
curl --request PUT \
	--url https://api.chatbot.com/training/train/:interactionID \
	--header 'authorization: Bearer ${DEVELOPER_ACCESS_TOKEN}' \
	--header 'content-type: application/json' \
	--data '
[
  "5acb6abf0fe82bf4d13a5f98"
]
'
```

#### Response Example

```json
{
    "used": [
        "5acb6abf0fe82bf4d13a5f98"
    ],
    "unused": [],
    "timestamp": "2018-01-19T11:55:07.552Z",
    "status": {
        "code": 200,
        "type": "success"
    }
}
```

## Train by text

Train by provided text & remove training item if exists.

PUT https://api.chatbot.com/training/train/:interactionID/text

#### Request URL

```bash
curl --request PUT \
	--url https://api.chatbot.com/training/train/:interactionID/text \
	--header 'authorization: Bearer ${DEVELOPER_ACCESS_TOKEN}' \
	--header 'content-type: application/json' \
	--data '
{
    "text": "Here put your training text"
}
'
```

#### Properties

| parameter | type   |
|-----------|--------|
| `text`    | String |

#### Response Example

```json
{
    "used": [
        "5acb6abf0fe82bf4d13a5f98"
    ],
    "unused": [],
    "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.
