예제 #1
0
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

import asyncio

from adapter import ConsoleAdapter
from bot import Name
from bot import Gender

# Create adapter
ADAPTER = ConsoleAdapter()
BOT = Name()
BOT= Gender()
LOOP = asyncio.get_event_loop()

if __name__ == "__main__":
    try:
        # Greet user
        print("Hi... I'm a Health Bot (Still in Development State) ")
        print("What is your Name?")

        LOOP.run_until_complete(ADAPTER.process_activity(BOT.on_turn))
       
    except KeyboardInterrupt:
        pass
    finally:
        LOOP.stop()
        LOOP.close()
예제 #2
0
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

import asyncio
from botbuilder.core import TurnContext, ConversationState, UserState, MemoryStorage
from botbuilder.schema import ActivityTypes

from adapter import ConsoleAdapter
from bot import EchoBot

# Create adapter
adapter = ConsoleAdapter()
bot = EchoBot()

loop = asyncio.get_event_loop()

if __name__ == "__main__":
    try:
        # Greet user
        print("Hi... I'm an echobot. Whatever you say I'll echo back.")

        loop.run_until_complete(adapter.process_activity(bot.on_turn))
    except KeyboardInterrupt:
        pass
    finally:
        loop.stop()
        loop.close()
예제 #3
0
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

import asyncio
from botbuilder.core import BotContext, ConversationState, UserState, MemoryStorage
from botbuilder.schema import ActivityTypes

from adapter import ConsoleAdapter

# Create adapter
adapter = ConsoleAdapter()

# Create MemoryStorage, UserState and ConversationState
memory = MemoryStorage()
# Commented out user_state because it's not being used.
# user_state = UserState(memory)
conversation_state = ConversationState(memory)

# Register both State middleware on the adapter.
# Commented out user_state because it's not being used.
# adapter.use(user_state)
adapter.use(conversation_state)


async def logic(context: BotContext):
    if context.activity.type == ActivityTypes.message:
        state = await conversation_state.get(context)

        # If our conversation_state already has the 'count' attribute, increment state.count by 1
        # Otherwise, initialize state.count with a value of 1
        if hasattr(state, 'count'):
예제 #4
0
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

#import asyncio
import asyncio
from botbuilder.core import TurnContext, ConversationState, UserState, MemoryStorage
from botbuilder.schema import ActivityTypes

from adapter import ConsoleAdapter
from bot import EchoBot

# Create adapter
adapter = ConsoleAdapter()
bot = EchoBot()

loop = asyncio.get_event_loop()

if __name__ == "__main__":
    try:
        # Greet user
        print("Hi... I'm an echobot. Ask me a question")

        loop.run_until_complete(adapter.process_activity(bot.qnaCaller))
    except KeyboardInterrupt:
        pass
    finally:
        loop.stop()
        loop.close()