LINEBOTLIFF
LINE Messaging APILINE BOTChannel Secret``Channel Access Token
OK
LINEngrokPCAzureAWSEC2PC
ngrokMac
$ brew install ngrok
Ctrl+C
URL
$ ngrok http 21212
https://9b41ad02.ngrok.io
PClocalhost:21212
ngrok by @inconshreveable (Ctrl+C to quit)
Session Status online
Account Yuji Ueki (Plan: Pro)
Update update available (version 2.3.25, Ctrl-U to update
Version 2.2.8
Region United States (us)
Web Interface http://127.0.0.1:4041
Forwarding http://9b41ad02.ngrok.io -> localhost:21212
Forwarding https://9b41ad02.ngrok.io -> localhost:21212
Connections ttl opn rt1 rt5 p50 p90
2 0 0.03 0.01 0.00 0.01
APIChannel Secret``Channel Access Token
URLWebhook
PyPILINEPythonSDKMinetteMinette for Python
requirements.txt
pip install -r requirements.txt
CloneZIPminette.ini
LINE DevelopersChannel SecretChannel Access Token
[line_bot_api]
channel_secret = YOUR_CHANNEL_SECRET
channel_access_token = YOUR_CHANNEL_ACCESS_TOKEN
LINE
$ python run.py
2019-04-17 21:48:01,443 - minette.core - WARNING - Do not use MeCabService tagger for the production environment. This is for trial use only. Install MeCab and use MeCabTagger instead.
2019-04-17 21:48:01,444 - minette.core - INFO - Create 16 worker thread(s)
* Serving Flask app "run" (lazy loading)
* Environment: production
* Debug mode: off
* Running on http://0.0.0.0:21212/ (Press CTRL+C to quit)
Minette11
#
class SpecialEchoDialogService(DialogService):
def compose_response(self, request, context, connection):
#
previous_text = context.data.get("previous_text", "")
#
context.data["previous_text"] = request.text
#
noun = [w.surface for w in request.words if w.part == ""]
#
context.topic.keep_on = True
#
ret = "{}'{}''{}'".format(
request.user.name, request.text, previous_text
)
ret += "\n: {}".format("".join(noun)) if noun else ""
return ret
MinetteDialogRouter``DialogService
DialogService``DialogRouter
dialogs``echo.py
from minette import DialogService
class EchoDialogService(DialogService):
def compose_response(self, request, context, connection):
return "You said: {}".format(request.text)
compose_response``request``text
dialog_router.py
EchoDialogService
from dialogs.echo import EchoDialogService # 1
register_intents``EchoIntent``EchoDialogService
#
def register_intents(self):
self.intent_resolver = {
"TranslationIntent": TranslationDialogService,
"WeatherIntent": WeatherDialogService,
"EchoIntent": EchoDialogService # 2
}
EchoIntent``extract_intent
23Highest
# 3
#
if request.text.startswith(""):
return "EchoIntent", {}, Priority.Highest
extract_intent
LUIS
Ctrl+C``run.py
LINE
https://9b41ad02.ngrok.io/messagelog?key=password key``minette.ini
scheduler.py
5tasks``SecondsTask
SQLiteSQL DatabaseMySQLMinetteexamples
IssueTwitter: @uezochan
Enjoy creating awesome LINEBOT!