Ejemplo n.º 1
0
        await CONVERSATION_STATE.save_changes(context, True)
        await CLIENT.post_activity(
            CONFIG.APP_ID,
            SKILL_CONFIG.SKILLS[active_skill_id],
            SKILL_CONFIG.SKILL_HOST_ENDPOINT,
            end_of_conversation,
        )

    # Clear out state
    await CONVERSATION_STATE.delete(context)


ADAPTER.on_turn_error = on_error

# Create the Bot
BOT = RootBot(CONVERSATION_STATE, SKILL_CONFIG, CLIENT, CONFIG)

SKILL_HANDLER = SkillHandler(ADAPTER, BOT, ID_FACTORY, CREDENTIAL_PROVIDER,
                             AuthenticationConfiguration())


# Listen for incoming requests on /api/messages
async def messages(req: Request) -> Response:
    # Main bot message handler.
    if "application/json" in req.headers["Content-Type"]:
        body = await req.json()
    else:
        return Response(status=415)

    activity = Activity().deserialize(body)
    auth_header = req.headers[
Ejemplo n.º 2
0
CREDENTIAL_PROVIDER = SimpleCredentialProvider(CONFIG.APP_ID,
                                               CONFIG.APP_PASSWORD)
CLIENT = SkillHttpClient(CREDENTIAL_PROVIDER, ID_FACTORY)

# Create adapter.
# See https://aka.ms/about-bot-adapter to learn more about how bots work.
SETTINGS = BotFrameworkAdapterSettings(CONFIG.APP_ID, CONFIG.APP_PASSWORD)
ADAPTER = AdapterWithErrorHandler(SETTINGS, CONFIG, CONVERSATION_STATE, CLIENT,
                                  SKILL_CONFIG)

DIALOG = MainDialog(CONVERSATION_STATE, ID_FACTORY, CLIENT, SKILL_CONFIG,
                    CONFIG)

# Create the Bot
BOT = RootBot(CONVERSATION_STATE,
              DIALOG)  # , SKILL_CONFIG, ID_FACTORY, CLIENT, CONFIG)

AUTH_CONFIG = AuthenticationConfiguration(
    claims_validator=AllowedSkillsClaimsValidator(CONFIG).claims_validator)

SKILL_HANDLER = SkillHandler(ADAPTER, BOT, ID_FACTORY, CREDENTIAL_PROVIDER,
                             AUTH_CONFIG)


# Listen for incoming requests on /api/messages
async def messages(req: Request) -> Response:
    # Main bot message handler.
    if "application/json" in req.headers["Content-Type"]:
        body = await req.json()
    else:
        return Response(status=HTTPStatus.UNSUPPORTED_MEDIA_TYPE)
Ejemplo n.º 3
0
# Whitelist skills from SKILLS_CONFIG
AUTH_CONFIG = AuthenticationConfiguration(
    claims_validator=AllowedSkillsClaimsValidator(SKILL_CONFIG).claims_validator
)

# Create adapter.
# See https://aka.ms/about-bot-adapter to learn more about how bots work.
SETTINGS = BotFrameworkAdapterSettings(CONFIG.APP_ID, CONFIG.APP_PASSWORD)
ADAPTER = AdapterWithErrorHandler(
    SETTINGS, CONFIG, CONVERSATION_STATE, CLIENT, SKILL_CONFIG
)

DIALOG = MainDialog(CONVERSATION_STATE, ID_FACTORY, CLIENT, SKILL_CONFIG, CONFIG)

# Create the Bot
BOT = RootBot(CONVERSATION_STATE, DIALOG)

SKILL_HANDLER = TokenExchangeSkillHandler(
    ADAPTER,
    BOT,
    CONFIG,
    ID_FACTORY,
    SKILL_CONFIG,
    CLIENT,
    CREDENTIAL_PROVIDER,
    AUTH_CONFIG,
)


# Listen for incoming requests on /api/messages
async def messages(req: Request) -> Response: