C
Chatty

Send a Message

POST/api/v1/chat

Send a message to your bot and get an AI reply based on its knowledge base, guardrails, and language settings. The bot maintains full conversation history within a session_id.

Required scope: chat

Request body

textstringbodyrequired

The user's message. Max 4,000 characters. Control characters are stripped automatically.

session_idstringbody

Conversation thread identifier. Omit to start a new session — the generated ID is returned in the response. Reuse the same ID to continue an existing conversation.

visitor_timezonestringbodydefault: UTC

IANA timezone of the visitor (e.g. "America/New_York"). Used by the bot for time-sensitive questions.

Response

replystring

The bot's text reply.

session_idstring

The session ID. Pass this back in your next request to continue the thread.

Examples

cURL
curl -X POST https://api.personaliai.com/api/v1/chat \
  -H "Authorization: Bearer chatty_sk_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Do you offer a free trial?",
    "session_id": "visitor-xyz-789",
    "visitor_timezone": "America/Chicago"
  }'
Python
import httpx
 
r = httpx.post(
    "https://api.personaliai.com/api/v1/chat",
    headers={"Authorization": "Bearer chatty_sk_your_key"},
    json={"text": "Do you offer a free trial?", "session_id": "visitor-xyz-789"},
)
print(r.json()["reply"])
Node.js
const res = await fetch(
  "https://api.personaliai.com/api/v1/chat",
  {
    method: "POST",
    headers: {
      Authorization: "Bearer chatty_sk_your_key",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ text: "Do you offer a free trial?", session_id: "visitor-xyz-789" }),
  }
);
const { reply, session_id } = await res.json();
Go
body, _ := json.Marshal(map[string]string{
    "text":       "Do you offer a free trial?",
    "session_id": "visitor-xyz-789",
})
req, _ := http.NewRequest("POST",
    "https://api.personaliai.com/api/v1/chat",
    bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer chatty_sk_your_key")
req.Header.Set("Content-Type", "application/json")

200 OK:

{
  "reply": "Yes! We offer a 14-day free trial on all paid plans — no credit card required.",
  "session_id": "visitor-xyz-789"
}

To reset a conversation, call DELETE /api/v1/conversations/{session_id} — the next message with the same session_id starts fresh.