Building a Facebook chatbots with Python

<strong>Facebook now has the Messenger Platform which permits us to manufacture bots which can acknowledge messages from clients and react to them.</strong>

Facebook now has the Messenger Platform which permits us to manufacture bots which can acknowledge messages from clients and react to them.

Facebook now has the Messenger Platform which permits us to manufacture bots which can acknowledge messages from clients and react to them. In this instructional exercise, we should perceive how we can assemble a bot and add it to one of our pages so that the clients can interface with the bot by sending messages to the page.

To begin, we have three necessities to satisfy:

  • We require a Facebook Page
  • We require a Facebook App
  • We require a webhook/callback URL to acknowledge approaching messages

I am accepting you as of now have a Facebook Page. In the event that you don’t, simply ahead and make one. It’s extremely basic.


Creating and Configuring The Facebook App

1. Initially, we make a non specific facebook application. We have to give the name, namespace, classification, contact email. Basic and direct. This is what it would seem that for me:

.


2. Presently we need to scan the “Include Product” segment and include “Envoy”.


3. Produce access token for a Page you oversee. A popup will open approaching you for consents. Stipend the consent and you will soon see the entrance token for that page. It would be ideal if you take a note of this token. We should utilize it later send messages to the clients in the interest of the page.

Next, snap the “Webhooks” area.


4. Before we can setup a webhook, we have to setup a URL which is openly available on the web. The URL must have SSL (that is it should be https). To meet this prerequisite and set up a neighborhood dev environment, we setup a fast flagon application on our nearby machine.

Install Flask from PyPi using pip:

pip install Flask

Facebook will send a GET solicitation to the callback URL we give. The solicitation will contain a custom mystery we can include (while setting up the webhook) and a test code from Facebook. They anticipate that us will yield the test code to check ourselves. To do as such, we compose a speedy GET handler utilizing Flask.

## Filename: server.py 

from flask import Flask, request

app = Flask(name)

@app.route('/', methods=['GET'])
def handle_verification():
return request.args['hub.challenge']

if name == 'main':
app.run(debug=True)

We run the nearby server utilizing python server.py. The application will dispatch at port 5000 of course. Next we utilize ngrok to open the server to the web. ngrok is an awesome device and you ought to truly try it out for running and troubleshooting webhooks/callback urls on your nearby machine.

ngrok http 5000

With that order, we will get a location like https://ac433506.ngrok.io. Duplicate that url and glue it in the Webhook setup popup. Checkmark the occasions we’re occupied with. I check every one of them. At that point we include a mystery, which our code couldn’t care less about much. So simply include anything you like. The popup now seems as though this:

Click “Verify and Save”. If the verification succeeds, the popup will close and you will be back to the previous screen.

Select a Page again and click “Subscribe”. Presently our application ought to be added to the page we chose. If it’s not too much trouble note, on the off chance that we haven’t created an entrance token for that page in the prior stride, the membership will fall flat. So ensure we have an entrance token produced for that page.


Handling Messages

Presently every time somebody makes an impression on the “Masnun” page, Facebook will make a POST solicitation to our callback url. So we have to compose a POST handler for that url. We additionally require react back to the client utilizing the Graph API. For that we would need to utilize the marvelous requests module.

pip install requests

Here’s the code for tolerating approaching messages and sending them an answer:

from flask import Flask, request
import requests

app = Flask(name)

ACCESS_TOKEN = "EAAP9MMaGh1cBAHS7jZCnuQgm2GWx5grLraIElFlWlIw2r3Afb34m2c2rP0xdkkkKEeiBOykGINAP0tScwmL5NNBJQN9ayPCuq13syvWocmbYZA7BXL86FsZCyZBxTmkgYYp8MDulLc1Tx70FGdU5ebQZAJV28nMkZD"

def reply(user_id, msg):
data = {
"recipient": {"id": user_id},
"message": {"text": msg}
}
resp = requests.post("https://graph.facebook.com/v2.6/me/messages?access_token=" + ACCESS_TOKEN, json=data)
print(resp.content)

@app.route('/', methods=['POST'])
def handle_incoming_messages():
data = request.json
sender = data['entry'][0]['messaging'][0]['sender']['id']
message = data['entry'][0]['messaging'][0]['message']['text']
reply(sender, message[::-1])

return "ok"

if name == 'main':
app.run(debug=True)

The code here acknowledges a message, recovers the client id and the message content. It switches the message and sends back to the client. For this we utilize the ACCESS_TOKEN we produced before hand. The approaching solicitation must be reacted with a status code 200 to recognize the message. Generally Facebook will attempt the message a couple of more times and after that cripple the webhook. So sending a http status code 200 is essential. We simply yield “alright” to do as such.

You can now make an impression on your page and check whether it reacts accurately. Look at Flask’s and ngrok’s logs to troubleshoot any issues you may confront.

You can download the specimen code from here: https://github.com/masnun/fb-bot

Python GUI Programming Projects using Tkinter and Python 3

Python GUI Programming Projects using Tkinter and Python 3

Python GUI Programming Projects using Tkinter and Python 3

Description
Learn Hands-On Python Programming By Creating Projects, GUIs and Graphics

Python is a dynamic modern object -oriented programming language
It is easy to learn and can be used to do a lot of things both big and small
Python is what is referred to as a high level language
Python is used in the industry for things like embedded software, web development, desktop applications, and even mobile apps!
SQL-Lite allows your applications to become even more powerful by storing, retrieving, and filtering through large data sets easily
If you want to learn to code, Python GUIs are the best way to start!

I designed this programming course to be easily understood by absolute beginners and young people. We start with basic Python programming concepts. Reinforce the same by developing Project and GUIs.

Why Python?

The Python coding language integrates well with other platforms – and runs on virtually all modern devices. If you’re new to coding, you can easily learn the basics in this fast and powerful coding environment. If you have experience with other computer languages, you’ll find Python simple and straightforward. This OSI-approved open-source language allows free use and distribution – even commercial distribution.

When and how do I start a career as a Python programmer?

In an independent third party survey, it has been revealed that the Python programming language is currently the most popular language for data scientists worldwide. This claim is substantiated by the Institute of Electrical and Electronic Engineers, which tracks programming languages by popularity. According to them, Python is the second most popular programming language this year for development on the web after Java.

Python Job Profiles
Software Engineer
Research Analyst
Data Analyst
Data Scientist
Software Developer
Python Salary

The median total pay for Python jobs in California, United States is $74,410, for a professional with one year of experience
Below are graphs depicting average Python salary by city
The first chart depicts average salary for a Python professional with one year of experience and the second chart depicts the average salaries by years of experience
Who Uses Python?

This course gives you a solid set of skills in one of today’s top programming languages. Today’s biggest companies (and smartest startups) use Python, including Google, Facebook, Instagram, Amazon, IBM, and NASA. Python is increasingly being used for scientific computations and data analysis
Take this course today and learn the skills you need to rub shoulders with today’s tech industry giants. Have fun, create and control intriguing and interactive Python GUIs, and enjoy a bright future! Best of Luck
Who is the target audience?

Anyone who wants to learn to code
For Complete Programming Beginners
For People New to Python
This course was designed for students with little to no programming experience
People interested in building Projects
Anyone looking to start with Python GUI development
Basic knowledge
Access to a computer
Download Python (FREE)
Should have an interest in programming
Interest in learning Python programming
Install Python 3.6 on your computer
What will you learn
Build Python Graphical User Interfaces(GUI) with Tkinter
Be able to use the in-built Python modules for their own projects
Use programming fundamentals to build a calculator
Use advanced Python concepts to code
Build Your GUI in Python programming
Use programming fundamentals to build a Project
Signup Login & Registration Programs
Quizzes
Assignments
Job Interview Preparation Questions
& Much More

Guide to Python Programming Language

Guide to Python Programming Language

Guide to Python Programming Language

Description
The course will lead you from beginning level to advance in Python Programming Language. You do not need any prior knowledge on Python or any programming language or even programming to join the course and become an expert on the topic.

The course is begin continuously developing by adding lectures regularly.

Please see the Promo and free sample video to get to know more.

Hope you will enjoy it.

Basic knowledge
An Enthusiast Mind
A Computer
Basic Knowledge To Use Computer
Internet Connection
What will you learn
Will Be Expert On Python Programming Language
Build Application On Python Programming Language

Python Programming Tutorials For Beginners

Python Programming Tutorials For Beginners

Python Programming Tutorials For Beginners

Description
Hello and welcome to brand new series of wiredwiki. In this series i will teach you guys all you need to know about python. This series is designed for beginners but that doesn't means that i will not talk about the advanced stuff as well.

As you may all know by now that my approach of teaching is very simple and straightforward.In this series i will be talking about the all the things you need to know to jump start you python programming skills. This series is designed for noobs who are totally new to programming, so if you don't know any thing about

programming than this is the way to go guys Here is the links to all the videos that i will upload in this whole series.

In this video i will talk about all the basic introduction you need to know about python, which python version to choose, how to install python, how to get around with the interface, how to code your first program. Than we will talk about operators, expressions, numbers, strings, boo leans, lists, dictionaries, tuples and than inputs in python. With

Lots of exercises and more fun stuff, let's get started.

Download free Exercise files.

Dropbox: https://bit.ly/2AW7FYF

Who is the target audience?

First time Python programmers
Students and Teachers
IT pros who want to learn to code
Aspiring data scientists who want to add Python to their tool arsenal
Basic knowledge
Students should be comfortable working in the PC or Mac operating system
What will you learn
know basic programming concept and skill
build 6 text-based application using python
be able to learn other programming languages
be able to build sophisticated system using python in the future

To know more: