Back to Blog
2 min read

Language Detection with AI Builder: Routing Multilingual Content

Language detection automatically identifies the language of text content, enabling intelligent routing of multilingual communications and appropriate processing based on language.

Capabilities

supported_languages: 120+
output:
  - Detected language name
  - ISO language code
  - Confidence score

common_languages:
  - English (en)
  - Spanish (es)
  - French (fr)
  - German (de)
  - Portuguese (pt)
  - Chinese (zh)
  - Japanese (ja)
  - Arabic (ar)

Basic Usage

// Detect language
DetectLanguageBtn.OnSelect =
    Set(
        LanguageResult,
        AIBuilder.DetectLanguage(InputText.Text)
    );

// Display result
LanguageLabel.Text = LanguageResult.language
LanguageCodeLabel.Text = "Code: " & LanguageResult.languageCode
ConfidenceLabel.Text = "Confidence: " & Text(LanguageResult.confidence * 100, "0") & "%"

Multilingual Support Routing

{
    "trigger": {
        "type": "When_email_arrives"
    },
    "actions": {
        "Detect_Language": {
            "type": "AIBuilder",
            "inputs": {
                "model": "prebuilt-languageDetection",
                "text": "@{triggerBody()?['body']}"
            }
        },
        "Route_By_Language": {
            "type": "Switch",
            "expression": "@body('Detect_Language')?['languageCode']",
            "cases": {
                "en": {
                    "actions": {
                        "Forward_To_English_Team": {
                            "type": "SendEmail",
                            "inputs": {
                                "to": "support-en@company.com"
                            }
                        }
                    }
                },
                "es": {
                    "actions": {
                        "Forward_To_Spanish_Team": {
                            "type": "SendEmail",
                            "inputs": {
                                "to": "support-es@company.com"
                            }
                        }
                    }
                },
                "fr": {
                    "actions": {
                        "Forward_To_French_Team": {
                            "type": "SendEmail",
                            "inputs": {
                                "to": "support-fr@company.com"
                            }
                        }
                    }
                }
            },
            "default": {
                "actions": {
                    "Forward_To_General": {
                        "type": "SendEmail",
                        "inputs": {
                            "to": "support@company.com",
                            "subject": "[Language: @{body('Detect_Language')?['language']}] @{triggerBody()?['subject']}"
                        }
                    }
                }
            }
        }
    }
}

Translation Workflow

// Detect language and translate if needed
ProcessMultilingualContent.OnSelect =
    Set(
        DetectedLang,
        AIBuilder.DetectLanguage(ContentText.Text)
    );

    If(
        DetectedLang.languageCode <> "en",
        // Translate to English for processing
        Set(
            TranslatedContent,
            // Use Microsoft Translator connector
            MicrosoftTranslator.Translate(
                ContentText.Text,
                "en",
                DetectedLang.languageCode
            )
        );
        Set(ProcessingText, TranslatedContent),
        Set(ProcessingText, ContentText.Text)
    );

    // Continue with English-based processing
    Set(
        Sentiment,
        AIBuilder.AnalyzeSentiment(ProcessingText)
    )

Conclusion

Language detection enables:

  • Intelligent multilingual routing
  • Appropriate language-specific processing
  • Global customer support automation
  • Content localization workflows

Resources

Michael John Peña

Michael John Peña

Senior Data Engineer based in Sydney. Writing about data, cloud, and technology.