Esempio n. 1
0
    MemoryStorage,
    UserState,
    TurnContext,
)
from botbuilder.schema import Activity, ActivityTypes
from botbuilder.applicationinsights import ApplicationInsightsTelemetryClient
from botbuilder.applicationinsights.flask import BotTelemetryMiddleware

from dialogs import MainDialog
from bots import DialogAndWelcomeBot

# Create the loop and Flask app
LOOP = asyncio.get_event_loop()
app = Flask(__name__, instance_relative_config=True)
app.config.from_object("config.DefaultConfig")
app.wsgi_app = BotTelemetryMiddleware(app.wsgi_app)

# Create adapter.
# See https://aka.ms/about-bot-adapter to learn more about how bots work.
SETTINGS = BotFrameworkAdapterSettings(app.config["APP_ID"],
                                       app.config["APP_PASSWORD"])
ADAPTER = BotFrameworkAdapter(SETTINGS)


# Catch-all for errors.
async def on_error(context: TurnContext, error: Exception):
    # This check writes out errors to console log .vs. app insights.
    # NOTE: In production environment, you should consider logging this to Azure
    #       application insights.
    print(f"\n [on_turn_error] unhandled error: {error}", file=sys.stderr)
Esempio n. 2
0
    MemoryStorage,
    UserState,
    TurnContext,
)
from botbuilder.schema import Activity, ActivityTypes
from botbuilder.applicationinsights import ApplicationInsightsTelemetryClient
from botbuilder.applicationinsights.flask import BotTelemetryMiddleware

from dialogs import MainDialog
from bots import DialogAndWelcomeBot

# Create the loop and Flask app
LOOP = asyncio.get_event_loop()
APP = Flask(__name__, instance_relative_config=True)
APP.config.from_object("config.DefaultConfig")
APP.wsgi_app = BotTelemetryMiddleware(APP.wsgi_app)

# Create adapter.
# See https://aka.ms/about-bot-adapter to learn more about how bots work.
SETTINGS = BotFrameworkAdapterSettings(APP.config["APP_ID"], APP.config["APP_PASSWORD"])
ADAPTER = BotFrameworkAdapter(SETTINGS)


# Catch-all for errors.
async def on_error(context: TurnContext, error: Exception):
    # This check writes out errors to console log .vs. app insights.
    # NOTE: In production environment, you should consider logging this to Azure
    #       application insights.
    print(f"\n [on_turn_error] unhandled error: {error}", file=sys.stderr)

    # Send a message to the user