/smart-forms/:id/chatChat
Ask an AI assistant questions about smart form session data
Overview
Sends a natural language message to an AI assistant that has access to the smart form's completed session data (up to the 50 most recent sessions). Returns a conversational answer and the number of credits consumed. Pass conversationHistory to maintain multi-turn conversations.
Request
/smart-forms/:id/chatHeaders
| Header | Value |
|---|---|
Authorization | Bearer fxk_live_<your-api-key> |
Content-Type | application/json |
Path Parameters
Request Body
ConversationHistory Entry
| Field | Type | Description |
|---|---|---|
role | string | user or assistant |
content | string | The message content |
Example Request
# Single-turn question
curl -X POST "https://api.formfex.com/api/v1/public/smart-forms/SMART_FORM_ID/chat" \
-H "Authorization: Bearer $FORMFEX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"message": "What are the most common complaints from respondents?"
}'
# Multi-turn with conversation history
curl -X POST "https://api.formfex.com/api/v1/public/smart-forms/SMART_FORM_ID/chat" \
-H "Authorization: Bearer $FORMFEX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"message": "Can you give me specific examples?",
"conversationHistory": [
{
"role": "user",
"content": "What are the most common complaints from respondents?"
},
{
"role": "assistant",
"content": "The most common complaints are long checkout wait times and noise levels in rooms."
}
]
}'Response
Response Fields
| Field | Type | Description |
|---|---|---|
answer | string | The AI assistant's response |
creditsUsed | number | Number of credits consumed by this request (minimum 1) |
Error Cases
| Status | Description |
|---|---|
400 | No completed sessions exist to chat about |
401 | Invalid or missing API key |
403 | Smart Forms feature not available on plan, or insufficient credits |
404 | Smart form not found or not owned by this API key |
Session Context
The AI has access to the 50 most recently completed sessions, including their full Q&A transcripts and individual analyses. Questions can reference specific sessions, trends, sentiment scores, or common themes.
Credit Cost
Each chat request consumes a minimum of 1 credit. Complex questions across many sessions may consume more. The exact cost is returned in the creditsUsed field.
n8n
In n8n, this operation is available as Chat under the Smart Form resource in the Formfex node. Note: AI Agent tool nodes may compose messages longer than 500 characters — the node automatically truncates to stay within the limit.