Azure / communication-ui-library

UI Library for Azure Communication Services helps developers build communication applications with ease. From turn-key composites to UI components that can be composited together.
https://aka.ms/acsstorybook
MIT License
169 stars 71 forks source link

ACS Chat Channel - Support for Bot Event Activities #4203

Closed ramneettung-msft closed 7 months ago

ramneettung-msft commented 7 months ago

Hi,

I am using the ACS Chat Channel integration to create an ACS chat thread between a user and a bot (both ACS identities).

https://learn.microsoft.com/en-us/azure/communication-services/quickstarts/chat/quickstart-botframework-integration

I am trying to send a "message with event activity" as indicated in the docs:

{ "content":"{ \"name\":\"endOfConversation\", \"field1\":\"value1\", \"field2\": {
\"nestedField\":\"nestedValue\" } }", "senderDisplayName":"Acs-Dev-Bot", "metadata":{
"microsoft.azure.communication.chat.bot.contenttype": "azurebotservice.event", "text":"random text", "key1":"value1", "key2":"{\r\n \"subkey1\": \"subValue1\"\r\n}" }, "messageType": "Text" }

I would expect there is a way that I can filter this message from displaying in the chat thread, but when I send this it always ends up rendering there. Is there any support for message filtering based on the metadata? I would expect that these situations that should be supported by the communication ui library?

Describe the bug; what happened?

Send an event message activity using approach specified in our documentation, and it was sent successfully but do not want to render this message in the chat thread as it's a event.

What are the steps to reproduce the issue?

Outlined in the documentation, and using the Chat Composite.

What behavior did you expect?

I expected the message to not be displayed in the chat thread.

jpeng-ms commented 7 months ago

Hi @ramneettung-msft thanks for raising this issue. please allow me to check with our team and I will get you back shortly.

jpeng-ms commented 7 months ago

Hi @ramneettung-msft , thanks for your patience, I have checked with my team.

When a new message comes in, it will first land in chat stateful client which we then pass down the event to adapter for rendering.

So to be able to intercept and manipulate (or remove) the event, we need to have a custom Chat SDK client which listens to newMessageReceived event with a custom callback (which will discard the event if it matches the condition you defined).

Once you have created this custom chat client, then you can create composite like the following:

  const chatClient = // your custom chat client goes here
  const chatThreadClient = chatClient.getChatThreadClient(chatThreadId);

  await chatClient.startRealtimeNotifications();

  const callWithChatAdapter = await createAzureCommunicationCallWithChatAdapterFromClients({
    callAgent,
    callClient,
    callLocator,
    chatClient,
    chatThreadClient,
    callAdapterOptions
  });

By doing this, you are essentially intercepted incoming events before it's being passed down to stateful layer and UI layer.

Please let me know if this resolves the issue you are facing.

Looking forward to hearing back from you,

jpeng-ms commented 7 months ago

Hi @ramneettung-msft we haven't heard back from you in 2 weeks so I am going to go ahead to close this issue. Feel free to reopen it anytime if you have more questions!