botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

How can I get the userId if the message type is ActivityTypes.ConversationUpdate.

Open JeevaJose opened this issue 9 years ago • 18 comments

I want to show the user name in the beginning of the welcome message like Hi . I have developed a Bot application in .Net and configured with webchat.

I am passing the userid and username from the MVC application. I got the userid if the message type is ActivityTypes.Message

I could not find the userid if the message type is ActivityTypes.ConversationUpdate.

Once the message type changed to ActivityTypes.Message then the actual userId is available or the user input the value to chat.

How can I get the userId if the message type is ActivityTypes.ConversationUpdate.

JeevaJose avatar Feb 24 '17 13:02 JeevaJose

Activity.MembersAdded might be what you need:

https://github.com/Microsoft/BotBuilder/blob/master/CSharp/Library/Microsoft.Bot.Connector.Shared/ConnectorAPI/Models/Activity.cs#L128

willportnoy avatar Feb 24 '17 23:02 willportnoy

Thanks for your quick information.

This is not the correct answer.

I am passing the userId and user name to the below query string.

https://webchat.botframework.com/embed/?s=&username=&userid=

if the message type is ActivityTypes.ConversationUpdate, this case I am getting the userid from From.Id or Activity.MembersAdded[0].id but that is not the correct userId and expecting the actual userid from wechat url.

if the message type is ActivityTypes.Message, this case I am getting the correct userid which I have passed from wechat url.

The requirement is once the user logged into the Webchat application I have to display the user name with welcome message in the Chatwindow . storing the userid and token information to BotState from the web application. If I get the userId from Activity I can pulling the token information from botstate. I have a problem only with ActivityTypes.ConversationUpdate that have some id but not the actual userid.

JeevaJose avatar Feb 25 '17 15:02 JeevaJose

Same issue here. I even raised an issue few days earlier but didn't get a satisfying answer. https://github.com/Microsoft/BotBuilder/issues/1994

b4usat avatar Feb 27 '17 14:02 b4usat

please help me to get the right answer.

I am working on proactive Bot application and send the notification to webchat. The user signed into webpage that page has webchat, How the user will get the notification without input any message to webchat. Here I am looking the solution to get the ResumptionCookie data from ActivityTypes.ConversationUpdate.

Is there any solution to send the notification message to webchat without user input to webchat?

JeevaJose avatar Mar 03 '17 17:03 JeevaJose

@danmarshall @eanders-MS do you know?

willportnoy avatar Mar 07 '17 03:03 willportnoy

I don't know, Can I contact this person over Email?

JeevaJose avatar Mar 12 '17 13:03 JeevaJose

@JeevaJose I am closing this issue for inactivity, please continue the conversation here if needed. We can reopen the issue if it is still not resolved.

JasonSowers avatar May 23 '17 20:05 JasonSowers

Still active in case of webchat client.

andrejs-mamontovs avatar Jul 27 '17 10:07 andrejs-mamontovs

Hello all, remember that ActivityTypes.ConversationUpdate is going to be called twice - once for the bot user and once for the user. See https://github.com/Microsoft/BotBuilder/issues/1930

Also, the userid URL parameter is not officially supported, it will not be passed to DirectLine and it will not be the same id in the activities.

danmarshall avatar Jul 27 '17 17:07 danmarshall

In the case of WebChat it is called only once. And only for Bot side! And it is the issue! Please take a look.

andrejs-mamontovs avatar Jul 28 '17 06:07 andrejs-mamontovs

Hello @andrejs-mamontovs can you please let us know your SDK and provide a code sample?

danmarshall avatar Jul 28 '17 17:07 danmarshall

Hi Now it is Microsoft.Bot.Bulder 3.9.0.0 (C#) (valid for older versions as well) on the backend. Just run WebClient from https://dev.botframework.com/bots portal, test section. Demo code is as simple as possible, just handle ConversationUpdate (MVC controller code) and prepare response. In my case, only one greeting was returned (Works fine in the official emulator).

andrejs-mamontovs avatar Jul 28 '17 18:07 andrejs-mamontovs

@andrejs-mamontovs can you try this sample: https://github.com/Microsoft/BotBuilder-Samples/tree/master/CSharp/core-GetConversationMembers

danmarshall avatar Jul 28 '17 20:07 danmarshall

I deployed the C# sample from the link above and verified that I get 2 updates, one for the bot, and one for the end user: image

danmarshall avatar Jul 28 '17 21:07 danmarshall

So, so far no luck. I tried your code as part of my project with no luck. will try to find the reason later.

andrejs-mamontovs avatar Jul 31 '17 07:07 andrejs-mamontovs

Were you able to implement this?

jamiemaguiredotnet avatar Jun 20 '18 10:06 jamiemaguiredotnet

Same issue with me. Are you guys able to solve this ?

aqanonas avatar Nov 21 '18 03:11 aqanonas

Hi @aqanonas

This is a known issue with a workaround described here: https://blog.botframework.com/2018/07/12/how-to-properly-send-a-greeting-message-and-common-issues-from-customers/

There is also a related issue on the WebChat repository: https://github.com/Microsoft/BotFramework-WebChat/issues/1371

EricDahlvang avatar Nov 21 '18 17:11 EricDahlvang