Search code examples
pythonbotframeworkazure-language-understanding

Issue in connecting with LUIS platform from Python v4 botframework


I am trying to run the below github project :-

Python Core Bot

in main_dialog.py below lines (70-73) are relevant:

# Call LUIS and gather any potential booking details. (Note the TurnContext has the response to the prompt.)
        intent, luis_result = await LuisHelper.execute_luis_query(
            self._luis_recognizer, step_context.context
        )

Configured config.py with Luis app id ,key and hostname

When i run the python app :- python app.py

and start chatbot emulator ,it doesn't recognizes the LUIS intent and i also get an error.

More description of error, i have provided in below link:

Chatbot v4 issue raised github

Steps to reproduce: Configure config.py with Luis app id,key and host. Run app using python app.py Start chatbot emulator and open bot with http://localhost:3978/api/messages url. Enter your message as per screenshot.

enter image description here

Case 1. Luis host id is configured with value starting with https:// i.e https://XXXX.XXXX.XXX in config.py

Blow error occurs: Error occurred in request., ConnectionError: HTTPSConnectionPool(host='https', port=443): Max retries exceeded with url: /southcXXX.api.XXXXX.microsoft.com/luis/v2.0/ap ps/?log=true (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))

Case 2. When luis host is configured without https:// i.e XXXX.XXXX.XXXX

Then luis intents are not recognized in main_dialog.py . It finally goes to didnt_understand_message part i.e Sorry, I didn't get that. Please try asking in a different way in chatbot (attached in screenshot)

# Call LUIS and gather any potential booking details. (Note the TurnContext has the response to the prompt.)
intent, luis_result = await LuisHelper.execute_luis_query(
    self._luis_recognizer, step_context.context
)

if intent == Intent.BOOK_FLIGHT.value and luis_result:
    # Show a warning for Origin and Destination if we can't resolve them.
    await MainDialog._show_warning_for_unsupported_cities(
        step_context.context, luis_result
    )

    # Run the BookingDialog giving it whatever details we have from the LUIS call.
    return await step_context.begin_dialog(self._booking_dialog_id, luis_result)

if intent == Intent.GET_WEATHER.value:
    get_weather_text = "TODO: get weather flow here"
    get_weather_message = MessageFactory.text(
        get_weather_text, get_weather_text, InputHints.ignoring_input
    )
    await step_context.context.send_activity(get_weather_message)

else:
    didnt_understand_text = (
        "Sorry, I didn't get that. Please try asking in a different way"
    )
    didnt_understand_message = MessageFactory.text(
        didnt_understand_text, didnt_understand_text, InputHints.ignoring_input
    )
    await step_context.context.send_activity(didnt_understand_message)

return await step_context.next(None)

Please help. Thanks in Advance.


Solution

  • This issue is resolved Now. Luis host format was added in config.py file was having https:// which was causing issue. I just removed that from url and it worked fine for me.

    https://xxx.xxx.xxx - Wrong format for this Python project. xxxx.xxxx.xxx - Correct format.