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
97 stars 56 forks source link

Want to send additional information with file in send Attachment method #203

Closed OctaveIdeas closed 9 months ago

OctaveIdeas commented 11 months ago

Success Case: I am using amazon-connect-chatjs sendAttachment method to send attachments . It is working fine.

await controller.sendAttachment({ attachment: file})

I have to send some additional information with a file to my backend, which I wrote using Amazon Connect Chat APIs. I have different types of channels (whatsapp) communicating with my frontend using that backend. I have to make a decision on the additional information to whom I have to send the attachment. Is there any way to add my additional information with a send attachment and get this information on the WebSocket onMessage event? Please guide me on how I can achieve that approach.

i want something like this:

await controller.sendAttachment({ attachment: file}, {additional information}) or await controller.sendAttachment({ attachment: file, additional information})

I've tried the above approach but got same attachment response on WebSocket as previous, all the information got ignored or removed.

OctaveIdeas commented 11 months ago

@spencerlepine please check this

spenlep-amzn commented 11 months ago

Hi @OctaveIdeas,

No, there is no way to "add my additional information with a send attachment and get this information on the WebSocket onMessage event" with just ChatJS.

You can return metadata with the promise, but that data stays client-side (not being sent end-to-end):

// https://github.com/amazon-connect/amazon-connect-chatjs?tab=readme-ov-file#amazon-connect-participant-service-api-wrappers

function handleResponse(response) {
  const { data, metadata } = response;
  // ...
}

function handleError(response) {
  const { error, metadata } = response;
  // ...
}

await chatSession
  .sendAttachment({ attachment: file, metadata: "foo" })
  .then(handleResponse, handleError);
spenlep-amzn commented 11 months ago

Please confirm if there is a bug with ChatJS, or this is just a question about how to add feature to your own implementation.

With the information provided about your setup, it is not clear what the expected end-to-end flow is

OctaveIdeas commented 10 months ago

@spenlep-amzn this is just a question to add feature in my implementation

spenlep-amzn commented 9 months ago

Closing this issue due to inactivity.

Please feel-free to re-open if you have additional info about the setup.

Thanks -Spencer