When using a send middleware with the Web adapter, the user ID is not available in the message object during a conversation (i.e. Dialog).
For instance, the middleware (bot, message, next) => { console.log(message); next(); } displays these data for a bot message:
{ type: 'message',
text: 'typed!',
inputHint: 'acceptingInput',
channelData: {} }
A possible solution consists in extracting the user ID for the convo vars in the function makeOutgoing(dc, line, vars)
of conversation.ts:
// copy user and channel from vars (for Web adapter)
if (!outgoing.user && vars.user) {
outgoing.user = vars.user;
}
Then the message user can be leverage in the send middleware 🎉
{ type: 'message',
text: 'typed!',
inputHint: 'acceptingInput',
channelData: {},
user: '7a247882-bdab-c853-7175-f97d3978d663' // <= Yes!
}
Moreover, when a message is sent with bot.reply or bot.say, the user ID is not present in the traditional (legacy?) messager.user.
{ type: 'message',
text: 'Echo: pizza',
// ...
recipient: { id: '7a247882-bdab-c853-7175-f97d3978d663' },
// ...
user: '7a247882-bdab-c853-7175-f97d3978d663', // <= It would be great to have this
// ...
}
It could be great to add it in the function ensureMessageFormat(message) of botworker.ts:
const activity = {
type: message.type || 'message',
text: message.text,
// ...
user: message.recipient && message.recipient.id,
// ...
};
Can these points be integrated in a future release of Botkit?
How can i make myself useful to the code?
Thanks,
Chris
Context:
- Botkit version: 4.10.0
- Messaging Platform: Web (botbuilder-adapter-web in version 1.0.9)
- Node version: v10.15.1
- Os: MacOS