Amazon Connect: Example of Click to Call in JavaScript

0

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

asked 2 years ago203 views
1 Answer
0

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");
            }
        })
bbolek
answered 2 years ago
  • thanks @bbolek . But I have further questions . I am trying to use the javascript v3 for Connect ( https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-connect/index.html ) 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