An Introduction To Web Call Application In Django

Posted By : Nikhil Verma | 02-May-2022

Django

Loading...

1. What is Twilio?

This is http api that allows the user to make a web based call and sms application. The objective of this powerfull api is help to make a telephony applications.


2. What is ngrok?

This is a cross-platform application that provide facility to use local server on internet.


3. How To Setup Twilio?

Step - 1: You have to create a twilio account on https://www.twilio.com/try-twilio


Step - 2: after create a twilio account you will get credit amount almost $15


Step - 3: When amount credited in you account then buy a twilio number


Step - 4: then add the number at phone numbers >> manage >> verified caller ids >> Add new caller ids


Step - 5: Now, Its time setup django project

For setup the django project take the reference from here - https://docs.djangoproject.com/en/4.0/intro/tutorial01/


Step - 6: create an application

python manage.py startapp twi_call

pip install twilio


step - 7: In twi_call views.py file

you have to import these packages

from django.http import HttpResponse

from django.views.decorators.csrf import csrf_exempt

from twilio.rest import Client

account_sid= 'AC4fa03sd54f65sd4fsd51f0238ff5a26e'

auth_token = 'e9442321ddf81b39383464d2dc9d0d78aff8730a6fdr'

client = Client(account_sid, auth_token)

@csrf_exempt

def answer(self):

call = client.calls.create(

twiml='<Response><Say> Hello i am twilio</Say></Response>',

to='#############',//registered contact no.

from_='##########'//twilio phone number

)

return HttpResponse("Thank you")

you will get account_sid and auth_token from user settings >> console


Step - 8: setup url for above function

from twi_call import views

urlpatterns = [

path('admin/', admin.site.urls),

path('answer', views.answer)

]


4. You have setup your django project and twilio account, Now its time setup ngrok


Step - 1: Create a account in ngrok from this url - https://dashboard.ngrok.com/signup


Step - 2: After login via ngrok account you will get the screen like :


Step - 3: Click on Download button


Step - 4: unzip the file

linux -

unzip /path/to/ngrok.zip


Step - 5: connect to the server

ngrok config add-authtoken 26uw7VdPF4gPxxa1sXN9dT1ErBW_3jVtku5zgbsNPABWM184J


Step-6: Run ngrok via this command

ngrok http 8000

after execute this command you will get the output screen like this


5. run django server

python manage.py runserver


6. search in browser

https://413e-223-181-167-29.ngrok.io/answer

then you will received a call on phone


If you follow the above steps, you will able to create web call application



We are an ERP software development company that excels in building custom enterprise solutions from the ground up. Our seasoned developers use agile methodologies to build scalable enterprise solutions with custom features. To learn more about our custom ERP software development services, drop us a line at [email protected].