Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

role property is not set for messages sent by bot #1886

Closed
hansmbakker opened this issue Apr 10, 2019 · 18 comments
Closed

role property is not set for messages sent by bot #1886

hansmbakker opened this issue Apr 10, 2019 · 18 comments

Comments

@hansmbakker
Copy link

hansmbakker commented Apr 10, 2019

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

@corinagum corinagum added needs-repro Waiting for repro or investigation Pending labels Apr 10, 2019
@hansmbakker
Copy link
Author

@corinagum what do you mean with "need more detail"?

@corinagum
Copy link
Contributor

Hi @hansmbakker, sorry for the confusion - the "Need more detail" label just means that the team hasn't investigated this issue yet. :) In this case, I have read the issue but haven't reproduced it or discussed it with other team members. This is also when we determine the T-Shirt size and how soon we want to implement the feature or fix. Hope that helps!

@hansmbakker
Copy link
Author

Thanks for the clarification!

@tdurnford
Copy link
Contributor

@hansmbakker Where are you trying to filter the activities?

@hansmbakker
Copy link
Author

First I would like to share that the filtering likely is not the problem here; it works with the bot emulator. I believe the web chat simply does not add the "role": "bot" property to the activities sent by the bot.

I do the filtering in the bot's webapp (I'm using the enterprise bot template).

I want to build functionality where the user can download a transcript of his conversation.

So what I do:

  • in a conversation I use the bot framework's transcript store (AzureBlobTranscriptStore) to fetch conversations as a List<IActivity>
  • I filter out all message activities
  • I process it into my own viewmodel and render it into a template that I offer as a download to the user

@tdurnford
Copy link
Contributor

I agree that the issue is most likely not with filter the activities. I wanted to be sure I was reproducing the behavior properly. Thank you for clarifying your issue.

@tdurnford
Copy link
Contributor

tdurnford commented Apr 19, 2019

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

@hansmbakker
Copy link
Author

Nice that you could reproduce it!

@corinagum
Copy link
Contributor

corinagum commented Apr 19, 2019

From the looks of the Bot Framework schema, this is intentional in the protocol and is a wontfix.

A7512: Senders SHOULD NOT include this field. Receivers SHOULD ignore this field.

I believe expectation is that users of DLJS who want to utilize role must fill it themselves, and role is assigned in Emulator because it's functionality of displaying transcripts.
@cwhitten @compulim @tonyanziano is this something we would want to revert in Emulator?

@corinagum
Copy link
Contributor

Adding @justinwilaby to the list of pings :)

@justinwilaby
Copy link

@corinagum is correct. The required fields for a ChannelAccount object are id and name. The role field is used by the Emulator for the purpose of exporting transcripts.

@corinagum
Copy link
Contributor

I'm going to close this as a won't fix. We can always open this up to further discussion again at a later time. :)

@corinagum corinagum added won't fix and removed needs-repro Waiting for repro or investigation Pending labels Apr 29, 2019
@hansmbakker
Copy link
Author

My usecase is, simply put:

I want to display transcripts in a proper way to my editor team who will improve the bot based on conversations that users have.

@corinagum since (per the Bot Framework schema also linked by @corinagum)

This field is intended for use in the Transcript format [16] to distinguish between activities sent by users and activities sent by bots.

The field supports my usecase, but the field only adds value when it is properly filled. What component should fill the role property according to Microsoft?

@corinagum
Copy link
Contributor

My understanding is that it would be the user's responsibility to write this patch.

Would you be able to implement something similar to Web Chat's role patch?

@compulim
Copy link
Contributor

compulim commented Sep 4, 2019

According to the spec Conversation account role, it should be filled by the receiver from the Direct Line channel, and removed before sending it back to the channel.

IMO, the ideal case would be DirectLineJS filling it and removing it. So it is most transparent to the user and also most usable.

@hansmbakker
Copy link
Author

@corinagum could you explain where/how that code is used? Is it used by WebChat and does WebChat remove the role again before sending it to the bot?

@compulim I am using the Virtual Assistant C# template --> did you mean DirectLineJS as a WebChat dependency or as a dependency for the bot adapter? In that case it would need to be done by Microsoft.Bot.Connector.DirectLine I believe?

@corinagum When implementing it into my project I could implement it as middleware for virtual assistant.

@corinagum
Copy link
Contributor

Yes, Web Chat routes it through to add the role and it should be removed.

(To answer your question to compulim as well)
Yes, in this case he is referring to DLJS as a dependency on Web Chat.

@hansmbakker
Copy link
Author

Ok, I'll look into writing middleware that does it.

@corinagum @compulim what is the risk of not removing the bot role? I don't understand why it needs to be cleared afterwards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants