Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

user not available within 'send' middleware when within a dialog (convo) and using botbuilder-adapter-web #2062

Closed
pgoldweic opened this issue Mar 2, 2021 · 5 comments
Labels

Comments

@pgoldweic
Copy link

pgoldweic commented Mar 2, 2021

When a bot sends a message to a user from within a dialog (convo), the user value appears to be missing from the message (at least when using the botbuilder-adapter-web).
In fact, in printing out the message out for debugging purposes, this is what shows up:

   { type: 'message',
     inputHint: 'acceptingInput',
     suggestedActions: { actions: [ [Object], [Object] ] },
     text: 'Should we resume the previous chat or start a new one?',
     channelData: { quick_replies: [ [Object], [Object] ] } }

As you can see, neither the 'user' nor the 'recipient' fields are available (each of them would give us useful user information).
Needless to say, send middleware is unable to do anything useful with this information, so I believe this is actually a bug. I noticed that there are a couple of prior, related issues created by @cbouvard : #2030 and #2043. I'm hoping that #2043 can actually resolve this issue, as it stores the 'user' value in convo vars, but it is awaiting a review since September. It would be great if somebody could please verify that this is actually a bug, and also review the submitted PR in #2043 in order to fix it . Better still, it would be best to have a solution that does not depend on the bot asking the user for their name during the interaction (so that it can be stored in the convo vars), as access to the 'user' value should be a given within send middleware.

@cbouvard
Copy link

cbouvard commented Mar 5, 2021

Hey @pgoldweic 👋

Patricia, for your information, the code of the PR #2043 is operational. My bots have been working well in production since months 👌

I hope the PR will be merged soon to avoid managing a fork!

@pgoldweic
Copy link
Author

Thanks for commenting on this @cbouvard ! Does this work also when the first question is being asked by the bot within the convo,, before a user's response? (that is, is the user/userid already there?). And also, have you managed to get access to this info. from within the convo.before() method?

@cbouvard
Copy link

cbouvard commented Mar 5, 2021

Yes, the user info is available at the very beginning of a conversation.

In the tiny project created for testing the PR (👉 here), you can check the
behavior by adding a simple console.log in the file features/pizza.js:

convo.before('default', (convo, bot) => {
    console.log('Here are the vars in convo:', convo.vars);
});

And I tested it with the Bot Framework emulator, it seems to be OK:

✅ Message received "Give me some pizza, Patricia 😉" with user c3dcc333-ee7b-4518-aa08-8b93bed06e32
Here are the vars in convo: { user: 'c3dcc333-ee7b-4518-aa08-8b93bed06e32',
  channel: 'f02c36a0-7dc9-11eb-9ffe-b53a872a3e35|livechat' }

Hope this helps!

@pgoldweic
Copy link
Author

Glad to hear this! Thanks again @cbouvard . Yes, I definitely hope that this gets merged soon!

@stale
Copy link

stale bot commented Jun 11, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jun 11, 2021
@stale stale bot closed this as completed Jul 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants