-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Support entire message objects in convo handlers. Fixes #1793 and #1710 #1801
Conversation
Thanks for this work. I have some initial concerns about breaking changes - even things like changing text from optional to required could break things for devs. Does this change the signature of any handlers? |
Hi @benbrown, thanks for replying. This does not change signatures for any existing handlers. Except the optional -> required 'text' property, the change is completely internal to botkit. In fact existing conversation handlers (in botkit v0.7x) expected message objects which changed to only text. Also in case of questions only text can anyway be captured in capture key (as a convo var) The BotkitMessage text was made a 'required' property because the class that it extends from has that set as required. Thanks, |
I am on this and plan to get it reviewed and included in the next release if at all possible. |
Hi @naikus, However, I do think this is a valid issue and you've done 90% of the work. In order to merge this, I request the following change: Instead of swapping the text field for the full message, add an additional parameter to the handler signature. This way, the change is additive and will not break existing bots. |
Hi @benbrown, I agree. I'll make the changes and to the signature and push the changes for review. |
Thanks @naikus! Ping me when you push the new commits. |
@naikus Any updates on this? |
Hi @etiennellipse |
…he entire message of type BotkitMessage
…otkitMessage Fixed errors to pass all test cases All tests pass
Hi @benbrown, convo.addQuestion(
"what?",
async (response, convo, bot, message) => {
// This logs the entire message payload (BotkitMessage) where message.text is same as response
console.log(message);
await convo.gotoThread('thread-3');
},
"what",
"thread-2"
); |
I have been waiting for this change for months now 😄 Hope this comes in next version +1 |
I am also waiting for this one for a long time .. hope this gets approved soon and comes in next release. It may fix #1862 |
I'm on it! |
I've done some e2e testing with this. I was wondering if it'd help if there were unit tests for this. I can start on those. Only I did not see any existing tests for callbacks for |
@naikus yes, new tests would be wonderful. |
…ers to test message objects are passed to them when they are invoked
…ers to test message objects are passed to them when they are invoked
…m/naikus/botkit into message-objects-in-convo-handlers
@benbrown I've added necessary unit tests, thanks. |
+1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any update on this? I've just bumped into this problem as well when trying to update a bot from 0.5.8 to the latest version. We were relying on the message being available in the handler so that we could call bot.replyInteractive()
. It would be great to get this added so that we can update our bot.
user: message.from.id, | ||
channel: message.conversation.id, | ||
value: message.value, | ||
incoming_messge: message, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this not be incoming_message
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes good catch I will probably not merge this piece anyways since it is sort of out of scope of the main change.
working on merging this now. |
snag #1: the way this is implemented to create a new turncontext breaks a bunch of the expected adapter behavior regarding the turn state. however, without it, we don't get access to the message object we want. experimenting! |
phew! I was able to work around that issue by using the turnContext.turnState to store the botkit message and make it available inside the dialog. |
OK! This functionality is included in the next release -> #1929 |
@benbrown nice one! Any idea when the new release is likely to be made available? |
@adam-resdiary this week unless a big snag is encountered on the botbuilder 4.8 release, which I am waiting for. Should be tomorrow! |
AT LONG LAST, this has been merged! |
@benbrown, does this work also for the convo.after handler? The documentation does not include a full_message parameter in there. I'm realizing this would resolve a legacy migration issue that I'm having ( in which I need the full message object once a -single question- dialog ends). In legacy botkit I was able to use a dynamic convo for this (created within a controller.hears() handler). |
This merge request allows botkit conversation handlers (those that go with
addQuestion
api) to receive full message objets. ( Fixes #1710 )Also any augmentation done by botkit middlewares to messages are now available in handlers. This is especially useful for NLU intent and entity identification (i.e. if any of the handlers need to know them) ( Fixes #1793 )