rehabstudio / fbmessenger Goto Github PK
View Code? Open in Web Editor NEWA python library to communicate with the Facebook Messenger API's
License: Other
A python library to communicate with the Facebook Messenger API's
License: Other
Hi everyone, first of all thank you in advance for your patience. I have a question: I noticed that using standard Flask configuration (as in the example), the library processes one message at a time. Therefore, I changed Flask WSGI server to gevent, to handle multiple concurrent connections. However, if two users send concurrent messages, the answers seem to be randomly mixing up. I noticed that send
method of BaseMessenger
class uses last_message
, which doesn't seem to be thread-safe. Therefore, in the class extending BaseMessenger
class, I implemented some sort of override of the send
method like this:
def raw_send(self, recipient_id, message_data, messaging_type='RESPONSE', tag=None):
self.client.send(payload=self.build_message_template(message_data),
entry={"sender": {"id": recipient_id}},
messaging_type=messaging_type,
tag=tag)
Did I do the right thing? Is there a way to use the library with concurrent requests? At the moment I am using fbmessenger 5.3.2. I hope my question isn't stupid. Thank you again.
I think it would be useful if the values had a default value.
This spares unnecessary lines of code.
Using the method fbmessenger.send()
I have a very slow response time (~ 800ms), has anybody encountered that before ?
I am having decent response (~80ms) time with slack on the same platform, so I am sure it doesn't come from my connection.
Hi, I need to send the reply back to facebook as 2 different messages. How can i handle this?
response = Text(text='Sorry, I am not able to answer for your queries right now.')
I need Sorry and I am not able to answer for your queries right now. as two different messages.
Please help.
Element
currently does not support the default_action
key, as per:
https://developers.facebook.com/docs/messenger-platform/send-api-reference/generic-template
We need this, so I'll do the work and tests and open a PR, if that's OK - unless someone else is working on this?
We should use the sender_id instead of the full message. It's easier if someone uses the library not only to respond to messages.
Example:
https://github.com/rehabstudio/fbmessenger/blob/master/fbmessenger/__init__.py#L45
def get_user_data(self, entry, fields=None, timeout=None):
How to set Facebook messenger API version ?
update "Create a route for the callback url":
messenger = Messenger(os.environ.get('FB_VERIFY_TOKEN'),os.environ.get('FB_PAGE_TOKEN'))
should be
messenger = Messenger(os.environ.get('FB_PAGE_TOKEN'))
Would you like assistance or advice?
assistance
Issue description
in the example below, trying to call an async function from within "def message(self, message):"
Steps to reproduce
insert "await inside the "def message(self, message):" where is a function defined as async
Traceback or other info
[2018-08-29 04:53:10,185] DEBUG in bot: Response: {'error': {'message': '(#100) Requires one of the params: get_started,persistent_menu,target_audience,whitelisted_domains,greeting,account_linking_url,payment_settings,home_url', 'type': 'OAuthException', 'code': 100, 'fbtrace_id': 'FncS+nanDCj'}}
Would you like assistance or advice?
advice
Issue description
Would like to send a file from a local filesystem.
file = attachments.File(url="file://./file.txt")
client.send(file.to_dict(), recipient_id=user_id, messaging_type='RESPONSE')
Steps to reproduce
the above code returns "(#100) file://./file.txt should represent a valid URL)"
also tried other variations of file:// syntax as well as simply ./file.txt and file.txt
Traceback or other info
Thanks!
Would you like assistance or advice?
Assistance.
Issue description
I can't seem to be able to send a message to a specific user after getting his ID
Steps to reproduce
I get the recipient_id through sender=self.get_user_id()
Then why I try to use self.send({'text': "msg"}, sender, 'RESPONSE')
it fails with the error:
ValueError: '2595091087229339' is not a valid 'messaging_type'
It seems like it's handling the variable sender as if it's the messaging_type not recipient_id
Any idea what am I doing wrong?
https://github.com/rehabstudio/fbmessenger/blob/master/fbmessenger/__init__.py#L299
Travis allows you to automatically publish packages to PyPI on successful builds
code:
elements.Button(button_type='web_url', title='Web button', url='http://facebook.com')
error:
(#100) Invalid keys "type, title, url" were found in param "message".
help
Issue description
Visiting https://pypi.org/project/fbmessenger/ says The author of this package has not provided a project description
I suspect that the method being used to read the README is erroneous.
Sending videos is as simple as adding the URL with .mp4 extension. But most of us share youtube videos across messenger.
So how can we send a Youtube video other than sending as a URL?
hi there,
I'm using the example, but I'm getting a loop at the messages. I send "video", then I receive thousands of video responses. Also, the example doesn't cover the message_type. I've put a fixed "RESPONSE" there.
Or else I get TypeError: send() missing 1 required positional argument: 'messaging_type'
'Messenger' object has no attribute 'set_thread_setting'
Should use MessengerProfile and messenger.set_messenger_profile.
Example:
https://github.com/davidchua/pymessenger/blob/master/pymessenger/bot.py#L29
Documentation:
https://developers.facebook.com/docs/graph-api/securing-requests/
Would be a very useful feature!
Can anyone brief me on getting user information of the sender?
Details Such as Name, Location etc.
Hi,
it would be good to have a template for Issues & Pull requests.
I would create a pull request for it?!
From 1 january 2019 all messages sent outside the 24 hour window need to have the tag NON_PROMOTIONAL_SUBSCRIPTION and the messaging_type TYPE_MESSAGE_TAG.
In this library NON_PROMOTIONAL_SUBSCRIPTION is TYPE_NON_PROMOTIONAL_SUBSCRIPTION constant. That is not right. It should be a tag constant.
Here is the FB documentation:
https://developers.facebook.com/docs/messenger-platform/send-messages/message-tags
I have a django project and I will like to build a chatbot for it, but instead of running a different flask server i would like to build a new app inside the project with the bot functionality, any idea of how to do this?
Issue description
Importing ABC from collections has been deprecated and will be removed in Python 3.10. Use collections.abc for Python 3 and collections for Python 2.
fbmessenger/templates.py
47: if isinstance(elements, collections.Iterable):
85: if isinstance(buttons, collections.Iterable):
Would you like assistance or advice?
Advice, please!
Issue description
When I drag and drop multiple images to a facebook messenger, they are sent as a group
How do I do this as a bot?
Steps to reproduce
NA
Traceback or other info
NA
Quick replies do not work, doesn't send any message.
I think this is another recent-ish feature that it would be good to support:
https://developers.facebook.com/docs/messenger-platform/messenger-profile/domain-whitelisting
I'm happy to do the work to add this, but it probably won't be in the next few days (vacations beckon!)
Hi,
Any plans to add the share_contents
property?
https://developers.facebook.com/docs/messenger-platform/send-messages/buttons#share
The button type "type": "element_share"
is there but share_contents
is not supported.
Any plans for adding the messaging_type
property?
https://developers.facebook.com/docs/messenger-platform/send-messages#messaging_types
Hi,
I would like to know if the library supports sending attachments from file as described here: https://developers.facebook.com/docs/messenger-platform/send-messages#sending_attachments in section "Attaching from File".
Thank you :)
fbmessenger version 5.0.0
I am using Rasa-core which uses the fbmessenger as facebook connector, Issue is when my bot takes long time to respond which usually happens when some API is being called I start getting the same message back from messenger no mattter what is being typed by user .So I searched a bit and I came to this conclusion that facebook sends the same message when it doesn't get a response in few seconds .OR it may be due to my localtunnel being patchy.
Hi, there and thank you for your library!
Currently, there is no way to add text to an image. Can it be implemented in the future versions? Thanks
class Image(BaseAttachment):
def __init__(self, url=None, is_reusable=None, quick_replies=None, attachment_id=None):
self.attachment_type = 'image'
self.url = url
self.is_reusable = is_reusable
self.quick_replies = quick_replies
self.attachment_id = attachment_id
super(Image, self).__init__(self.attachment_type, self.url, self.is_reusable,
self.quick_replies, self.attachment_id)
The BaseMessenger.send
instance method doesn't take in a message tag parameter which is required when the messaging_type
is "MESSAGE_TAG"
. As per the FB Docs, we should allow an extra optional parameter to the send
method called tag
which gets sent in the request body when the messaging_type
is "MESSAGE_TAG"
.
Without this, we are not able to use this library for proactively messaging the users.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.