QBusiness

2025/08/06 - QBusiness - 1 new3 updated api methods

Changes  Amazon Q Business now supports the GetDocumentContent() API that enables customers to securely access the source documents through clickable citation links at query time

GetDocumentContent (new) Link ¶

Retrieves the content of a document that was ingested into Amazon Q Business. This API validates user authorization against document ACLs before returning a pre-signed URL for secure document access. You can download or view source documents referenced in chat responses through the URL.

See also: AWS API Documentation

Request Syntax

client.get_document_content(
    applicationId='string',
    indexId='string',
    dataSourceId='string',
    documentId='string',
    outputFormat='RAW'
)
type applicationId:

string

param applicationId:

[REQUIRED]

The unique identifier of the Amazon Q Business application containing the document. This ensures the request is scoped to the correct application environment and its associated security policies.

type indexId:

string

param indexId:

[REQUIRED]

The identifier of the index where documents are indexed.

type dataSourceId:

string

param dataSourceId:

The identifier of the data source from which the document was ingested. This field is not present if the document is ingested by directly calling the BatchPutDocument API. If the document is from a file-upload data source, the datasource will be "uploaded-docs-file-stat-datasourceid".

type documentId:

string

param documentId:

[REQUIRED]

The unique identifier of the document that is indexed via BatchPutDocument API or file-upload or connector sync. It is also found in chat or chatSync response.

type outputFormat:

string

param outputFormat:

Raw document outputFormat.

rtype:

dict

returns:

Response Syntax

{
    'presignedUrl': 'string',
    'mimeType': 'string'
}

Response Structure

  • (dict) --

    • presignedUrl (string) --

      A pre-signed URL that provides temporary access to download the document content directly from Amazon Q Business. The URL expires after 5 minutes for security purposes. This URL is generated only after successful ACL validation.

    • mimeType (string) --

      The MIME type of the document content (e.g., application/pdf, text/plain, application/vnd.openxmlformats-officedocument.wordprocessingml.document).

Chat (updated) Link ¶
Changes (response)
{'outputStream': {'metadataEvent': {'sourceAttributions': {'datasourceId': 'string',
                                                           'documentId': 'string',
                                                           'indexId': 'string'}}}}

Starts or continues a streaming Amazon Q Business conversation.

See also: AWS API Documentation

Request Syntax

client.chat(
    applicationId='string',
    userId='string',
    userGroups=[
        'string',
    ],
    conversationId='string',
    parentMessageId='string',
    clientToken='string',
    inputStream={...}
)
type applicationId:

string

param applicationId:

[REQUIRED]

The identifier of the Amazon Q Business application linked to a streaming Amazon Q Business conversation.

type userId:

string

param userId:

The identifier of the user attached to the chat input.

type userGroups:

list

param userGroups:

The group names that a user associated with the chat input belongs to.

  • (string) --

type conversationId:

string

param conversationId:

The identifier of the Amazon Q Business conversation.

type parentMessageId:

string

param parentMessageId:

The identifier used to associate a user message with a AI generated response.

type clientToken:

string

param clientToken:

A token that you provide to identify the chat input.

This field is autopopulated if not provided.

type inputStream:

dict

param inputStream:

The streaming input for the Chat API.

rtype:

dict

returns:

The response of this operation contains an :class:`.EventStream` member. When iterated the :class:`.EventStream` will yield events based on the structure below, where only one of the top level keys will be present for any given event.

Response Syntax

{
    'outputStream': EventStream({
        'textEvent': {
            'systemMessageType': 'RESPONSE'|'GROUNDED_RESPONSE',
            'conversationId': 'string',
            'userMessageId': 'string',
            'systemMessageId': 'string',
            'systemMessage': 'string'
        },
        'metadataEvent': {
            'conversationId': 'string',
            'userMessageId': 'string',
            'systemMessageId': 'string',
            'sourceAttributions': [
                {
                    'title': 'string',
                    'snippet': 'string',
                    'url': 'string',
                    'citationNumber': 123,
                    'updatedAt': datetime(2015, 1, 1),
                    'textMessageSegments': [
                        {
                            'beginOffset': 123,
                            'endOffset': 123,
                            'snippetExcerpt': {
                                'text': 'string'
                            },
                            'mediaId': 'string',
                            'mediaMimeType': 'string',
                            'sourceDetails': {
                                'imageSourceDetails': {
                                    'mediaId': 'string',
                                    'mediaMimeType': 'string'
                                },
                                'audioSourceDetails': {
                                    'mediaId': 'string',
                                    'mediaMimeType': 'string',
                                    'startTimeMilliseconds': 123,
                                    'endTimeMilliseconds': 123,
                                    'audioExtractionType': 'TRANSCRIPT'|'SUMMARY'
                                },
                                'videoSourceDetails': {
                                    'mediaId': 'string',
                                    'mediaMimeType': 'string',
                                    'startTimeMilliseconds': 123,
                                    'endTimeMilliseconds': 123,
                                    'videoExtractionType': 'TRANSCRIPT'|'SUMMARY'
                                }
                            }
                        },
                    ],
                    'documentId': 'string',
                    'indexId': 'string',
                    'datasourceId': 'string'
                },
            ],
            'finalTextMessage': 'string'
        },
        'actionReviewEvent': {
            'conversationId': 'string',
            'userMessageId': 'string',
            'systemMessageId': 'string',
            'pluginId': 'string',
            'pluginType': 'SERVICE_NOW'|'SALESFORCE'|'JIRA'|'ZENDESK'|'CUSTOM'|'QUICKSIGHT'|'SERVICENOW_NOW_PLATFORM'|'JIRA_CLOUD'|'SALESFORCE_CRM'|'ZENDESK_SUITE'|'ATLASSIAN_CONFLUENCE'|'GOOGLE_CALENDAR'|'MICROSOFT_TEAMS'|'MICROSOFT_EXCHANGE'|'PAGERDUTY_ADVANCE'|'SMARTSHEET'|'ASANA',
            'payload': {
                'string': {
                    'displayName': 'string',
                    'displayOrder': 123,
                    'displayDescription': 'string',
                    'type': 'STRING'|'NUMBER'|'ARRAY'|'BOOLEAN',
                    'value': {...}|[...]|123|123.4|'string'|True|None,
                    'allowedValues': [
                        {
                            'value': {...}|[...]|123|123.4|'string'|True|None,
                            'displayValue': {...}|[...]|123|123.4|'string'|True|None
                        },
                    ],
                    'allowedFormat': 'string',
                    'arrayItemJsonSchema': {...}|[...]|123|123.4|'string'|True|None,
                    'required': True|False
                }
            },
            'payloadFieldNameSeparator': 'string'
        },
        'failedAttachmentEvent': {
            'conversationId': 'string',
            'userMessageId': 'string',
            'systemMessageId': 'string',
            'attachment': {
                'name': 'string',
                'status': 'FAILED'|'SUCCESS',
                'error': {
                    'errorMessage': 'string',
                    'errorCode': 'InternalError'|'InvalidRequest'|'ResourceInactive'|'ResourceNotFound'
                },
                'attachmentId': 'string',
                'conversationId': 'string'
            }
        },
        'authChallengeRequestEvent': {
            'authorizationUrl': 'string'
        }
    })
}

Response Structure

  • (dict) --

    • outputStream (:class:`.EventStream`) --

      The streaming output for the Chat API.

      • textEvent (dict) --

        Information about the payload of the ChatOutputStream event containing the AI-generated message output.

        • systemMessageType (string) --

          The type of AI-generated message in a TextOutputEvent. Amazon Q Business currently supports two types of messages:

          • RESPONSE - The Amazon Q Business system response.

          • GROUNDED_RESPONSE - The corrected, hallucination-reduced, response returned by Amazon Q Business. Available only if hallucination reduction is supported and configured for the application and detected in the end user chat query by Amazon Q Business.

        • conversationId (string) --

          The identifier of the conversation with which the text output event is associated.

        • userMessageId (string) --

          The identifier of an end user message in a TextOutputEvent.

        • systemMessageId (string) --

          The identifier of an AI-generated message in a TextOutputEvent.

        • systemMessage (string) --

          An AI-generated message in a TextOutputEvent.

      • metadataEvent (dict) --

        A metadata event for a AI-generated text output message in a Amazon Q Business conversation.

        • conversationId (string) --

          The identifier of the conversation with which the generated metadata is associated.

        • userMessageId (string) --

          The identifier of an Amazon Q Business end user text input message within the conversation.

        • systemMessageId (string) --

          The identifier of an Amazon Q Business AI generated message within the conversation.

        • sourceAttributions (list) --

          The source documents used to generate the conversation response.

          • (dict) --

            The documents used to generate an Amazon Q Business web experience response.

            • title (string) --

              The title of the document which is the source for the Amazon Q Business generated response.

            • snippet (string) --

              The content extract from the document on which the generated response is based.

            • url (string) --

              The URL of the document which is the source for the Amazon Q Business generated response.

            • citationNumber (integer) --

              The number attached to a citation in an Amazon Q Business generated response.

            • updatedAt (datetime) --

              The Unix timestamp when the Amazon Q Business application was last updated.

            • textMessageSegments (list) --

              A text extract from a source document that is used for source attribution.

              • (dict) --

                Provides information about a text extract in a chat response that can be attributed to a source document.

                • beginOffset (integer) --

                  The zero-based location in the response string where the source attribution starts.

                • endOffset (integer) --

                  The zero-based location in the response string where the source attribution ends.

                • snippetExcerpt (dict) --

                  The relevant text excerpt from a source that was used to generate a citation text segment in an Amazon Q Business chat response.

                  • text (string) --

                    The relevant text excerpt from a source that was used to generate a citation text segment in an Amazon Q chat response.

                • mediaId (string) --

                  The identifier of the media object associated with the text segment in the source attribution.

                • mediaMimeType (string) --

                  The MIME type (image/png) of the media object associated with the text segment in the source attribution.

                • sourceDetails (dict) --

                  Source information for a segment of extracted text, including its media type.

                  • imageSourceDetails (dict) --

                    Details specific to image content within the source.

                    • mediaId (string) --

                      Unique identifier for the image file.

                    • mediaMimeType (string) --

                      The MIME type of the image file.

                  • audioSourceDetails (dict) --

                    Details specific to audio content within the source.

                    • mediaId (string) --

                      Unique identifier for the audio media file.

                    • mediaMimeType (string) --

                      The MIME type of the audio file (e.g., audio/mp3, audio/wav).

                    • startTimeMilliseconds (integer) --

                      The starting timestamp in milliseconds for the relevant audio segment.

                    • endTimeMilliseconds (integer) --

                      The ending timestamp in milliseconds for the relevant audio segment.

                    • audioExtractionType (string) --

                      The type of audio extraction performed on the content.

                  • videoSourceDetails (dict) --

                    Details specific to video content within the source.

                    • mediaId (string) --

                      Unique identifier for the video media file.

                    • mediaMimeType (string) --

                      The MIME type of the video file (e.g., video/mp4, video/avi).

                    • startTimeMilliseconds (integer) --

                      The starting timestamp in milliseconds for the relevant video segment.

                    • endTimeMilliseconds (integer) --

                      The ending timestamp in milliseconds for the relevant video segment.

                    • videoExtractionType (string) --

                      The type of video extraction performed on the content.

            • documentId (string) --

              The unique identifier of the source document used in the citation, obtained from the Amazon Q Business index during chat response generation. This ID is used as input to the GetDocumentContent API to retrieve the actual document content for user verification.

            • indexId (string) --

              The identifier of the index containing the source document's metadata and access control information. This links the citation back to the specific Amazon Q Business index where the document's searchable content and permissions are stored.

            • datasourceId (string) --

              The identifier of the data source from which the document was ingested. This field is not present if the document is ingested by directly calling the BatchPutDocument API (similar to checkDocumentAccess). If the document is from a file-upload data source, the datasource will be "uploaded-docs-file-stat-datasourceid".

        • finalTextMessage (string) --

          The final text output message generated by the system.

      • actionReviewEvent (dict) --

        A request from Amazon Q Business to the end user for information Amazon Q Business needs to successfully complete a requested plugin action.

        • conversationId (string) --

          The identifier of the conversation with which the action review event is associated.

        • userMessageId (string) --

          The identifier of the conversation with which the plugin action is associated.

        • systemMessageId (string) --

          The identifier of an Amazon Q Business AI generated associated with the action review event.

        • pluginId (string) --

          The identifier of the plugin associated with the action review event.

        • pluginType (string) --

          The type of plugin.

        • payload (dict) --

          Field values that an end user needs to provide to Amazon Q Business for Amazon Q Business to perform the requested plugin action.

          • (string) --

            • (dict) --

              A user input field in an plugin action review payload.

              • displayName (string) --

                The name of the field.

              • displayOrder (integer) --

                The display order of fields in a payload.

              • displayDescription (string) --

                The field level description of each action review input field. This could be an explanation of the field. In the Amazon Q Business web experience, these descriptions could be used to display as tool tips to help users understand the field.

              • type (string) --

                The type of field.

              • value (:ref:`document<document>`) --

                The field value.

              • allowedValues (list) --

                Information about the field values that an end user can use to provide to Amazon Q Business for Amazon Q Business to perform the requested plugin action.

                • (dict) --

                  Information about the field values that an end user can use to provide to Amazon Q Business for Amazon Q Business to perform the requested plugin action.

                  • value (:ref:`document<document>`) --

                    The field value.

                  • displayValue (:ref:`document<document>`) --

                    The name of the field.

              • allowedFormat (string) --

                The expected data format for the action review input field value. For example, in PTO request, from and to would be of datetime allowed format.

              • arrayItemJsonSchema (:ref:`document<document>`) --

                Use to create a custom form with array fields (fields with nested objects inside an array).

              • required (boolean) --

                Information about whether the field is required.

        • payloadFieldNameSeparator (string) --

          A string used to retain information about the hierarchical contexts within an action review event payload.

      • failedAttachmentEvent (dict) --

        A failed file upload event during a web experience chat.

        • conversationId (string) --

          The identifier of the conversation associated with the failed file upload.

        • userMessageId (string) --

          The identifier of the end user chat message associated with the file upload.

        • systemMessageId (string) --

          The identifier of the AI-generated message associated with the file upload.

        • attachment (dict) --

          The details of a file uploaded during chat.

          • name (string) --

            The name of a file uploaded during chat.

          • status (string) --

            The status of a file uploaded during chat.

          • error (dict) --

            An error associated with a file uploaded during chat.

            • errorMessage (string) --

              The message explaining the Amazon Q Business request error.

            • errorCode (string) --

              The code associated with the Amazon Q Business request error.

          • attachmentId (string) --

            The unique identifier of the Amazon Q Business attachment.

          • conversationId (string) --

            The unique identifier of the Amazon Q Business conversation.

      • authChallengeRequestEvent (dict) --

        An authentication verification event activated by an end user request to use a custom plugin.

        • authorizationUrl (string) --

          The URL sent by Amazon Q Business to a third party authentication server in response to an authentication verification event activated by an end user request to use a custom plugin.

ChatSync (updated) Link ¶
Changes (response)
{'sourceAttributions': {'datasourceId': 'string',
                        'documentId': 'string',
                        'indexId': 'string'}}

Starts or continues a non-streaming Amazon Q Business conversation.

See also: AWS API Documentation

Request Syntax

client.chat_sync(
    applicationId='string',
    userId='string',
    userGroups=[
        'string',
    ],
    userMessage='string',
    attachments=[
        {
            'data': b'bytes',
            'name': 'string',
            'copyFrom': {
                'conversation': {
                    'conversationId': 'string',
                    'attachmentId': 'string'
                }
            }
        },
    ],
    actionExecution={
        'pluginId': 'string',
        'payload': {
            'string': {
                'value': {...}|[...]|123|123.4|'string'|True|None
            }
        },
        'payloadFieldNameSeparator': 'string'
    },
    authChallengeResponse={
        'responseMap': {
            'string': 'string'
        }
    },
    conversationId='string',
    parentMessageId='string',
    attributeFilter={
        'andAllFilters': [
            {'... recursive ...'},
        ],
        'orAllFilters': [
            {'... recursive ...'},
        ],
        'notFilter': {'... recursive ...'},
        'equalsTo': {
            'name': 'string',
            'value': {
                'stringValue': 'string',
                'stringListValue': [
                    'string',
                ],
                'longValue': 123,
                'dateValue': datetime(2015, 1, 1)
            }
        },
        'containsAll': {
            'name': 'string',
            'value': {
                'stringValue': 'string',
                'stringListValue': [
                    'string',
                ],
                'longValue': 123,
                'dateValue': datetime(2015, 1, 1)
            }
        },
        'containsAny': {
            'name': 'string',
            'value': {
                'stringValue': 'string',
                'stringListValue': [
                    'string',
                ],
                'longValue': 123,
                'dateValue': datetime(2015, 1, 1)
            }
        },
        'greaterThan': {
            'name': 'string',
            'value': {
                'stringValue': 'string',
                'stringListValue': [
                    'string',
                ],
                'longValue': 123,
                'dateValue': datetime(2015, 1, 1)
            }
        },
        'greaterThanOrEquals': {
            'name': 'string',
            'value': {
                'stringValue': 'string',
                'stringListValue': [
                    'string',
                ],
                'longValue': 123,
                'dateValue': datetime(2015, 1, 1)
            }
        },
        'lessThan': {
            'name': 'string',
            'value': {
                'stringValue': 'string',
                'stringListValue': [
                    'string',
                ],
                'longValue': 123,
                'dateValue': datetime(2015, 1, 1)
            }
        },
        'lessThanOrEquals': {
            'name': 'string',
            'value': {
                'stringValue': 'string',
                'stringListValue': [
                    'string',
                ],
                'longValue': 123,
                'dateValue': datetime(2015, 1, 1)
            }
        }
    },
    chatMode='RETRIEVAL_MODE'|'CREATOR_MODE'|'PLUGIN_MODE',
    chatModeConfiguration={
        'pluginConfiguration': {
            'pluginId': 'string'
        }
    },
    clientToken='string'
)
type applicationId:

string

param applicationId:

[REQUIRED]

The identifier of the Amazon Q Business application linked to the Amazon Q Business conversation.

type userId:

string

param userId:

The identifier of the user attached to the chat input.

type userGroups:

list

param userGroups:

The group names that a user associated with the chat input belongs to.

  • (string) --

type userMessage:

string

param userMessage:

A end user message in a conversation.

type attachments:

list

param attachments:

A list of files uploaded directly during chat. You can upload a maximum of 5 files of upto 10 MB each.

  • (dict) --

    This is either a file directly uploaded into a web experience chat or a reference to an existing attachment that is part of a web experience chat.

    • data (bytes) --

      The contents of the attachment.

    • name (string) --

      The filename of the attachment.

    • copyFrom (dict) --

      A reference to an existing attachment.

      • conversation (dict) --

        A reference to an attachment in an existing conversation.

        • conversationId (string) -- [REQUIRED]

          The unique identifier of the Amazon Q Business conversation.

        • attachmentId (string) -- [REQUIRED]

          The unique identifier of the Amazon Q Business attachment.

type actionExecution:

dict

param actionExecution:

A request from an end user to perform an Amazon Q Business plugin action.

  • pluginId (string) -- [REQUIRED]

    The identifier of the plugin the action is attached to.

  • payload (dict) -- [REQUIRED]

    A mapping of field names to the field values in input that an end user provides to Amazon Q Business requests to perform their plugin action.

    • (string) --

      • (dict) --

        A user input field in an plugin action execution payload.

        • value (:ref:`document<document>`) -- [REQUIRED]

          The content of a user input field in an plugin action execution payload.

  • payloadFieldNameSeparator (string) -- [REQUIRED]

    A string used to retain information about the hierarchical contexts within an action execution event payload.

type authChallengeResponse:

dict

param authChallengeResponse:

An authentication verification event response by a third party authentication server to Amazon Q Business.

  • responseMap (dict) -- [REQUIRED]

    The mapping of key-value pairs in an authentication challenge response.

    • (string) --

      • (string) --

type conversationId:

string

param conversationId:

The identifier of the Amazon Q Business conversation.

type parentMessageId:

string

param parentMessageId:

The identifier of the previous system message in a conversation.

type attributeFilter:

dict

param attributeFilter:

Enables filtering of Amazon Q Business web experience responses based on document attributes or metadata fields.

  • andAllFilters (list) --

    Performs a logical AND operation on all supplied filters.

    • (dict) --

      Enables filtering of responses based on document attributes or metadata fields.

  • orAllFilters (list) --

    Performs a logical OR operation on all supplied filters.

    • (dict) --

      Enables filtering of responses based on document attributes or metadata fields.

  • notFilter (dict) --

    Performs a logical NOT operation on all supplied filters.

  • equalsTo (dict) --

    Performs an equals operation on two document attributes or metadata fields. Supported for the following document attribute value types: dateValue, longValue, stringListValue and stringValue.

    • name (string) -- [REQUIRED]

      The identifier for the attribute.

    • value (dict) -- [REQUIRED]

      The value of the attribute.

      • stringValue (string) --

        A string.

      • stringListValue (list) --

        A list of strings.

        • (string) --

      • longValue (integer) --

        A long integer value.

      • dateValue (datetime) --

        A date expressed as an ISO 8601 string.

        It's important for the time zone to be included in the ISO 8601 date-time format. For example, 2012-03-25T12:30:10+01:00 is the ISO 8601 date-time format for March 25th 2012 at 12:30PM (plus 10 seconds) in Central European Time.

  • containsAll (dict) --

    Returns true when a document contains all the specified document attributes or metadata fields. Supported for the following document attribute value types: stringListValue.

    • name (string) -- [REQUIRED]

      The identifier for the attribute.

    • value (dict) -- [REQUIRED]

      The value of the attribute.

      • stringValue (string) --

        A string.

      • stringListValue (list) --

        A list of strings.

        • (string) --

      • longValue (integer) --

        A long integer value.

      • dateValue (datetime) --

        A date expressed as an ISO 8601 string.

        It's important for the time zone to be included in the ISO 8601 date-time format. For example, 2012-03-25T12:30:10+01:00 is the ISO 8601 date-time format for March 25th 2012 at 12:30PM (plus 10 seconds) in Central European Time.

  • containsAny (dict) --

    Returns true when a document contains any of the specified document attributes or metadata fields. Supported for the following document attribute value types: stringListValue.

    • name (string) -- [REQUIRED]

      The identifier for the attribute.

    • value (dict) -- [REQUIRED]

      The value of the attribute.

      • stringValue (string) --

        A string.

      • stringListValue (list) --

        A list of strings.

        • (string) --

      • longValue (integer) --

        A long integer value.

      • dateValue (datetime) --

        A date expressed as an ISO 8601 string.

        It's important for the time zone to be included in the ISO 8601 date-time format. For example, 2012-03-25T12:30:10+01:00 is the ISO 8601 date-time format for March 25th 2012 at 12:30PM (plus 10 seconds) in Central European Time.

  • greaterThan (dict) --

    Performs a greater than operation on two document attributes or metadata fields. Supported for the following document attribute value types: dateValue and longValue.

    • name (string) -- [REQUIRED]

      The identifier for the attribute.

    • value (dict) -- [REQUIRED]

      The value of the attribute.

      • stringValue (string) --

        A string.

      • stringListValue (list) --

        A list of strings.

        • (string) --

      • longValue (integer) --

        A long integer value.

      • dateValue (datetime) --

        A date expressed as an ISO 8601 string.

        It's important for the time zone to be included in the ISO 8601 date-time format. For example, 2012-03-25T12:30:10+01:00 is the ISO 8601 date-time format for March 25th 2012 at 12:30PM (plus 10 seconds) in Central European Time.

  • greaterThanOrEquals (dict) --

    Performs a greater or equals than operation on two document attributes or metadata fields. Supported for the following document attribute value types: dateValue and longValue.

    • name (string) -- [REQUIRED]

      The identifier for the attribute.

    • value (dict) -- [REQUIRED]

      The value of the attribute.

      • stringValue (string) --

        A string.

      • stringListValue (list) --

        A list of strings.

        • (string) --

      • longValue (integer) --

        A long integer value.

      • dateValue (datetime) --

        A date expressed as an ISO 8601 string.

        It's important for the time zone to be included in the ISO 8601 date-time format. For example, 2012-03-25T12:30:10+01:00 is the ISO 8601 date-time format for March 25th 2012 at 12:30PM (plus 10 seconds) in Central European Time.

  • lessThan (dict) --

    Performs a less than operation on two document attributes or metadata fields. Supported for the following document attribute value types: dateValue and longValue.

    • name (string) -- [REQUIRED]

      The identifier for the attribute.

    • value (dict) -- [REQUIRED]

      The value of the attribute.

      • stringValue (string) --

        A string.

      • stringListValue (list) --

        A list of strings.

        • (string) --

      • longValue (integer) --

        A long integer value.

      • dateValue (datetime) --

        A date expressed as an ISO 8601 string.

        It's important for the time zone to be included in the ISO 8601 date-time format. For example, 2012-03-25T12:30:10+01:00 is the ISO 8601 date-time format for March 25th 2012 at 12:30PM (plus 10 seconds) in Central European Time.

  • lessThanOrEquals (dict) --

    Performs a less than or equals operation on two document attributes or metadata fields.Supported for the following document attribute value type: dateValue and longValue.

    • name (string) -- [REQUIRED]

      The identifier for the attribute.

    • value (dict) -- [REQUIRED]

      The value of the attribute.

      • stringValue (string) --

        A string.

      • stringListValue (list) --

        A list of strings.

        • (string) --

      • longValue (integer) --

        A long integer value.

      • dateValue (datetime) --

        A date expressed as an ISO 8601 string.

        It's important for the time zone to be included in the ISO 8601 date-time format. For example, 2012-03-25T12:30:10+01:00 is the ISO 8601 date-time format for March 25th 2012 at 12:30PM (plus 10 seconds) in Central European Time.

