{
  "info": {
    "_postman_id": "1dd5273e-3ca5-4fe0-80ce-b3af1534cf9c",
    "name": "NexBot Chat API",
    "description": "Chat with your NexBot over the API. 1) Call Auth with your embed key (from the Deploy page of your bot at https://plateform.nexoptech.com/) to get a session token. 2) Call Chat with your message — the token is applied automatically.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "item": [
    {
      "name": "Auth",
      "event": [
        {
          "listen": "test",
          "script": {
            "exec": [
              "const response = pm.response.json();",
              "",
              "if (response.success && response.data && response.data.token) {",
              "    pm.collectionVariables.set(\"Authorization\", response.data.token);",
              "",
              "    console.log(\"Auth token saved successfully\");",
              "} else {",
              "    console.log(\"Token not found in response\");",
              "}"
            ],
            "type": "text/javascript"
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"embed_key\": \"{{EMBED_KEY}}\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{BASE_URL}}/api/v1/auth/widget-session",
          "host": ["{{BASE_URL}}"],
          "path": ["api", "v1", "auth", "widget-session"]
        }
      },
      "response": []
    },
    {
      "name": "Chat",
      "request": {
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{Authorization}}",
              "type": "string"
            }
          ]
        },
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"message\": \"What are your business hours?\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{BASE_URL}}/api/v1/chat/message",
          "host": ["{{BASE_URL}}"],
          "path": ["api", "v1", "chat", "message"]
        }
      },
      "response": []
    }
  ],
  "variable": [
    {
      "key": "Authorization",
      "value": "",
      "type": "string"
    },
    {
      "key": "BASE_URL",
      "value": "https://api.nexoptech.com",
      "type": "string"
    },
    {
      "key": "EMBED_KEY",
      "value": "pk_your_embed_key_here",
      "type": "string"
    }
  ]
}
