BotFramework-WebChat: role property is not set for messages sent by bot

Description (Actual behavior)

I noticed that in the the Web Chat channel

  • the role property is not set in from for messages sent by the bot
  • the role is set correct for messages sent by the user however

This applies both to

  • the embed WebChat from the Azure Portal, hosted at https://webchat.botframework.com/embed/<botId>?s=<secret>
  • self-hosted webchat using the Full Bundle example from the WebChat readme

Therefore, I cannot search for message sent by the bot by filtering

  • by type == "message" AND
  • by role == "bot"

(since role = bot is not set, zero messages are found)

The bot emulator correctly fills the role property though.

Expected behaviour

When a user has a conversation with the bot, I can get messages sent by the bot by filtering

  • by type == "message" AND
  • by role == "bot"

Workaround

To get bot messages: filter activities in the webchat

  • by type == "message" AND
  • by role != "user"

Related PRs

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 18 (10 by maintainers)

Most upvoted comments

Just taking a look at the ConsoleTranscriptLogger, you are correct. The from attribute in Activities sent by the bot are being set properly when client is the emulator but not WebChat. Take a look at the screenshots below.

adapter.use(new TranscriptLoggerMiddleware(new ConsoleTranscriptLogger()));

Emulator Untitled

WebChat Untitled1

I think it’s worth noting that the TranscriptLoggerMiddleware sets the role for Activities sent by the user if it is missing.

https://github.com/Microsoft/botbuilder-dotnet/blob/a5ba0c40aa962188ce52a8a152af1128dcfa7aa1/libraries/Microsoft.Bot.Builder/TranscriptLoggerMiddleware.cs#L55