# Conversation with Chatbot Agent

&#x20;This API allows seamless communication between a client application and a custom chatbot service agent, facilitating natural language processing and response generation.

#### Get your Chatbot Agent ID <a href="#collect-customer-information" id="collect-customer-information"></a>

A Chatbot Agent ID is gotten from the [Autogon console](https://console.autogon.ai/) after a successful creation of a chatbot agent, [see here](https://youtu.be/LE9T9K__cv8) on how to create a Chatbot Agent.&#x20;

#### Authentication <a href="#collect-customer-information" id="collect-customer-information"></a>

Requests to this API doesn't require an API Key to be included in its headers

#### Pricing

Requests made to the Chatbot Conversation API are billed. Each message - response cycle incurs a specific charge.

The pricing for API requests is as follows:

* **Per Request Cost**: 0.05 units per API request

<mark style="color:green;">`POST`</mark> `https://api.autogon.ai/api/v1/services/chatbot/{agent_id}/chat/`

Initiates a new conversation session with the chatbot.

#### Path Parameters

| Name                                        | Type   | Description                                                         |
| ------------------------------------------- | ------ | ------------------------------------------------------------------- |
| agent\_id<mark style="color:red;">\*</mark> | String | Unique identifier for the Agent which responds to the conversation. |

#### Headers

| Name                                           | Type   | Description      |
| ---------------------------------------------- | ------ | ---------------- |
| Content-Type<mark style="color:red;">\*</mark> | String | application/json |

#### Request Body

| Name                                       | Type            | Description                                      |
| ------------------------------------------ | --------------- | ------------------------------------------------ |
| question<mark style="color:red;">\*</mark> | String          | message from the user                            |
| session\_id                                | String(UUID v4) | Identifier for the ongoing conversation session. |

{% tabs %}
{% tab title="200: OK Successful Conversation " %}

```json

{
    "status": "true",
    "message": "Chat with agent: {agent_id} successful",
    "data": {
        "session_id": "cb6c2000-3231-47f1-b773-6f611bb1ea2f",
        "question": "hello chatbot",
        "bot_response": "How can I help you"
        }
}
```

{% endtab %}

{% tab title="404: Not Found Incorrect agent\_id" %}

```json
{
    "status": "false",
    "message": "Agent not found"
}
```

{% endtab %}
{% endtabs %}

### Sample request

{% tabs %}
{% tab title="Python (Requests)" %}
{% code lineNumbers="true" %}

```python
import requests
import json

url = "https://api.autogon.ai/api/v1/services/chatbot/test-agent-id-907e43cd56e7/chat/"

payload = json.dumps({
  "session_id": "test-session-id-1497505decbe",
  "question": "Hello Chatbot"
})
headers = {
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endcode %}
{% endtab %}

{% tab title="Node.js" %}
{% code lineNumbers="true" %}

```javascript
const axios = require('axios');
let data = JSON.stringify({
  "session_id": "test-session-id-1497505decbe",
  "question": "Hello Chatbot"
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.autogon.ai/api/v1/services/chatbot/test-agent-id-907e43cd56e7/chat/',
  headers: { 
    'Content-Type': 'application/json'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endcode %}
{% endtab %}

{% tab title="Curl" %}
{% code overflow="wrap" %}

```json
curl --location 'https://api.autogon.ai/api/v1/services/chatbot/test-agent-id-907e43cd56e7/chat/' \
--header 'Content-Type: application/json' \
--data '{
    "session_id": "test-session-id-1497505decbe",
    "question": "Hello Chatbot"
}'
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Autogon Response

```json
{
    "status": "true",
    "message": "Chat with agent: test-agent-id-907e43cd56e7 successful",
    "data": {
        "session_id": "test-session-id-1497505decbe",
        "question": "Hello Chatbot",
        "bot_response": "How can I help you"
        }
}
```