type chatMode:

string

param chatMode:

The chatMode parameter determines the chat modes available to Amazon Q Business users:

  • RETRIEVAL_MODE - If you choose this mode, Amazon Q generates responses solely from the data sources connected and indexed by the application. If an answer is not found in the data sources or there are no data sources available, Amazon Q will respond with a "No Answer Found" message, unless LLM knowledge has been enabled. In that case, Amazon Q will generate a response from the LLM knowledge

  • CREATOR_MODE - By selecting this mode, you can choose to generate responses only from the LLM knowledge. You can also attach files and have Amazon Q generate a response based on the data in those files. If the attached files do not contain an answer for the query, Amazon Q will automatically fall back to generating a response from the LLM knowledge.

  • PLUGIN_MODE - By selecting this mode, users can choose to use plugins in chat to get their responses.

For more information, see Admin controls and guardrails, Plugins, and Response sources.

type chatModeConfiguration:

dict

param chatModeConfiguration:

The chat mode configuration for an Amazon Q Business application.

  • pluginConfiguration (dict) --

    Configuration information required to invoke chat in PLUGIN_MODE.

    • pluginId (string) -- [REQUIRED]

      The identifier of the plugin you want to use.

type clientToken:

string

param clientToken:

A token that you provide to identify a chat request.

This field is autopopulated if not provided.

rtype:

dict

returns:

Response Syntax

{
    'conversationId': 'string',
    'systemMessage': 'string',
    'systemMessageId': 'string',
    'userMessageId': 'string',
    'actionReview': {
        'pluginId': 'string',
        'pluginType': 'SERVICE_NOW'|'SALESFORCE'|'JIRA'|'ZENDESK'|'CUSTOM'|'QUICKSIGHT'|'SERVICENOW_NOW_PLATFORM'|'JIRA_CLOUD'|'SALESFORCE_CRM'|'ZENDESK_SUITE'|'ATLASSIAN_CONFLUENCE'|'GOOGLE_CALENDAR'|'MICROSOFT_TEAMS'|'MICROSOFT_EXCHANGE'|'PAGERDUTY_ADVANCE'|'SMARTSHEET'|'ASANA',
        'payload': {
            'string': {
                'displayName': 'string',
                'displayOrder': 123,
                'displayDescription': 'string',
                'type': 'STRING'|'NUMBER'|'ARRAY'|'BOOLEAN',
                'value': {...}|[...]|123|123.4|'string'|True|None,
                'allowedValues': [
                    {
                        'value': {...}|[...]|123|123.4|'string'|True|None,
                        'displayValue': {...}|[...]|123|123.4|'string'|True|None
                    },
                ],
                'allowedFormat': 'string',
                'arrayItemJsonSchema': {...}|[...]|123|123.4|'string'|True|None,
                'required': True|False
            }
        },
        'payloadFieldNameSeparator': 'string'
    },
    'authChallengeRequest': {
        'authorizationUrl': 'string'
    },
    'sourceAttributions': [
        {
            'title': 'string',
            'snippet': 'string',
            'url': 'string',
            'citationNumber': 123,
            'updatedAt': datetime(2015, 1, 1),
            'textMessageSegments': [
                {
                    'beginOffset': 123,
                    'endOffset': 123,
                    'snippetExcerpt': {
                        'text': 'string'
                    },
                    'mediaId': 'string',
                    'mediaMimeType': 'string',
                    'sourceDetails': {
                        'imageSourceDetails': {
                            'mediaId': 'string',
                            'mediaMimeType': 'string'
                        },
                        'audioSourceDetails': {
                            'mediaId': 'string',
                            'mediaMimeType': 'string',
                            'startTimeMilliseconds': 123,
                            'endTimeMilliseconds': 123,
                            'audioExtractionType': 'TRANSCRIPT'|'SUMMARY'
                        },
                        'videoSourceDetails': {
                            'mediaId': 'string',
                            'mediaMimeType': 'string',
                            'startTimeMilliseconds': 123,
                            'endTimeMilliseconds': 123,
                            'videoExtractionType': 'TRANSCRIPT'|'SUMMARY'
                        }
                    }
                },
            ],
            'documentId': 'string',
            'indexId': 'string',
            'datasourceId': 'string'
        },
    ],
    'failedAttachments': [
        {
            'name': 'string',
            'status': 'FAILED'|'SUCCESS',
            'error': {
                'errorMessage': 'string',
                'errorCode': 'InternalError'|'InvalidRequest'|'ResourceInactive'|'ResourceNotFound'
            },
            'attachmentId': 'string',
            'conversationId': 'string'
        },
    ]
}

Response Structure

  • (dict) --

    • conversationId (string) --

      The identifier of the Amazon Q Business conversation.

    • systemMessage (string) --

      An AI-generated message in a conversation.

    • systemMessageId (string) --

      The identifier of an Amazon Q Business AI generated message within the conversation.

    • userMessageId (string) --

      The identifier of an Amazon Q Business end user text input message within the conversation.

    • actionReview (dict) --

      A request from Amazon Q Business to the end user for information Amazon Q Business needs to successfully complete a requested plugin action.

      • pluginId (string) --

        The identifier of the plugin associated with the action review.

      • pluginType (string) --

        The type of plugin.

      • payload (dict) --

        Field values that an end user needs to provide to Amazon Q Business for Amazon Q Business to perform the requested plugin action.

        • (string) --

          • (dict) --

            A user input field in an plugin action review payload.

            • displayName (string) --

              The name of the field.

            • displayOrder (integer) --

              The display order of fields in a payload.

            • displayDescription (string) --

              The field level description of each action review input field. This could be an explanation of the field. In the Amazon Q Business web experience, these descriptions could be used to display as tool tips to help users understand the field.

            • type (string) --

              The type of field.

            • value (:ref:`document<document>`) --

              The field value.

            • allowedValues (list) --

              Information about the field values that an end user can use to provide to Amazon Q Business for Amazon Q Business to perform the requested plugin action.

              • (dict) --

                Information about the field values that an end user can use to provide to Amazon Q Business for Amazon Q Business to perform the requested plugin action.

                • value (:ref:`document<document>`) --

                  The field value.

                • displayValue (:ref:`document<document>`) --

                  The name of the field.

            • allowedFormat (string) --

              The expected data format for the action review input field value. For example, in PTO request, from and to would be of datetime allowed format.

            • arrayItemJsonSchema (:ref:`document<document>`) --

              Use to create a custom form with array fields (fields with nested objects inside an array).

            • required (boolean) --

              Information about whether the field is required.

      • payloadFieldNameSeparator (string) --

        A string used to retain information about the hierarchical contexts within an action review payload.

    • authChallengeRequest (dict) --

      An authentication verification event activated by an end user request to use a custom plugin.

      • authorizationUrl (string) --

        The URL sent by Amazon Q Business to the third party authentication server to authenticate a custom plugin user through an OAuth protocol.

    • sourceAttributions (list) --

      The source documents used to generate the conversation response.

      • (dict) --

        The documents used to generate an Amazon Q Business web experience response.

        • title (string) --

          The title of the document which is the source for the Amazon Q Business generated response.

        • snippet (string) --

          The content extract from the document on which the generated response is based.

        • url (string) --

          The URL of the document which is the source for the Amazon Q Business generated response.

        • citationNumber (integer) --

          The number attached to a citation in an Amazon Q Business generated response.

        • updatedAt (datetime) --

          The Unix timestamp when the Amazon Q Business application was last updated.

        • textMessageSegments (list) --

          A text extract from a source document that is used for source attribution.

          • (dict) --

            Provides information about a text extract in a chat response that can be attributed to a source document.

            • beginOffset (integer) --

              The zero-based location in the response string where the source attribution starts.

            • endOffset (integer) --

              The zero-based location in the response string where the source attribution ends.

            • snippetExcerpt (dict) --

              The relevant text excerpt from a source that was used to generate a citation text segment in an Amazon Q Business chat response.

              • text (string) --

                The relevant text excerpt from a source that was used to generate a citation text segment in an Amazon Q chat response.

            • mediaId (string) --

              The identifier of the media object associated with the text segment in the source attribution.

            • mediaMimeType (string) --

              The MIME type (image/png) of the media object associated with the text segment in the source attribution.

            • sourceDetails (dict) --

              Source information for a segment of extracted text, including its media type.

              • imageSourceDetails (dict) --

                Details specific to image content within the source.

                • mediaId (string) --

                  Unique identifier for the image file.

                • mediaMimeType (string) --

                  The MIME type of the image file.

              • audioSourceDetails (dict) --

                Details specific to audio content within the source.

                • mediaId (string) --

                  Unique identifier for the audio media file.

                • mediaMimeType (string) --

                  The MIME type of the audio file (e.g., audio/mp3, audio/wav).

                • startTimeMilliseconds (integer) --

                  The starting timestamp in milliseconds for the relevant audio segment.

                • endTimeMilliseconds (integer) --

                  The ending timestamp in milliseconds for the relevant audio segment.

                • audioExtractionType (string) --

                  The type of audio extraction performed on the content.

              • videoSourceDetails (dict) --

                Details specific to video content within the source.

                • mediaId (string) --

                  Unique identifier for the video media file.

                • mediaMimeType (string) --

                  The MIME type of the video file (e.g., video/mp4, video/avi).

                • startTimeMilliseconds (integer) --

                  The starting timestamp in milliseconds for the relevant video segment.

                • endTimeMilliseconds (integer) --

                  The ending timestamp in milliseconds for the relevant video segment.

                • videoExtractionType (string) --

                  The type of video extraction performed on the content.

        • documentId (string) --

          The unique identifier of the source document used in the citation, obtained from the Amazon Q Business index during chat response generation. This ID is used as input to the GetDocumentContent API to retrieve the actual document content for user verification.

        • indexId (string) --

          The identifier of the index containing the source document's metadata and access control information. This links the citation back to the specific Amazon Q Business index where the document's searchable content and permissions are stored.

        • datasourceId (string) --

          The identifier of the data source from which the document was ingested. This field is not present if the document is ingested by directly calling the BatchPutDocument API (similar to checkDocumentAccess). If the document is from a file-upload data source, the datasource will be "uploaded-docs-file-stat-datasourceid".

    • failedAttachments (list) --

      A list of files which failed to upload during chat.

      • (dict) --

        The details of a file uploaded during chat.

        • name (string) --

          The name of a file uploaded during chat.

        • status (string) --

          The status of a file uploaded during chat.

        • error (dict) --

          An error associated with a file uploaded during chat.

          • errorMessage (string) --

            The message explaining the Amazon Q Business request error.

          • errorCode (string) --

            The code associated with the Amazon Q Business request error.

        • attachmentId (string) --

          The unique identifier of the Amazon Q Business attachment.

        • conversationId (string) --

          The unique identifier of the Amazon Q Business conversation.

ListMessages (updated) Link ¶
Changes (response)
{'messages': {'sourceAttribution': {'datasourceId': 'string',
                                    'documentId': 'string',
                                    'indexId': 'string'}}}

Gets a list of messages associated with an Amazon Q Business web experience.

See also: AWS API Documentation

Request Syntax

client.list_messages(
    conversationId='string',
    applicationId='string',
    userId='string',
    nextToken='string',
    maxResults=123
)
type conversationId:

string

param conversationId:

[REQUIRED]

The identifier of the Amazon Q Business web experience conversation.

type applicationId:

string

param applicationId:

[REQUIRED]

The identifier for the Amazon Q Business application.

type userId:

string

param userId:

The identifier of the user involved in the Amazon Q Business web experience conversation.

type nextToken:

string

param nextToken:

If the number of messages returned exceeds maxResults, Amazon Q Business returns a next token as a pagination token to retrieve the next set of messages.

type maxResults:

integer

param maxResults:

The maximum number of messages to return.

rtype:

dict

returns:

Response Syntax

{
    'messages': [
        {
            'messageId': 'string',
            'body': 'string',
            'time': datetime(2015, 1, 1),
            'type': 'USER'|'SYSTEM',
            'attachments': [
                {
                    'name': 'string',
                    'status': 'FAILED'|'SUCCESS',
                    'error': {
                        'errorMessage': 'string',
                        'errorCode': 'InternalError'|'InvalidRequest'|'ResourceInactive'|'ResourceNotFound'
                    },
                    'attachmentId': 'string',
                    'conversationId': 'string'
                },
            ],
            'sourceAttribution': [
                {
                    'title': 'string',
                    'snippet': 'string',
                    'url': 'string',
                    'citationNumber': 123,
                    'updatedAt': datetime(2015, 1, 1),
                    'textMessageSegments': [
                        {
                            'beginOffset': 123,
                            'endOffset': 123,
                            'snippetExcerpt': {
                                'text': 'string'
                            },
                            'mediaId': 'string',
                            'mediaMimeType': 'string',
                            'sourceDetails': {
                                'imageSourceDetails': {
                                    'mediaId': 'string',
                                    'mediaMimeType': 'string'
                                },
                                'audioSourceDetails': {
                                    'mediaId': 'string',
                                    'mediaMimeType': 'string',
                                    'startTimeMilliseconds': 123,
                                    'endTimeMilliseconds': 123,
                                    'audioExtractionType': 'TRANSCRIPT'|'SUMMARY'
                                },
                                'videoSourceDetails': {
                                    'mediaId': 'string',
                                    'mediaMimeType': 'string',
                                    'startTimeMilliseconds': 123,
                                    'endTimeMilliseconds': 123,
                                    'videoExtractionType': 'TRANSCRIPT'|'SUMMARY'
                                }
                            }
                        },
                    ],
                    'documentId': 'string',
                    'indexId': 'string',
                    'datasourceId': 'string'
                },
            ],
            'actionReview': {
                'pluginId': 'string',
                'pluginType': 'SERVICE_NOW'|'SALESFORCE'|'JIRA'|'ZENDESK'|'CUSTOM'|'QUICKSIGHT'|'SERVICENOW_NOW_PLATFORM'|'JIRA_CLOUD'|'SALESFORCE_CRM'|'ZENDESK_SUITE'|'ATLASSIAN_CONFLUENCE'|'GOOGLE_CALENDAR'|'MICROSOFT_TEAMS'|'MICROSOFT_EXCHANGE'|'PAGERDUTY_ADVANCE'|'SMARTSHEET'|'ASANA',
                'payload': {
                    'string': {
                        'displayName': 'string',
                        'displayOrder': 123,
                        'displayDescription': 'string',
                        'type': 'STRING'|'NUMBER'|'ARRAY'|'BOOLEAN',
                        'value': {...}|[...]|123|123.4|'string'|True|None,
                        'allowedValues': [
                            {
                                'value': {...}|[...]|123|123.4|'string'|True|None,
                                'displayValue': {...}|[...]|123|123.4|'string'|True|None
                            },
                        ],
                        'allowedFormat': 'string',
                        'arrayItemJsonSchema': {...}|[...]|123|123.4|'string'|True|None,
                        'required': True|False
                    }
                },
                'payloadFieldNameSeparator': 'string'
            },
            'actionExecution': {
                'pluginId': 'string',
                'payload': {
                    'string': {
                        'value': {...}|[...]|123|123.4|'string'|True|None
                    }
                },
                'payloadFieldNameSeparator': 'string'
            }
        },
    ],
    'nextToken': 'string'
}

Response Structure

  • (dict) --

    • messages (list) --

      An array of information on one or more messages.

      • (dict) --

        A message in an Amazon Q Business web experience.

        • messageId (string) --

          The identifier of the Amazon Q Business web experience message.

        • body (string) --

          The content of the Amazon Q Business web experience message.

        • time (datetime) --

          The timestamp of the first Amazon Q Business web experience message.

        • type (string) --

          The type of Amazon Q Business message, whether HUMAN or AI generated.

        • attachments (list) --

          A file directly uploaded into an Amazon Q Business web experience chat.

          • (dict) --

            The details of a file uploaded during chat.

            • name (string) --

              The name of a file uploaded during chat.

            • status (string) --

              The status of a file uploaded during chat.

            • error (dict) --

              An error associated with a file uploaded during chat.

              • errorMessage (string) --

                The message explaining the Amazon Q Business request error.

              • errorCode (string) --

                The code associated with the Amazon Q Business request error.

            • attachmentId (string) --

              The unique identifier of the Amazon Q Business attachment.

            • conversationId (string) --

              The unique identifier of the Amazon Q Business conversation.

        • sourceAttribution (list) --

          The source documents used to generate Amazon Q Business web experience message.

          • (dict) --

            The documents used to generate an Amazon Q Business web experience response.

            • title (string) --

              The title of the document which is the source for the Amazon Q Business generated response.

            • snippet (string) --

              The content extract from the document on which the generated response is based.

            • url (string) --

              The URL of the document which is the source for the Amazon Q Business generated response.

            • citationNumber (integer) --

              The number attached to a citation in an Amazon Q Business generated response.

            • updatedAt (datetime) --

              The Unix timestamp when the Amazon Q Business application was last updated.

            • textMessageSegments (list) --

              A text extract from a source document that is used for source attribution.

              • (dict) --

                Provides information about a text extract in a chat response that can be attributed to a source document.

                • beginOffset (integer) --

                  The zero-based location in the response string where the source attribution starts.

                • endOffset (integer) --

                  The zero-based location in the response string where the source attribution ends.

                • snippetExcerpt (dict) --

                  The relevant text excerpt from a source that was used to generate a citation text segment in an Amazon Q Business chat response.

                  • text (string) --

                    The relevant text excerpt from a source that was used to generate a citation text segment in an Amazon Q chat response.

                • mediaId (string) --

                  The identifier of the media object associated with the text segment in the source attribution.

                • mediaMimeType (string) --

                  The MIME type (image/png) of the media object associated with the text segment in the source attribution.

                • sourceDetails (dict) --

                  Source information for a segment of extracted text, including its media type.

                  • imageSourceDetails (dict) --

                    Details specific to image content within the source.

                    • mediaId (string) --

                      Unique identifier for the image file.

                    • mediaMimeType (string) --

                      The MIME type of the image file.

                  • audioSourceDetails (dict) --

                    Details specific to audio content within the source.

                    • mediaId (string) --

                      Unique identifier for the audio media file.

                    • mediaMimeType (string) --

                      The MIME type of the audio file (e.g., audio/mp3, audio/wav).

                    • startTimeMilliseconds (integer) --

                      The starting timestamp in milliseconds for the relevant audio segment.

                    • endTimeMilliseconds (integer) --

                      The ending timestamp in milliseconds for the relevant audio segment.

                    • audioExtractionType (string) --

                      The type of audio extraction performed on the content.

                  • videoSourceDetails (dict) --

                    Details specific to video content within the source.

                    • mediaId (string) --

                      Unique identifier for the video media file.

                    • mediaMimeType (string) --

                      The MIME type of the video file (e.g., video/mp4, video/avi).

                    • startTimeMilliseconds (integer) --

                      The starting timestamp in milliseconds for the relevant video segment.

                    • endTimeMilliseconds (integer) --

                      The ending timestamp in milliseconds for the relevant video segment.

                    • videoExtractionType (string) --

                      The type of video extraction performed on the content.

            • documentId (string) --

              The unique identifier of the source document used in the citation, obtained from the Amazon Q Business index during chat response generation. This ID is used as input to the GetDocumentContent API to retrieve the actual document content for user verification.

            • indexId (string) --

              The identifier of the index containing the source document's metadata and access control information. This links the citation back to the specific Amazon Q Business index where the document's searchable content and permissions are stored.

            • datasourceId (string) --

              The identifier of the data source from which the document was ingested. This field is not present if the document is ingested by directly calling the BatchPutDocument API (similar to checkDocumentAccess). If the document is from a file-upload data source, the datasource will be "uploaded-docs-file-stat-datasourceid".

        • actionReview (dict) --

          An output event that Amazon Q Business returns to an user who wants to perform a plugin action during a non-streaming chat conversation. It contains information about the selected action with a list of possible user input fields, some pre-populated by Amazon Q Business.

          • pluginId (string) --

            The identifier of the plugin associated with the action review.

          • pluginType (string) --

            The type of plugin.

          • payload (dict) --

            Field values that an end user needs to provide to Amazon Q Business for Amazon Q Business to perform the requested plugin action.

            • (string) --

              • (dict) --

                A user input field in an plugin action review payload.

                • displayName (string) --

                  The name of the field.

                • displayOrder (integer) --

                  The display order of fields in a payload.

                • displayDescription (string) --

                  The field level description of each action review input field. This could be an explanation of the field. In the Amazon Q Business web experience, these descriptions could be used to display as tool tips to help users understand the field.

                • type (string) --

                  The type of field.

                • value (:ref:`document<document>`) --

                  The field value.

                • allowedValues (list) --

                  Information about the field values that an end user can use to provide to Amazon Q Business for Amazon Q Business to perform the requested plugin action.

                  • (dict) --

                    Information about the field values that an end user can use to provide to Amazon Q Business for Amazon Q Business to perform the requested plugin action.

                    • value (:ref:`document<document>`) --

                      The field value.

                    • displayValue (:ref:`document<document>`) --

                      The name of the field.

                • allowedFormat (string) --

                  The expected data format for the action review input field value. For example, in PTO request, from and to would be of datetime allowed format.

                • arrayItemJsonSchema (:ref:`document<document>`) --

                  Use to create a custom form with array fields (fields with nested objects inside an array).

                • required (boolean) --

                  Information about whether the field is required.

          • payloadFieldNameSeparator (string) --

            A string used to retain information about the hierarchical contexts within an action review payload.

        • actionExecution (dict) --

          Performs an Amazon Q Business plugin action during a non-streaming chat conversation.

          • pluginId (string) --

            The identifier of the plugin the action is attached to.

          • payload (dict) --

            A mapping of field names to the field values in input that an end user provides to Amazon Q Business requests to perform their plugin action.

            • (string) --

              • (dict) --

                A user input field in an plugin action execution payload.

                • value (:ref:`document<document>`) --

                  The content of a user input field in an plugin action execution payload.

          • payloadFieldNameSeparator (string) --

            A string used to retain information about the hierarchical contexts within an action execution event payload.

    • nextToken (string) --

      If the response is truncated, Amazon Q Business returns this token, which you can use in a later request to list the next set of messages.