amazon-connect / amazon-connect-chatjs

Amazon Connect ChatJS - a browser-based contact center integration API for Chat on the Agent and Customer side.
https://docs.aws.amazon.com/connect/latest/adminguide/what-is-amazon-connect.html
Apache License 2.0
93 stars 54 forks source link

Function is not allowing Inside connect.contact(()=>{}) #144

Closed nayabrasool4910 closed 1 year ago

nayabrasool4910 commented 1 year ago

Hi, I am trying to call function after connecting chat from AgentChatSession to CustomerChatSession using angular.

my code

ngOninit(){

connect.contact(function (contact) {
contact.onAccepted(async () => {
          const accept = 'Accepted'
          this.getcall(){
             console.log('call get method')
          }
          const cnn = contact.getAgentConnection() as connect.ChatConnection
          if(cnn){
          const agentChatSession = await cnn.getMediaController();
          agentChatSession.onMessage((res)=>{
            console.log(res)
          });
          }  
        });

})

}

I am getting error like getcall() is not a function. Can you please put your comments. It will be helpfull to me. Thanks in advance.

doreechi commented 1 year ago

Hi, can you please try to follow the documentation in this section https://github.com/amazon-connect/amazon-connect-chatjs#connectchatsessioncreate?

spencerlepine commented 1 year ago

Hi @nayabrasool4910 , it appears this syntax error is not related to ChatJS. Going to resolve the issue.

Please refer the documentation as mentioned above. If you have further questions, please feel free to reach out or re-open.

From the snippet you have shared, here is a small change that may resolve the error. Please provide more details if there are different errors relating to ChatSession methods


@Component({
  // Component metadata here
})
export class YourComponent implements OnInit {
  constructor() { }

+ getcall() {
+   console.log('call get method')
+ }

  ngOninit() {

    connect.contact(function (contact) {
      contact.onAccepted(async () => {
        const accept = 'Accepted'

-       this.getcall(){
-         console.log('call get method')
-       }
+       this.getcall()

        const cnn = contact.getAgentConnection() as connect.ChatConnection;

        if (cnn) {
          const agentChatSession = await cnn.getMediaController();
          agentChatSession.onMessage((res) => {
            console.log(res);
          });
        }
      });

    })

  }
}

Thanks, Spencer