QBusiness / Client / list_messages

list_messages

QBusiness.Client.list_messages(**kwargs)

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

See also: AWS API Documentation

Request Syntax

response = client.list_messages(
    conversationId='string',
    applicationId='string',
    userId='string',
    nextToken='string',
    maxResults=123
)
Parameters:
  • conversationId (string) –

    [REQUIRED]

    The identifier of the Amazon Q Business web experience conversation.

  • applicationId (string) –

    [REQUIRED]

    The identifier for the Amazon Q Business application.

  • userId (string) – The identifier of the user involved in the Amazon Q Business web experience conversation.

  • nextToken (string) – 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.

  • maxResults (integer) – The maximum number of messages to return.

Return type:

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.

                  Note

                  This is a Tagged Union structure. Only one of the following top level keys will be set: imageSourceDetails, audioSourceDetails, videoSourceDetails. If a client receives an unknown member it will set SDK_UNKNOWN_MEMBER as the top level key, which maps to the name or tag of the unknown member. The structure of SDK_UNKNOWN_MEMBER is as follows:

                  'SDK_UNKNOWN_MEMBER': {'name': 'UnknownMemberName'}
                  
                  • 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 (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 (document) –

                      The field value.

                    • displayValue (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 (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 (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.

Exceptions

  • QBusiness.Client.exceptions.InternalServerException

  • QBusiness.Client.exceptions.ResourceNotFoundException

  • QBusiness.Client.exceptions.LicenseNotFoundException

  • QBusiness.Client.exceptions.ThrottlingException

  • QBusiness.Client.exceptions.ValidationException

  • QBusiness.Client.exceptions.AccessDeniedException