This module will send messages to the facebook servers which in turn will send those messages to the user whom’s user is passed. Messages can pe pure text based or be other types like images,videos,location and some special ones from Facebook i.e Templates

class Facebook.send.Send(page_access_token, api_ver=None)[source]

Bases: object

Initialize the send class with page_access_token and api_version(optional) so that you can use the obtained instance to send messages of different types

@required

Parameters:page_access_token – The page access token for the bot

@optional

Parameters:api_ver (int,float) – api version you want to use
get_user_info(user_id)[source]

The User Profile API lets your bot get more information about the user for more info go to https://developers.facebook.com/docs/messenger-platform/user-profile

Parameters:user_id (str) – User id of the person of whom user info is to be retrieved.
Returns:first name,last name,profile pic,locale,timezone,gender.
send_attachment(user_id, attachment_type, url=None, file=None, notification_type='REGULAR', quick_replies=None)[source]

@required

Parameters:
  • user_id – user_id of the recipient
  • attachment_type (str) – Type of attachment, may be image, audio, video, file or template
  • url – URL of data
  • file (str) – path of attachment in the directory

@optional

Parameters:
  • notification_type (string) – Push notification type: REGULAR, SILENT_PUSH, or NO_PUSH.
  • quick_replies – a list containing number of quick replies.(Up to 11).
Returns:

response from facebook or type of error if encountered.

send_button_template(user_id, text, buttons, quick_replies=None)[source]

https://developers.facebook.com/docs/messenger-platform/send-api-reference/button-template

Parameters:
  • user_id – User Id of the recipient to whom the message is being sent.
  • text (str) – UTF-8 encoded text of up to 640 characters that appears the in main body.
  • buttons (Dict | list[dict]) – Set of, one to three, buttons that appear as call-to-actions.
  • quick_replies – a list containing number of quick replies.(Up to 11)
Returns:

send_generic_template(user_id, elements, quick_replies=None)[source]

For more info go to https://developers.facebook.com/docs/messenger-platform/send-api-reference/generic-template

Parameters:
  • user_id (str) – User Id of the recipient to whom the message is being sent.
  • elements – a list of generic templates(up to 10).
  • quick_replies – a list containing number of quick replies.(Up to 11)

Element: Data for each bubble in message :return:

send_list_template(user_id, elements, top_element_style='large', quick_replies=None)[source]

For more info go to https://developers.facebook.com/docs/messenger-platform/send-api-reference/list-template

Parameters:
  • user_id (str) – User Id of the recipient to whom the message is being sent.
  • top_element_style (enum) – Value must be large or compact. Default to large if not specified.
  • elements – List of view elements (maximum of 4 elements and minimum of 2 elements).
  • quick_replies – a list containing number of quick replies.(Up to 11)
Returns:

send_text(user_id, message, notification_type='REGULAR', quick_replies=None)[source]

@required

Parameters:
  • user_id (string) – user_id of the recipient
  • message (string) – Message text
  • notification_type (string) – Push notification type: REGULAR, SILENT_PUSH, or NO_PUSH
  • quick_replies – a list containing number of quick replies.(Up to 11)
Returns:

return response from facebook or type of error if encountered

sender_action(user_id, action='mark_seen')[source]

Sender Action of Facebook bot API. For more info https://developers.facebook.com/docs/messenger-platform/send-api-reference/sender-actions

Parameters:
  • user_id (str) – User id of the person who is going to receive the action
  • action (str) – type of sender action