Route support requests by language
Build a Python support form that detects a message's language and assigns an application-owned queue, with a review path for uncertain results.
Working example
ParseAPISet up ParseAPI
Set PARSEAPI_KEY in your server environment.
Install the Python web app dependencies in a virtual environment.
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install Flask==3.1.3 httpx==0.28.1
export PARSEAPI_KEY='YOUR_SECRET_API_KEY'Choose a support queue from a message
Build a support-request form that assigns a queue from the submitted message's language. The Python app displays the decision for that exact message. It uses a review queue when detection is uncertain or your team has no configured queue for the language.
This is the routing step in your application. The complete local app does not send messages or create records in a help-desk service.
1. Define the queues your team has
The queue names belong to your app:
QUEUES = {"en": "English support", "fr": "French support", "es": "Spanish support"}
REVIEW_QUEUE = "Language review"Replace these sample names with your own routing rules. Keep a review path instead of assuming every message belongs to English support.
The form accepts one message of up to 2,000 characters. It preserves the entered text and checks a session-bound CSRF token before making a request.
<label for="message">Support message</label>
<textarea id="message" name="message" dir="auto" maxlength="2000" required
aria-describedby="message-hint message-error"
aria-invalid="{{ 'true' if field_error else 'false' }}">{{ message }}</textarea>On a form POST to /, Flask supplies the submitted field:
message = request.form.get("message", "")2. Detect the submitted message
This app uses httpx for the language-detection request. Its handler reads key from the server's PARSEAPI_KEY and creates an HTTP client for https://api.parseapi.com:
with httpx.Client(
base_url=os.environ.get("PARSEAPI_BASE_URL", "https://api.parseapi.com"),
timeout=10.0, follow_redirects=False,
) as client:
response = client.post(
"/language/detect", json={"text": message.strip()},
headers={"X-API-Key": key, "X-API-Version": "2.3.0"},
)The complete source uses one HTTP client for this request, with https://api.parseapi.com as its base URL, a ten-second timeout and no automatic retries or followed redirects. The secret key stays on the server. The explicit header selects API 2.3 independently of the team's default.
The server sends the message in the JSON request body so the support text stays out of URLs. Language identification supports 32 languages and expects one language per request. Short fragments, mixed-language text and unsupported languages can remain unidentified. It does not translate the message.
3. Read the language result
After checking the HTTP status and response version, read the JSON:
detection = response.json()Use the language code for routing and its name for the person reading the result:
language = detection["language"]
language_name = detection["name"]A successful response can contain null language fields. That is an unidentified message, not a failed request. An HTTP error, timeout or malformed response leaves the routing decision unavailable and keeps the message in the form.
4. Apply your queue rule
Choose from the app's configured queues:
queue = QUEUES.get(language, REVIEW_QUEUE)The complete page displays that queue and the detected language. Unidentified text and an identified language with no configured queue both go to Language review, while keeping those two facts distinguishable in the displayed language label.
The handler passes its decision into the ticket template value:
<p class="queue">{{ ticket.queue }}</p>
<p>Detected language: {{ ticket.language_name }}</p>Use this decision when assigning a ticket in your own application. Retain the original message and let a person correct the assignment. A language label describes this message; it does not establish the author's permanent language preference or nationality.
The complete app does not retain message text in session cookies or log it. Use a stable APP_SECRET when adapting it to your own deployment.
The result is a queue decision, not a claim that a help-desk ticket was saved or delivered. See the Language reference for detection fields and limits.
Complete example
Use the complete implementation as a reference when adding this feature to your app. It includes the validation and failure handling around the calls above.
View and copy the complete source
Try the complete example on your computer
After completing the setup above, save the source in your application folder and start the app:
python3 support-language-routing.python.pyOpen 127.0.0.1:8000 to use the form. The server keeps your secret key out of the page.
For every field and parameter, see Language API reference.