amazon-connect/amazon-connect-chatjs

getTranscript not working for agent chat session

Closed this issue · 3 comments

Hi,

When i try to get the chat transcript i get the below error:

access to XMLHttpRequest at 'https://participant.connect.us-west-2.amazonaws.com/participant/event' from origin 'http://127.0.0.1:5501' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Code:
<script src="lib/connect-streams-min.js"></script>
<script src="lib/amazon-connect-chat.js"></script>

async function handleContactIncoming(contact) {
    console.log(contact, 'handleContactIncoming', 'Contact is incoming');
    console.log('connection: ', currentContact);
    console.log('CurrentQ: ', contact.getQueue().name);
    console.log('customerNo: ', currentContact.customerNo);
    console.log('QueueType: ', contact.getType());
    if (contact.getType() === connect.ContactType.CHAT) {
        // applies only to CHAT contacts
        console.log('connect.ConnectionType.AGENT', connect.ConnectionType.AGENT)
        const cnn = contact.getConnections().find(cnn => cnn.getType() === connect.ConnectionType.AGENT);
        const agentChatSession = connect.ChatSession.create({
            chatDetails: cnn.getMediaInfo(), // REQUIRED
            options: { // REQUIRED
                region: "us-east-1", // REQUIRED, must match the value provided to `connect.core.initCCP()`
            },
            type: connect.ChatSession.SessionTypes.AGENT, // REQUIRED
            websocketManager: connect.core.getWebSocketManager() // REQUIRED
        });
        const awsSdkResponse = await agentChatSession.getTranscript({
            maxResults: 100,
            sortOrder: "ASCENDING"
        });
        const { InitialContactId, NextToken, Transcript } = awsSdkResponse.data;
        console.log(Transcript);
        return;
    }
}

Amazon Connect Participant api calls are being attempted in us-west-2 but the region you specified was us-east-1.

The region, us-east-1, needs to be specified when initializing CCP as well. See region property here https://github.com/amazon-connect/amazon-connect-streams#initialization

Hi @agnel0410 , any updates on this issue?

If there are any further concerns please let us know. Would like to confirm before closing the issue.

Thanks,
Spencer

Closing issue as there is no activity after 2 months. Please open a new issue if you still need help