The steps for this recipe are as follows:
- Create an app.py file and import the libraries:
from flask import Flask,request,Response
from botbuilder.schema import Activity
from botbuilder.core import (
BotFrameworkAdapter,
BotFrameworkAdapterSettings,
ConversationState,
UserState,
MemoryStorage
)
import asyncio
from luisbot import LuisBot
- Initialize the Flask web server:
app = Flask(__name__)
- Initialize the event loop:
loop = asyncio.get_event_loop()
- Initialize the bot memory and conversation state as well as the user state:
botadaptersettings = BotFrameworkAdapterSettings("","")
botadapter = BotFrameworkAdapter(botadaptersettings)
memstore = MemoryStorage()
constate = ConversationState(memstore)
userstate = UserState(memstore)
botdialog = LuisBot(constate,userstate)
- Set the URL routing:
@app.route("/api/messages",methods=["POST"])
- Loop through the LUIS and Bot Framework logic:
def messages():
if "application...