Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.18k stars 4.54k forks source link

Can't send message with type ChatMessageType.ParticipantAdded #43207

Open ranouf opened 3 months ago

ranouf commented 3 months ago

Library name and version

Azure.Communication.Chat 1.1.1

Describe the bug

Same as this bug: https://github.com/Azure/azure-sdk-for-net/issues/32623

I create a new ChatThread

        public async Task<string> CreateChatThreadAsync(string topic, IDictionary<string, string> participants, string accessToken)
        {
            var client = GetChatClient(accessToken);

            var response = await client.CreateChatThreadAsync(
                topic,
                participants.Select(participant =>
                    new ChatParticipant(
                        CommunicationIdentifier.FromRawId(participant.Key)
                    )
                    {
                        DisplayName = participant.Value
                    }
                )
            );
            var result = response.Value.ChatThread.Id;
            return result;
        }
    then I try to send a message (like propose in the sample there: https://github.com/microsoft/BotFramework-WebChat/tree/master/samples/04.api/a.welcome-event)
    ```

            public async Task<string> SendNewParticipantAddedAsync(
        string accessToken,
        string threadId
    )
    {
        var client = GetChatClient(accessToken);
        var chatThreadClient = client.GetChatThreadClient(threadId);

        var response = await chatThreadClient.SendMessageAsync(
            @"{
                name: 'webchat/join',
                value: {  }
            }",
            ChatMessageType.ParticipantAdded
        );
        var result = response.Value.Id;
        return result;
    }

Then i have this issue:

> An error occurred while writing to logger(s). (Input string was not in a correct format.) (Input string was not in a correct format.) (Input string was not in a correct format.)'

> FormatException: Input string was not in a correct format.

### Expected behavior

it should not throw an exception and the message should be sent as expected

### Actual behavior

 i have this issue:

> An error occurred while writing to logger(s). (Input string was not in a correct format.) (Input string was not in a correct format.) (Input string was not in a correct format.)'

> FormatException: Input string was not in a correct format.

### Reproduction Steps

I create a new ChatThread

public async Task CreateChatThreadAsync(string topic, IDictionary<string, string> participants, string accessToken) { var client = GetChatClient(accessToken);

        var response = await client.CreateChatThreadAsync(
            topic,
            participants.Select(participant =>
                new ChatParticipant(
                    CommunicationIdentifier.FromRawId(participant.Key)
                )
                {
                    DisplayName = participant.Value
                }
            )
        );
        var result = response.Value.ChatThread.Id;
        return result;
    }

        then I try to send a message (like propose in the sample there: https://github.com/microsoft/BotFramework-WebChat/tree/master/samples/04.api/a.welcome-event)
            public async Task<string> SendNewParticipantAddedAsync(
        string accessToken,
        string threadId
    )
    {
        var client = GetChatClient(accessToken);
        var chatThreadClient = client.GetChatThreadClient(threadId);

        var response = await chatThreadClient.SendMessageAsync(
            @"{
                name: 'webchat/join',
                value: {  }
            }",
            ChatMessageType.ParticipantAdded
        );
        var result = response.Value.Id;
        return result;
    }


### Environment

.net 6.0

        <PackageReference Include="Azure.Communication.Chat" Version="1.1.1" />
        <PackageReference Include="Azure.Communication.Identity" Version="1.2.0" />
github-actions[bot] commented 3 months ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @acsdevx-msft.