Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified condition to parse Quick Reply properly #62

Merged
merged 1 commit into from
Dec 7, 2016

Conversation

MohitDhanjani
Copy link
Contributor

This little modification solves the issue of quick reply not being able to parse out as postback.
Even if the request contains quick reply, Claudia won't be able to parse it as a postback because the first condition is already fulfilled and it never goes till 'else-if' statement where the quick-reply is actually parsed.

This little modification solves the issue of quick reply not being able to parse out as postback.
Even if the request contains quick reply, Claudia won't be able to parse it as a postback because the first condition is already fulfilled and it never goes till 'else-if' statement where the quick-reply is actually parsed.
@stojanovic
Copy link
Member

Hm, doesn't this part of the code doing exactly that?
https://github.com/claudiajs/claudia-bot-builder/blob/master/lib/facebook/parse.js#L21-L29

@MohitDhanjani
Copy link
Contributor Author

MohitDhanjani commented Dec 7, 2016

The part highlighted by you is correct.
Problem is that it is never executed even if messageObject contains a Quick Reply.

The messageObject of a normal Text message will contain message and message.text fields. Which the first if statement checks. Once the first condition is satisfied, rest are ignored.
A Quick Reply also contains the above fields as well as message.quick_reply and message.quick_reply.payload fields.

As both Text and Quick Reply message contains the same fields, the code never enters the Quick Reply else if statement because the first condition is already satisfied as it contains the two fields which are same to both.

The little modification I made make sure that first condition is only executed if the message does not contain a Quick Reply, so that the actual condition block of Quick Reply gets executed instead of being ignored.

Edit

Attached is the screenshot of one of the request in my CloudWatch log stream.
It is a Quick Reply message from Facebook Messenger, which does not get parsed as postback.

logimage

@stojanovic
Copy link
Member

Makes sense, thanks and thanks for detailed explanation!

@stojanovic stojanovic merged commit 7e4ef3d into claudiajs:master Dec 7, 2016
@MohitDhanjani
Copy link
Contributor Author

Thanks for the merge. And big thanks to you and your team for developing Claudia. It is making life easier for students like me to develop and deploy APIs and bots on AWS! :)

@stojanovic
Copy link
Member

Pushed to npm in v2.9.0, release notes are here.

Thanks again :)
Feel free to send PR for anything you think could be useful for Claudia and, of course, to suggest any new features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants