This is a messenger(facebook) chat bot which can greet users and give the weather reports for now,But I will try to add more feautres into it.You can also make your own custom chatbot by using this project and customize the functionality as per your needs.
As a beginner I Know it's tough to think that how do we make chatbots,but now a days it's really easy to make chatbots,The only thing that we have to do is "Use the Resources wisely!!".So follow this documentation and you can make your own working chatbots in an hour!!
First create the virtualenv in any Location:-
> virtualenv chatbotenv
Clone this project in same location where your virtualenv exists:-
> git clone https://github.com/vinitraj10/chatbot
Start the virtualenv:-
>chatbotenv\scripts\activate
Open project in virtualenv and install requirements:-
>cd Facebook-messenger-bot
>pip install -r requirements.txt
Now Go to Wit and signup,create your app and follow there docs to give intents to your wit app. Or if you want my app configuration you can contact me. So take your wit key and update in your views.py
Now go to fbchatbot>views.py:- Give some random integer value in place of <verify_token> that will be required for setting up the webhooks
def fbchat(request):
if request.method == 'GET':
if request.GET['hub.verify_token'] == <verify_token>:
return HttpResponse(request.GET['hub.challenge'])
else:
return HttpResponse("Error,invalid token")
Download Ngrok for your machine after unzipping the download file you will get ngrok.exe place this exe file to your root folder and run the following commnad.
>python manage.py runserver
>ngrok http 8000
you will get some abcd.ngrok.io link for your app ,after that go to settings.py file and update ALLOWED_HOSTS:-
ALLOWED_HOSTS = ['abcd.ngrok.io']
Now follow this link to setup your webhook Quick start Just make sure you give your ssl certified ngrok url (https://) to callback url and verify token should be equal to that verify token which you have given in views.py file,Get your page access token and substitute it in views.py file wherever it has been used and also make sure you subscribe the app to the page According to official docs.