By using AWS re:Post, you agree to the Terms of Use
/Amazon Connect: Example of Click to Call in JavaScript/

Amazon Connect: Example of Click to Call in JavaScript


Hello All, Is there an example code for a click to call from a web page, possibly using the V3 using javascript ?

1 Answers

When connected to ccp assign agent to a variable

connect.agent((agent) => {
          window.CCP.agent = agent;

Then you can make a call as below:

const endpoint = connect.Endpoint.byPhoneNumber(phoneToDial);
        window.CCP.agent.connect(endpoint, {
            failure: (e: any) => {
                console.log("call failed");
answered 16 days ago
  • thanks @bbolek . But I have further questions . I am trying to use the javascript v3 for Connect ( ) And my current problem is the connection is refused . I think I am missing a parameter either during creating ConnectClient or StartOutboundVoiceContactCommand (see below ) . I get error "Uncaught (in promise) Error: Credential is missing"

    //code fragment import { ConnectClient, AssociateApprovedOriginCommand, StartOutboundVoiceContactCommand } from "@aws-sdk/client-connect";

    const client = new ConnectClient({ region: "us-west-2" }) /// const params = { "ContactFlowId": "36c5ea54-XXXX-XXXX-XXXXX-XXXXXXXX", "DestinationPhoneNumber": "+1XXXXXXXXXX", "InstanceId": "arn:aws:connect:us-west-2:XXXXXXX", }; const command = new StartOutboundVoiceContactCommand(params); client.send(command);

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions