You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
678 B

  1. ```python
  2. from flask import Flask, request
  3. from twilio.twiml.messaging_response import MessagingResponse
  4. app = Flask(__name__)
  5. @app.route("/whatsapp", methods=['POST'])
  6. def whatsapp_bot():
  7. incoming_msg = request.values.get('Body', '').lower()
  8. resp = MessagingResponse()
  9. msg = resp.message()
  10. if 'bonjour' in incoming_msg:
  11. msg.body("Bonjour ! Comment puis-je t'aider ?")
  12. elif 'aurevoir' in incoming_msg:
  13. msg.body("Au revoir ! Passe une excellente journée !")
  14. else:
  15. msg.body("Désolé, je ne comprends pas cette commande. Essaye encore.")
  16. return str(resp)
  17. if __name__ == "__main__":
  18. app.run(sage est reçu, le bot !