server.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # -*- coding: utf-8 -*-
  2. from __future__ import print_function, absolute_import, division
  3. from flask import Flask
  4. from flask_ask import Ask, statement, question, session
  5. import json
  6. import time
  7. from random import choice
  8. app = Flask(__name__)
  9. ask = Ask(app, "/ameise")
  10. # the Links:
  11. # Config: https://developer.amazon.com/edw/home.html#/skills
  12. # Docs: https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/supported-phrases-to-begin-a-conversation
  13. WELCOME = [
  14. 'Hast du einen Wunsch?',
  15. 'Kann ich dir helfen?',
  16. 'Was soll ich tun?',
  17. 'Ja?',
  18. 'Steht was an?',
  19. 'Was gibt es?',
  20. 'Hast du eine Frage?',
  21. 'Gib mir einen Befehl',
  22. ]
  23. REPROMPTS = [
  24. 'Was hast du gesagt?',
  25. 'Ich habe dich nicht verstanden!',
  26. 'Sprich deutlich, dann verstehe ich dich auch!',
  27. 'Nuscheln ist nicht erlaubt!',
  28. 'Was meinst du?',
  29. ]
  30. @app.route('/')
  31. def homepage():
  32. return "Hi there, how ya doin?"
  33. @ask.launch
  34. def start_skill():
  35. print('Welcome ...')
  36. return question(choice(WELCOME)).reprompt(choice(REPROMPTS))
  37. @ask.intent("ChefIntent")
  38. def declare_chef():
  39. names = ['Lilith', 'Elise', 'Lars', 'Annelie', 'Mama', 'Papa',
  40. 'Christine', 'Dirk', 'Lillutschka', 'Larsi', 'Liselchen', 'Annelutschka',
  41. 'Annelie Rothe', 'Lilith Rothe', 'Christine Rothe', 'Lars Rothe', 'Elise Rothe',
  42. 'die kleine Annelie', 'der schnelle Lars', 'die schlaue Elise', 'die intelligente Lilith']
  43. chefs = ['Chef', 'Oberchef', 'Boss', 'Bestimmer', 'Meister',
  44. 'Leiter', 'Direktor', u'Anführer', 'Oberboss', u'König']
  45. s = ('%s ist heute der %s, aber morgen ist %s dran!' %
  46. (choice(names), choice(chefs), choice(names)))
  47. return statement(s.encode('utf-8'))
  48. @ask.intent("LeaveIntent")
  49. def no_intent():
  50. choices = [
  51. 'Ok, das ist aber schade, Auf Wiedersehen.',
  52. 'Gut, bis zum nächsten Mal.',
  53. 'Ok, selten so viel Spass gehabt.',
  54. ]
  55. return statement(choice(choices))
  56. if __name__ == '__main__':
  57. app.run(debug=True, host='0.0.0.0', port=80)