-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Send middleware after ask() or addmessage() does not append recipient to message (Facebook) #1921
Comments
There are a lot of issues with the sample code you posted.
The send middleware will be seeing the message in its "botkit" form before it is translated into a Facebook API call where the recipient value is mixed in. |
Thanks Ben, I'm new to Version 4, so I appreciate your feedback. I use the send middleware to save the messages that are sent to the users from the bot, and i include the text of the message + the recipient id for logging and debugging purposes, so it's crucial for me to have the recipient id there. I hope this makes the problem clearer, I haven't been able to solve this yet. Thanks. |
The value should be present somewhere in the message you get in the middleware - I believe it will be in |
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. |
I think that this issue is likely the same as #2030 and also my latest #2062, as it concerns botkit middleware and not Facebook in particular. In summary: no information about the recipient is available within the send middleware as part of the message, if the message is part of an ongoing convo. Unfortunately, this is really crucial information for a bot application :-( (e.g. it's impossible to log properly without the recipient/user id). |
Hey all,
I have this code that asks a question then when the response is received, it goes to another question thread.
`await bot.changeContext(message.reference);
const convo = new BotkitConversation('register', bot.controller);
convo.ask('Please write the POS ID that you would like to register', async (response, mConvo, mBot) => {
convo.addAction('askUsername');
}, 'posId');
convo.addQuestion('What is your username ?', async (response, mConvo, mBot) => {
mConvo.stop();
}, 'username', 'askUsername');
bot.controller.addDialog(convo);
await bot.beginDialog(convo.id);`
This part works fine.
but in the send middleware:
controller.middleware.send.use(async (bot, message, next) => { console.log(message); });
The problem is,
This message does not have the "recipient" field or any field that contains data about the channel, sender or receiver.
When using bot.reply(), the message in send middleware contains the "recipient" field which has that facebook id of the user.
Thanks
The text was updated successfully, but these errors were encountered: