Last active
July 9, 2019 17:00
-
-
Save JustinaPetr/8774f9ac66f8b2aec84dc37dc12dec7f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@google_webhook.route("/webhook", methods=['POST']) | |
async def receive(request): | |
payload = request.json | |
intent = payload['inputs'][0]['intent'] | |
text = payload['inputs'][0]['rawInputs'][0]['query'] | |
if intent == 'actions.intent.MAIN': | |
message = "Hello! Welcome to the Rasa-powered Google Assistant skill. You can start by saying hi." | |
else: | |
out = CollectingOutputChannel() | |
await on_new_message(UserMessage(text, out)) | |
responses = [m["text"] for m in out.messages] | |
message = responses[0] | |
r = { | |
"expectUserResponse": 'true', | |
"expectedInputs": [ | |
{ | |
"possibleIntents": [ | |
{ | |
"intent": "actions.intent.TEXT" | |
} | |
], | |
"inputPrompt": { | |
"richInitialPrompt": { | |
"items": [ | |
{ | |
"simpleResponse": { | |
"textToSpeech": message, | |
"displayText": message | |
} | |
} | |
] | |
} | |
} | |
} | |
] | |
} | |
return response.json(r) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment