내용으로 건너뛰기

Embedding Quicksight GenerativeQnA for Registered Users "QuickSightEmbedding is not defined"

0

I am trying embed Quicksight GenerativeQnA but facing difficulty.

I have created a server in flask/python which is running and getting embed_url and sanitizing it. On frontend I have created a script which gets data.

<script>
        async function embedQuickSightSearch() {
            const response = await fetch('http://localhost:4200/get-embed-url?user_name=bhavinb');
            const data = await response.json();

            document.getElementById('debugInfo').innerText = `Received URL: ${JSON.stringify(data)}`;
            if (data.error) {
                document.getElementById('errorMessage').innerText = `Error: ${data.error}`;
                return;
            }

            const { embedUrl } = data;

            const options = {
                url: embedUrl,
                container: document.getElementById('embeddingContainer'),
                height: "600px",
                width: "800px",
                onChange: (event) => {
                    console.log('QuickSight Q Event:', event);
                }
            };

            try {
                const result = await QuickSightEmbedding.embedSearchEmbed(options);
                console.log('QuickSight Q Embed Success:', result);
            } catch (error) {
                console.error('QuickSight Q Embed Error:', error);
                document.getElementById('errorMessage').innerText = `Embedding Error Here: ${error.message}`;
            }
        }
        embedQuickSightSearch();
    </script>

But I am getting "Embedding Error Here: QuickSightEmbedding is not defined".

Note : I have added the domin(http://localhost:4200/) on Quicksight's Manage Domain section. Proper validations of credentials are passed, as a result I am getting embed_url.

Any advice would be helpful.

  • Added <script src="https://unpkg.com/amazon-quicksight-embedding-sdk@1.21.2/dist/quicksight-embedding-js-sdk.min.js"></script> in <Head> tag.

질문됨 2년 전235회 조회

1개 답변
0

The error "QuickSightEmbedding is not defined" suggests that you haven't properly included or loaded the Amazon QuickSight Embedding SDK in your HTML file. To resolve this issue, you need to include the QuickSight Embedding SDK script before using it in your code.

Here are the steps to fix this problem:

  1. Add the QuickSight Embedding SDK to your HTML file. You can do this by including the following script tag in the head section of your HTML:
<script src="https://unpkg.com/amazon-quicksight-embedding-sdk@1.x.x/dist/quicksight-embedding-js-sdk.min.js"></script>

Replace "1.x.x" with the specific version you want to use, or keep it as is to always use the latest version.

  1. Make sure this script tag is placed before your custom script that uses QuickSightEmbedding.

  2. After including the SDK, you should be able to use QuickSightEmbedding in your code.

Additionally, for embedding the Generative Q&A experience, you should use the embedGenerativeQnaExperience method instead of embedSearchEmbed. Here's how you can modify your code:

const result = await QuickSightEmbedding.embedGenerativeQnaExperience(options);

Make sure your backend is correctly configured to generate the embed URL for the Generative Q&A experience. The ExperienceConfiguration in your backend code should include the GenerativeQnA key when calling the generate_embed_url_for_registered_user API.

If you've made these changes and are still experiencing issues, double-check that your server is correctly generating the embed URL and that all necessary permissions are in place. Also, ensure that your AWS account has access to the Generative Q&A feature, as it may not be available in all regions or accounts.
Sources
Embedding the Amazon Q in QuickSight Generative Q&A experience for registered users - Amazon QuickSight
Embedding QuickSight visuals for registered users - Amazon QuickSight

답변함 2년 전

AWS
지원 엔지니어

검토됨 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.