Use the PolyAI Chat API to power Webchat.
POST /chat/create
request with:
user_id
(UUID recommended)message
(can be an empty string)metadata
objectconversation_id
and the assistant’s initial message.
POST /chat/respond
with the conversation_id
and a message
.
The response includes the assistant’s reply and an optional end_conversation
flag.
Region | Base URL |
---|---|
US | https://api.us-1.platform.polyai.app |
UK | https://api.uk-1.platform.polyai.app |
EU-W | https://api.euw-1.platform.polyai.app |
/v1/{account_id}/{project_id}/chat/{operation}
account_id
: Your PolyAI account ID (e.g. poly-scs-uk
)project_id
: Your PolyAI project ID (e.g. PROJECT-191bfa2a
)operation
: Either create
or respond
Header | Description |
---|---|
X-Api-Key | Your API key for PolyAI |
X-Token | A token identifying the agent (connector token) |
Content-Type | Must be application/json |
/v1/poly-scs-uk/PROJECT-191bfa2a/chat/create
Body:
/v1/poly-scs-uk/PROJECT-191bfa2a/chat/respond
Body:
user_id
must be unique per session. Use uuid.uuid4()
to generate it safely.conversation_id
must match the ID returned by the /chat/create
endpoint.end_conversation
indicates the assistant has concluded the session.