Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django.shortcuts import render
- from django.http import HttpResponse, JsonResponse
- from django.views.decorators.csrf import csrf_exempt
- from library.df_response_lib import *
- import json
- #define home function
- def home(request):
- return HttpResponse('Hello World!')
- @csrf_exempt
- def webhook(request):
- # build a request object
- req = json.loads(request.body)
- # get action from json
- action = req.get('queryResult').get('action')
- # prepare response for suggestions chips
- if action == 'get_suggestions_chips':
- #set fulfillment text
- fulfillmentText = 'Suggestion chips response from webhook'
- aog = actions_on_google_response()
- aog_sr = aog.simple_response([[fulfillmentText, fulfillmentText, False]])
- #create suggestion chips
- aog_sc = aog.suggestion_chips(["suggestion1", "suggestion2"])
- ff_response = fulfillment_response()
- ff_text = ff_response.fulfillment_text(fulfillmentText)
- ff_messages = ff_response.fulfillment_messages([aog_sr, aog_sc])
- reply = ff_response.main_response(ff_text, ff_messages)
- # return response
- return JsonResponse(reply, safe=False)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement