Alan numitron clock
SNES Pi Webserver
USB Volume/USB toys
SNES Arcade cabinet
Game boy projects
Home Presence Detector
Rand Nerd Tut
Carnet du maker (fr)
ATmel blog (defunct)
This is a new Template for line chatbot!
Started that in December 2016, idea would be a line chatbot that can do some domotics... First we'll work with the Messaging API of Line.
Points of interest
Basics: get a service running and plugged in Line
Create a business account, as a developer
Make a Channel, but for that you'll need a Provider
On the backend server, make a user linebot :
sudo adduser --disabled-login linebot
If python pip is not here, you can :
python -m ensurepip --default-pip or
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py;python get-pip.py or
python -m ensurepip --default-pip
sudo pip install line-bot-sdk flask
git clone https://github.com/line/line-bot-sdk-python
Make yourself a DNS name, Duck DNS is fantastic and free (thanks guys!)
Now you need a certificate, so use certbot (let's encrypt thanks for your free service!) for that. I tried many options, but ended by using the manual method:
sudo certbot certonly --manual -d myserver.duckdns.org
you'll need to run a parallel simple webserver, but it's all explained on the screen, just read it, you'll end up with you 2 .pem certificate files. You want that key file and your fullchain.pem that is stored in /etc/letsencrypt/live/myserver.duckdns.org/. You can use the privkey that is there too, it's the same as the key file you generated above.
You should now be able to run the basic samples of Line, after editing the code as below to enable listening to outside request (host="0.0.0.0") and enabling the certificates:
mkdir -p /tmp/certbot/public_html/.well-known/acme-challenge
printf "%s" ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > .well-known/acme-challenge/ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
sudo $(command -v python2 || command -v python2.7 || command -v python2.6) -c "import BaseHTTPServer, SimpleHTTPServer; \
s = BaseHTTPServer.HTTPServer(('', 80), SimpleHTTPServer.SimpleHTTPRequestHandler); \
Now go to Line website and go to your channel then provider and edit the 2 webhooks settings:
Use webhooks: set to Enabled
Webhook URL: put the url of your callback service, ie https://myserver.duckdns.org/callback You can even test, though it fails for me with the sample "flask-echo" but it works when you call it by talking to your line bot!
Victory, as you're here, you have a beta prototype working. Good job, go grab a beer. Yes you can, you deserve it.
if __name__ == "__main__":
app.run(host="0.0.0.0", ssl_context=('fullchain.pem', 'privkey.pem'))
Basics: as a docker!
I need a pretext to study docker, sounds about right. I will detail it here.
Natural Language Processing : SpaCy
Install Spacy, Python 2.x, in a Virtualenv, and English catalog
python -m pip install -U virtualenv
pip install -U spacy
python -m spacy download en
Sites you'll need
Line developer portal: https://developers.line.biz/console/
Official getting started with Messaging API https://developers.line.biz/en/docs/messaging-api/getting-started/
Official python SDK https://github.com/line/line-bot-sdk-python
Certbot (Let's encrypt) and Flask
SpaCy the trendy python lib https://spacy.io/usage/