Skip to content

Commit

Permalink
Merge pull request #15 from iTeam-S/Rivo
Browse files Browse the repository at this point in the history
[FIX] Persistent menu
  • Loading branch information
gaetan1903 authored Mar 11, 2022
2 parents 8b89c71 + 967d2e0 commit a7634fe
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions ampalibe/messenger.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self, access_token):
access_token (str): A facebook page access token
"""
self.token = access_token
self.url = "https://graph.facebook.com/v8.0/me"
self.url = "https://graph.facebook.com/v13.0/me"

@retry(requests.exceptions.ConnectionError, tries=3, delay=3)
def send_message(self, dest_id, message, prio=False):
Expand Down Expand Up @@ -271,7 +271,7 @@ def send_file_url(self, dest_id, url, filetype='file'):
return res

@retry(requests.exceptions.ConnectionError, tries=3, delay=3)
def persistent_menu(self, dest_id, persistent_menu, action='PUT'):
def persistent_menu(self, dest_id, persistent_menu, action='PUT', **kwargs):
"""
this is a method to enable a persistent
menu for messenger
Expand All @@ -288,6 +288,9 @@ def persistent_menu(self, dest_id, persistent_menu, action='PUT'):
dest_id (str): user id for destination
persistent_menu (list of dict): the elements of the persistent menu to enable
action (str, optional): the action for benefit["PUT","DELETE"]. Defaults to 'PUT'.
locale [optionnel]
composer_input_disabled [optionnel]
Ref:
https://developers.facebook.com/docs/messenger-platform/send-messages/persistent-menu
Expand All @@ -297,7 +300,13 @@ def persistent_menu(self, dest_id, persistent_menu, action='PUT'):
if action == "PUT":
dataJSON = {
"psid": dest_id,
persistent_menu: persistent_menu
persistent_menu: [
{
"locale": kwargs.get("locale", "default"),
"composer_input_disabled": kwargs.get("composer_input_disabled", "false"),
"call_to_actions": persistent_menu
}
]
}

res = requests.post(
Expand Down Expand Up @@ -429,4 +438,4 @@ def send_media(self,dest_id,fb_url,media_types):
params=params
)
Analyse(res)
return res
return res

0 comments on commit a7634fe

Please sign in to comment.