[Enhancement] Allow modify conversation variable via api (#23112)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
Alex Chim
2025-08-01 09:34:56 +08:00
committed by GitHub
parent 1821726d4f
commit 8ab3fda5a8
9 changed files with 816 additions and 2 deletions

View File

@@ -1011,6 +1011,121 @@ Chat applications support session persistence, allowing previous chat history to
---
<Heading
url='/conversations/:conversation_id/variables/:variable_id'
method='PUT'
title='Update Conversation Variable'
name='#update-conversation-variable'
/>
<Row>
<Col>
Update the value of a specific conversation variable. This endpoint allows you to modify the value of a variable that was captured during the conversation while preserving its name, type, and description.
### Path Parameters
<Properties>
<Property name='conversation_id' type='string' key='conversation_id'>
The ID of the conversation containing the variable to update.
</Property>
<Property name='variable_id' type='string' key='variable_id'>
The ID of the variable to update.
</Property>
</Properties>
### Request Body
<Properties>
<Property name='value' type='any' key='value'>
The new value for the variable. Must match the variable's expected type (string, number, object, etc.).
</Property>
<Property name='user' type='string' key='user'>
The user identifier, defined by the developer, must ensure uniqueness within the application.
</Property>
</Properties>
### Response
Returns the updated variable object with:
- `id` (string) Variable ID
- `name` (string) Variable name
- `value_type` (string) Variable type (string, number, object, etc.)
- `value` (any) Updated variable value
- `description` (string) Variable description
- `created_at` (int) Creation timestamp
- `updated_at` (int) Last update timestamp
### Errors
- 400, `Type mismatch: variable expects {expected_type}, but got {actual_type} type`, Value type doesn't match variable's expected type
- 404, `conversation_not_exists`, Conversation not found
- 404, `conversation_variable_not_exists`, Variable not found
</Col>
<Col sticky>
<CodeGroup title="Request" tag="PUT" label="/conversations/:conversation_id/variables/:variable_id" targetCode={`curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{\n "value": "Updated Value",\n "user": "abc-123"\n}'`}>
```bash {{ title: 'cURL' }}
curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {api_key}' \
--data-raw '{
"value": "Updated Value",
"user": "abc-123"
}'
```
</CodeGroup>
<CodeGroup title="Update with different value types">
```bash {{ title: 'String Value' }}
curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {api_key}' \
--data-raw '{
"value": "New string value",
"user": "abc-123"
}'
```
```bash {{ title: 'Number Value' }}
curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {api_key}' \
--data-raw '{
"value": 42,
"user": "abc-123"
}'
```
```bash {{ title: 'Object Value' }}
curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {api_key}' \
--data-raw '{
"value": {"product": "Widget", "quantity": 10, "price": 29.99},
"user": "abc-123"
}'
```
</CodeGroup>
<CodeGroup title="Response">
```json {{ title: 'Response' }}
{
"id": "variable-uuid-1",
"name": "customer_name",
"value_type": "string",
"value": "Updated Value",
"description": "Customer name extracted from the conversation",
"created_at": 1650000000000,
"updated_at": 1650000001000
}
```
</CodeGroup>
</Col>
</Row>
---
<Heading
url='/audio-to-text'
method='POST'