Part 1 of 3 in the AWS managed AI/ML series.
| Part | Topic |
|---|---|
| 1 (this page) | Comprehend, Translate, Lex |
| 2 — Speech, vision, documents | Polly, Transcribe, Rekognition, Textract |
| 3 — Search and recommendations | Kendra, Personalize |
Console steps come first. Copy-paste AWS CLI lives in <details> blocks.
Prerequisites
- Signed-in AWS account in a chosen Region (stick to one Region for the whole exercise).
- IAM user or role with service access (labs often attach broad managed policies; production uses least privilege).
- Optional sample text:
dir/ai-ml/sample-review.txt.
Verify credentials:
aws sts get-caller-identity
export AWS_REGION=us-east-1
Amazon Comprehend
Use when: you need sentiment, entities, key phrases, or language from short text—no model training required.
Console
- Open Amazon Comprehend.
- Left menu → Real-time analysis.
- Analysis type → Built-in.
- Paste text (up to 5,000 characters) or use the sample from
sample-review.txt. - Choose Analyze.
- In Insights, open Sentiment, Entities, and Key phrases tabs.
Reference: Real-time analysis using built-in models.
AWS CLI (Comprehend)
Dominant language:
aws comprehend detect-dominant-language \
--region "$AWS_REGION" \
--text "It is a beautiful day in Seattle."
Sentiment (set --language-code to match the text):
aws comprehend detect-sentiment \
--region "$AWS_REGION" \
--language-code en \
--text "It is a beautiful day in Seattle."
Named entities:
aws comprehend detect-entities \
--region "$AWS_REGION" \
--language-code en \
--text "Amazon Web Services is based in Seattle."
Docs: Using the synchronous API.
Amazon Translate
Use when: you need one string or document snippet translated to another language.
Console
- Open Amazon Translate.
- Choose Real-time translation (wording may vary by console version).
- Enter source text, pick Source language and Target language (or Auto for source where supported).
- Read the translated output in the panel.
Reference: Getting started with Amazon Translate.
AWS CLI (Translate)
aws translate translate-text \
--region "$AWS_REGION" \
--source-language-code en \
--target-language-code es \
--text "Hello, how are you?"
Auto-detect source (Region must support Comprehend-backed autodetect):
aws translate translate-text \
--region "$AWS_REGION" \
--source-language-code auto \
--target-language-code fr \
--text "Good morning"
Docs: translate-text.
Tip: Comprehend → Translate chain: detect language with Comprehend, then call Translate with that code instead of auto.
Amazon Lex (V2)
Use when: you need a conversational bot (intents, slots) with a test UI before wiring mobile or web clients.
Lex has many CLI steps (lexv2-models create bot, locale, build, version, alias). The console is faster for a first bot.
Console
- Open Amazon Lex.
- Create bot → Traditional → Create a blank bot.
- Name the bot, accept or create the IAM role, set Idle session timeout, choose Next.
- Add a language (for example English (US)).
- Create at least one Intent with sample Utterances (for example intent
OrderFlowers, utteranceI want to order flowers). - Build the bot locale, then Test in the built-in test window.
Reference: Creating a bot using the Lex V2 console.
AWS CLI (Lex — test only)
After the bot is Built and you have a bot alias, send text to the runtime API. Replace placeholders from the Lex console (Bot ID, Bot alias ID):
aws lexv2-runtime recognize-text \
--region "$AWS_REGION" \
--bot-id BOT_ID \
--bot-alias-id ALIAS_ID \
--locale-id en_US \
--session-id demo-session-001 \
--text "I want to order flowers"
List bots (find IDs):
aws lexv2-models list-bots --region "$AWS_REGION"
Full bot creation via CLI uses create-bot, create-bot-locale, intent APIs, build-bot-locale, create-bot-version, and create-bot-alias. Start from skeletons:
aws lexv2-models create-bot --generate-cli-skeleton input > create-bot.json
Docs: Lex V2 API, recognize-text.
Troubleshooting
| Symptom | Check |
|---|---|
Comprehend UnsupportedLanguageException | Use a supported language code and matching --language-code on entity/sentiment calls. |
| Translate autodetect fails | Use an explicit --source-language-code or a Region that supports autodetect. |
Lex test returns AccessDeniedException | Bot alias must point to a Built locale; runtime needs lex:RecognizeText on the caller. |
Next
Continue with Part 2 — Polly, Transcribe, Rekognition, Textract.