首页 > 解决方案 > 消息 Microsoft Bot 对模拟器的回复过于不一致和不同

问题描述

该机器人是用 python 开发的,并部署在谷歌应用引擎上。对话机器人在模拟器上流畅运行。但是当我在团队客户端上部署并测试它时,机器人会重复消息或没有收到响应。然后,这会使机器人偏离正题,因为它错过了对某些问题的某些答复。有什么帮助吗?

我的 GAE app.yaml 文件:

runtime: custom
env: flex
entrypoint: gunicorn app:app --bind :8080 --worker-class aiohttp.GunicornWebWorker --timeout 300
service: mma2d

runtime_config:
  python_version: 3


handlers:
- url: /*
  script: auto

我的 app.py 文件:(从顶部删除了依赖项)

CONVERSATION_REFERENCES: Dict[str, ConversationReference] = dict()

# Create MemoryStorage - UserState and ConversationState both stored in memory
MEMORY = MemoryStorage()
CONVERSATION_STATE = ConversationState(MEMORY)
USER_STATE = UserState(MEMORY)

# Create dialog
DIALOG = Dialog(USER_STATE,CONFIG.CONNECTION_NAME)

# Create Bot
BOT = DialogAndWelcomeBot(CONVERSATION_REFERENCES,CONVERSATION_STATE, USER_STATE, DIALOG)

# Application settings defined here. Provides the ID to the adapter which sends the messages.
SETTINGS = BotFrameworkAdapterSettings(CONFIG.APP_ID, CONFIG.APP_PASSWORD)  
ADAPTER = BotFrameworkAdapter(SETTINGS)
APP_ID = SETTINGS.app_id if SETTINGS.app_id else uuid.uuid4()


LOOP = asyncio.get_event_loop() 
async def index(request):
    return web.Response(text="Hello!")


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)

    activity = Activity().deserialize(body)
    print(activity)
    auth_header = req.headers["Authorization"] if "Authorization" in req.headers else ""

    response = await ADAPTER.process_activity(activity, auth_header, BOT.on_turn)
    if response:
        return json_response(data=response.body, status=response.status)
    return Response(status=HTTPStatus.OK)


app = web.Application(middlewares=[aiohttp_error_middleware])
app.router.add_post("/api/calling", messages)
app.router.add_get('/', index)

if __name__ == "__main__":
    # app.run()
    try:
        web.run_app(app)
    except Exception as error:
        raise error 

标签: pythongoogle-cloud-platformbotframeworkbots

解决方案


推荐阅读