예제 #1
0
파일: views.py 프로젝트: mani098/demo-ivr
def index(request):
	ivrQueryset, phoneQueryset = fetch_ivr_data(phone_number='+1 888-314-8506')
	get_ivr_data(phone_number='+1 888-314-8506') # To be removed
	if request.method == 'POST':
		update_ivr_data(dict(request.POST.iterlists()))
		ivrQueryset, phoneQueryset = fetch_ivr_data(phone_number='+1 888-314-8506')
	return render(request, 'index.html', {'ivr_data': ivrQueryset, 'ivr_phone': phoneQueryset})
예제 #2
0
파일: views.py 프로젝트: mani098/demo-ivr
def ivr(request):
	response = plivoxml.Response()
	IVR_MESSAGE, ivr_options = get_ivr_data(phone_number='+1 888-314-8506')
	if request.method == 'GET':
		getdigits_action_url = get_ip_addr() + reverse('ivr_call.views.ivr')	
		getDigits = plivoxml.GetDigits(action=getdigits_action_url,
									   method='POST', timeout=7, numDigits=1,
									   retries=1)
		
		getDigits.addSpeak(IVR_MESSAGE)
		response.add(getDigits)
		response.addSpeak(NO_INPUT_MESSAGE)

		return HttpResponse(str(response), content_type='text/xml')

	elif request.method == 'POST':
		digit = int(request.POST.get('Digits', None))

		if digit in ivr_options:
			if ivr_options[digit]['option_type'] == 'Redirect to':
				redirect_url = ivr_options[digit]['option_value']
				response.addRedirect(redirect_url)
				print redirect_url
			elif ivr_options[digit]['option_type'] == 'Add Speak':
				text = ivr_options[digit]['option_value']
				response.addSpeak(text)
		else:
			response.addSpeak(WRONG_INPUT_MESSAGE)

		return HttpResponse(str(response), content_type='text/xml')