Basic Python Echo Bot not addressable through Bot Framework Emulator (Post 500) after linking to Azure QnA Maker

170 Views Asked by At

I have followed the official instructions (Docs) on how to create a python echo bot with the SDKv4 and as soon as the described init function is added my bot ceases to work. The echo bot by itself, without the connection to the Azure QnA Maker works perfectly within the Bot Framework Emulator.

The Error displayed in the Bot Framework Emulator: POST500directline/conversations//activities. Also it doesn't display the welcoming message any more and when I send a message the bot apparently does not receive that message (send failed, retry is displayed below the message).

This problem occurs after adding the init function from the guide to the MyBot class from the bot.py file. The function reads:

def __init__(self, config: Config):
   self.qna_maker = QnAMaker(
      QnAMakerEndpoint(
         knowledge_base_id=config["QNA_KNOWLEDGEBASE_ID"],
         endpoint_key=config["QNA_ENDPOINT_KEY"],
         host=config["QNA_ENDPOINT_HOST"],
   )
)

When following the guide, I had to move the bot instance creation to the very bottom of the app.py file, below:

APP = web.Application(middlewares=[aiohttp_error_middleware])
APP.router.add_post("/api/messages", messages)
if __name__ == "__main__": (...)` 

as the code otherwise doesn't run: BOT = MyBot(APP.config) causes: NameError: name 'APP' is not defined

Also I get the problem in the app.py file: No name 'DefaultConfig' in module 'config' - even though config.py exists and is obviously used as the ports change when I change them in the config file.

Aside from that I followed the guide precisely. I would be very thankful for any help or resource recommendations, over the past two days I've tried to everything I could find online. Thank you!

0

There are 0 best solutions below