LexRuntimeV2Client.recognize_text
rboto-lex-runtime-v2==0.4.0 · Service index · Types
Model summary (excerpt): Sends user input to Amazon Lex V2. Client applications use this API to send requests to Amazon Lex V2 at runtime. Amazon Lex V2 then interprets the user input using the machine learning model that it build for the bot. In response, Amazon Lex V2 returns the next message to convey to the user and an optional response card to display. If the optional post-fulfillment response is specified, the...
Install and imports
from rboto import LexRuntimeV2Client
from rboto_lex_runtime_v2.types import (
RecognizeTextOutput,
SessionState,
)
Signature
async def recognize_text(
*,
bot_id: str,
bot_alias_id: str,
locale_id: str,
session_id: str,
text: str,
session_state: SessionState | None = None,
request_attributes: dict[str, str] | None = None,
) -> RecognizeTextOutput: ...
Arguments without defaults are required. None omits an optional request argument. Static types do not validate resource existence, permissions, lengths, ranges, or conditional service requirements.
Arguments
| Argument | Required | Model notes (excerpt) |
|---|---|---|
bot_id |
Yes | The identifier of the bot that processes the request. |
bot_alias_id |
Yes | The alias identifier in use for the bot that processes the request. |
locale_id |
Yes | The locale where the session is in use. |
session_id |
Yes | The identifier of the user session that is having the conversation. |
text |
Yes | The text that the user entered. Amazon Lex V2 interprets this text. |
session_state |
No | The current state of the dialog between the user and the bot. |
request_attributes |
No | Request-specific information passed between the client application and Amazon Lex V2 The namespace x-amz-lex: is reserved for special attributes. Don't create any request attributes with the prefix x-amz-lex: . |
Output
RecognizeTextOutput.
Read-only native attributes, accessed as response.field. Collection getters materialize Python values; to_dict() recursively materializes a mapping. Streams are consumed once.
| Field | Type | Presence | References |
|---|---|---|---|
messages |
list[MessageValueOutput] | None |
Always present | MessageValueOutput |
session_state |
SessionStateValueOutput | None |
Always present | SessionStateValueOutput |
interpretations |
list[InterpretationOutput] | None |
Always present | InterpretationOutput |
request_attributes |
dict[str, str] | None |
Always present | — |
session_id |
str | None |
Always present | — |
recognized_bot_member |
RecognizedBotMemberOutput | None |
Always present | RecognizedBotMemberOutput |
| None means a value can be absent. Output mappings include every declared key; optional input keys may be omitted. Unknown output enum/union variants are not automatically valid inputs.
Related types
RecognizeTextOutput, SessionState
Follow these links for nested inputs and outputs; recursive types link back to the same type page.
Pagination and streaming
No generated paginator for this operation.
No output stream.
Errors
Import from rboto_lex_runtime_v2.exceptions:
AccessDeniedError, BadGatewayError, ConflictError, DependencyFailedError, InternalServerError, ResourceNotFoundError, ThrottlingError, ValidationError.
Other service failures use the service base error; credential, transport and timeout failures use shared errors.
Example
Complete, type-checked service example. Replace its placeholders and configure credentials before running it.
import asyncio
from rboto import LexRuntimeV2Client
async def main() -> None:
client = LexRuntimeV2Client(region="us-east-1")
response = await client.recognize_text(
bot_id="YOUR_BOT_ID",
bot_alias_id="YOUR_ALIAS_ID",
locale_id="en_US",
session_id="example-session",
text="I need help with my order",
)
print(response.messages)
if __name__ == "__main__":
asyncio.run(main())