Zenaight commited on
Commit
cbedece
·
verified ·
1 Parent(s): 1a0d052

Upload main.py

Browse files
Files changed (1) hide show
  1. main.py +7 -5
main.py CHANGED
@@ -104,11 +104,11 @@ def send_whatsapp_message(wa_id, reply):
104
  httpx.post(url, headers=headers, json=payload)
105
 
106
  def send_welcome_buttons(wa_id: str):
107
- """Send an in-session Interactive quick-reply with 2 buttons."""
108
  url = f"https://graph.facebook.com/v23.0/{PHONE_NUMBER_ID}/messages"
109
  headers = {
110
  "Authorization": f"Bearer {WHATSAPP_API_TOKEN}",
111
- "Content-Type": "application/json"
112
  }
113
  payload = {
114
  "messaging_product": "whatsapp",
@@ -122,18 +122,20 @@ def send_welcome_buttons(wa_id: str):
122
  "action": {
123
  "buttons": [
124
  {
125
- "type": "quick_reply",
126
  "reply": {"id": "open_gallery", "title": "Open Gallery"}
127
  },
128
  {
129
- "type": "quick_reply",
130
  "reply": {"id": "open_camera", "title": "Open Camera"}
131
  }
132
  ]
133
  }
134
  }
135
  }
136
- httpx.post(url, headers=headers, json=payload)
 
 
137
 
138
  @app.post("/webhook") # incoming WhatsApp updates
139
  async def receive_update(req: Request):
 
104
  httpx.post(url, headers=headers, json=payload)
105
 
106
  def send_welcome_buttons(wa_id: str):
107
+ """Send an in-session Interactive button message with 2 reply options."""
108
  url = f"https://graph.facebook.com/v23.0/{PHONE_NUMBER_ID}/messages"
109
  headers = {
110
  "Authorization": f"Bearer {WHATSAPP_API_TOKEN}",
111
+ "Content-Type": "application/json",
112
  }
113
  payload = {
114
  "messaging_product": "whatsapp",
 
122
  "action": {
123
  "buttons": [
124
  {
125
+ "type": "reply",
126
  "reply": {"id": "open_gallery", "title": "Open Gallery"}
127
  },
128
  {
129
+ "type": "reply",
130
  "reply": {"id": "open_camera", "title": "Open Camera"}
131
  }
132
  ]
133
  }
134
  }
135
  }
136
+ resp = httpx.post(url, headers=headers, json=payload)
137
+ # debug log
138
+ print(f"[BUTTON] POST → {resp.status_code}, body: {resp.text}")
139
 
140
  @app.post("/webhook") # incoming WhatsApp updates
141
  async def receive_update(req: Request):