RasaHQ / rasa

💬 Open source machine learning framework to automate text- and voice-based conversations: NLU, dialogue management, connect to Slack, Facebook, and more - Create chatbots and voice assistants
https://rasa.com/docs/rasa/
Apache License 2.0
18.63k stars 4.6k forks source link

I don't get any replies from the bot through slack #3252

Closed HovHak closed 5 years ago

HovHak commented 5 years ago
**Rasa version**:13.3 **Python version**: 3.6 **Operating system** (windows, osx, ...):windows 10 **Issue**:I am trying to run my nlu and dialogue models through slack to test how my bot performs but it is not responding to my messages although through ngrok I can see that it receives them **Content of run.py **: ``` from rasa_core.channels.slack import SlackInput from rasa_core.agent import Agent from rasa_core.interpreter import RasaNLUInterpreter import yaml from rasa_core.utils import EndpointConfig nlu_interpreter = RasaNLUInterpreter('./models/nlu/default/MyNLU') action_endpoint = EndpointConfig(url="http://localhost:5055/webhook") agent = Agent.load('./models/dialogue', interpreter = nlu_interpreter, action_endpoint = action_endpoint) input_channel = SlackInput('xoxp-607403756646-592126442018-607420295142-824b897a97a9d1a110681e20bac254db','xoxb-607403756646-603559674128-oIUzV7UMm3g81Nl3HrHzQF5b','nsDsPdiNInDw2IESZM01Dqlq' ) agent.handle_channels([input_channel], 5004, serve_forever=True) ``` ![Capture2](https://user-images.githubusercontent.com/48651497/56073367-7c1af900-5d9a-11e9-941b-46c6ec22f6fb.PNG) ![Capture](https://user-images.githubusercontent.com/48651497/56073370-81784380-5d9a-11e9-9498-7aefd28d7422.PNG) ![Capture3](https://user-images.githubusercontent.com/48651497/56073372-863cf780-5d9a-11e9-84ea-15de220cd96a.PNG) I am kind of very lost now can't see what is the issue keep texting through the channel waiting for a reply. if you see any major issues please let me know
akelad commented 5 years ago

Is this perhaps related to this issue https://github.com/RasaHQ/rasa_nlu/issues/3085 ? cc @erohmensing

HovHak commented 5 years ago

I have followed the issue #3085 and changed my endpoint config from 'http://localhost:5055/webhook' to 'http://localhost:5005/webhooks/slack/webhook' also tried it with 5055, but still, it performs the same way i again see the message is received but nor replies from the bot

HovHak commented 5 years ago

@erohmensing is there any way I can debug and see what can be done to resolve this?, I am still struggling to understand what can cause this. Look forward to hearing from you).

erohmensing commented 5 years ago

@HovHak I'm going to set up a slack bot today to see if I run into the same issue -- If I do, i'll try to figure out what's causing it, and if I don't, we can look at the differences in our configurations. I'll keep you updated.

erohmensing commented 5 years ago

Okay, I've successfully set up a bot on Core 0.13.3, so it definitely does work (barring a button bug that has already been fixed). Some things I notice in your code:

input_channel = SlackInput('xoxp-607403756646-592126442018-607420295142-824b897a97a9d1a110681e20bac254db','xoxb-607403756646-603559674128-oIUzV7UMm3g81Nl3HrHzQF5b','nsDsPdiNInDw2IESZM01Dqlq'
                           )

This auth token looks like an OAuth access token rather than a Bot User OAuth access token, which usually starts with xoxb. Try switching the access token to see if that helps (I tested what happens if you use the other token, and you get 200s but no reply).

Screen Shot 2019-04-16 at 11 52 02

I otherwise wonder what your second argument 'nsDsPdiNInDw2IESZM01Dqlq' is -- this is supposed to be the slack channel, or if you leave this argument out, the bot will respond in the app. Since you look to be talking to the bot in the app, I would suggest leaving out this argument for now to see if you can get replies from within the app.

Can you try changing that line to

input_channel = SlackInput(slack_token=<your bot user Oath token>)

and tell me if you have any more luck? Keep the endpoint config as it was before.

HovHak commented 5 years ago

Okay, I've successfully set up a bot on Core 0.13.3, so it definitely does work (barring a button bug that has already been fixed). Some things I notice in your code:

input_channel = SlackInput('xoxp-607403756646-592126442018-607420295142-824b897a97a9d1a110681e20bac254db','xoxb-607403756646-603559674128-oIUzV7UMm3g81Nl3HrHzQF5b','nsDsPdiNInDw2IESZM01Dqlq'
                           )

This auth token looks like an OAuth access token rather than a Bot User OAuth access token, which usually starts with xoxb. Try switching the access token to see if that helps (I tested what happens if you use the other token, and you get 200s but no reply).

Screen Shot 2019-04-16 at 11 52 02

I otherwise wonder what your second argument 'nsDsPdiNInDw2IESZM01Dqlq' is -- this is supposed to be the slack channel, or if you leave this argument out, the bot will respond in the app. Since you look to be talking to the bot in the app, I would suggest leaving out this argument for now to see if you can get replies from within the app.

Can you try changing that line to

input_channel = SlackInput(slack_token=<your bot user Oath token>)

and tell me if you have any more luck? Keep the endpoint config as it was before.

hi there, thanx for coming back)). i got read of the slack channel and bot user Outh acces token with just leaving the first one and it worked.

however, it did not reply to the rest of my messages things like what is the weather like i presume there is an issue with connecting to the weather apixu

Capture45

it seems that on my actions class it struggles import 'from apixu.client import ApixuClient' I have successfully installed the WeatherAPIXU but can't find any client dependencies in it to call I am using an example of code from https://github.com/JustinaPetr/Weatherbot_Tutorial/blob/master/Full%20Code%20%5BLatest%20release%20of%20Rasa%20NLU%20and%20Rasa%20Core%5D/actions.py

is it up to date?

erohmensing commented 5 years ago

Ah sorry, perhaps you missed my last comment -- keep the endpoint config as before so that it matches the one in your endpoints.yml (it shouldn't need any slack stuff). Are you running the action server before you try to access it?

HovHak commented 5 years ago

Ah sorry, perhaps you missed my last comment -- keep the endpoint config as before so that it matches the one in your endpoints.yml (it shouldn't need any slack stuff). Are you running the action server before you try to access it?

thank you again for coming back),

yes i did not touch the endpoint.yml it is the same as it was, and no i am not running action server i have action class with all the actions in it where the bot suppose to call when it comes to actionWeather or actionScheduleMetting

just like in this page https://github.com/JustinaPetr/Weatherbot_Tutorial/blob/master/Full%20Code%20%5BLatest%20release%20of%20Rasa%20NLU%20and%20Rasa%20Core%5D/actions.py

erohmensing commented 5 years ago

Ah yes so what happens is if you have custom actions, you have to run a custom action server. I do this by running (in a different terminal window)

python -m rasa_core_sdk.endpoint --actions actions

this gives your code access to run the actions in your actions.py file. You should see something like this if you've done it successfully:

2019-04-16 13:42:20 INFO     __main__  - Starting action endpoint server...
2019-04-16 13:42:20 INFO     rasa_core_sdk.executor  - Registered function for 'restaurant_form'.
2019-04-16 13:42:20 INFO     __main__  - Action endpoint is up and running. on ('0.0.0.0', 5055)

Make sure that the url in the action_endpoint = EndpointConfig ... matches that endpoint in your endpoints.yml before re-running your code.

HovHak commented 5 years ago

Ah yes so what happens is if you have custom actions, you have to run a custom action server. I do this by running (in a different terminal window)

python -m rasa_core_sdk.endpoint --actions actions

this gives your code access to run the actions in your actions.py file. You should see something like this if you've done it successfully:

2019-04-16 13:42:20 INFO     __main__  - Starting action endpoint server...
2019-04-16 13:42:20 INFO     rasa_core_sdk.executor  - Registered function for 'restaurant_form'.
2019-04-16 13:42:20 INFO     __main__  - Action endpoint is up and running. on ('0.0.0.0', 5055)

Make sure that the url in the action_endpoint = EndpointConfig ... matches that endpoint in your endpoints.yml before re-running your code.

i am getting an error image

on the cmd i am on the directory where i have both my endpint.yml(and yes i made sure that it is the same as in my code) and the actions.py

erohmensing commented 5 years ago

There shouldn't be a space between -- and actions. Try again, or just copy/paste my command exactly.

HovHak commented 5 years ago

There shouldn't be a space between -- and actions. Try again, or just copy/paste my command exactly. ohh i, this is what i got image

erohmensing commented 5 years ago

Hmm okay. Can you paste your actions code? It looks like there might be something wrong in your actionScheduleMetting code since it successfully registers action_weather but not your meeting scheduling code. What version of rasa_core_sdk are you running?

HovHak commented 5 years ago

Hmm okay. Can you paste your actions code? It looks like there might be something wrong in your actionScheduleMetting code since it successfully registers action_weather but not your meeting scheduling code. What version of rasa_core_sdk are you running?

sure

Content of actions.py:

from rasa_core.actions import Action
# from rasa_core_sdk import Action
# from rasa_core_sdk.events import SlotSet

from rasa_core_sdk import Action
from rasa_core_sdk.events import SlotSet

#from WeatherAPIXU.

class ActionWeather(Action):
    def name(self):
        return 'action_weather'

    def run(self, dispatcher, tracker, domain):
        from apixu.client import ApixuClient
        api_key = '333'  # your apixu key
        client = ApixuClient(api_key)

        loc = tracker.get_slot('location')
        current = client.getcurrent(q=loc)

        country = current['location']['country']
        city = current['location']['name']
        condition = current['current']['condition']['text']
        temperature_c = current['current']['temp_c']
        humidity = current['current']['humidity']
        wind_mph = current['current']['wind_mph']

        response = """It is currently {} in {} at the moment. The temperature is {} degrees, the humidity is {}% and the wind speed is {} mph.""".format(
            condition, city, temperature_c, humidity, wind_mph)

        dispatcher.utter_message(response)
        return [SlotSet('location', loc)]

class ActionScheduleMeeting(Action):
    @property
    def name(self):
        return 'action_schedule_meeting'

    def run(self):
        print('scheduling meeting is completed! ')
        pass

class ActionShowMeeting(Action):
    def name(self):
        return 'action_show_meeting'

    def run(self, dispatcher, tracker, domain):
        dispatcher.utter_message('Here is the meeting information!')
        return []
erohmensing commented 5 years ago

Ah, try getting rid of the @property tag in ActionScheduleMeeting. Also, that run method will need the dispatcher, tracker, domain arguments as well as a return value like the run method of ActionShowMeeting.

HovHak commented 5 years ago

Ah, try getting rid of the @property tag in ActionScheduleMeeting. Also, that run method will need the dispatcher, tracker, domain arguments as well as a return value like the run method of ActionShowMeeting.

ok i did as you said and it started running except it does not perform any action when i ask it on the slack image

I think this might be because of the domain and story file i will attach it just in case. Content of chat_domain.yml:

intents:
    - schedule_meeting
    - search_for_meeting
    - greet
    - inform
    - goodbye

entities:
    - meeting
    - time
    - location

slots:
    location:
         type: text
    time:
         type: text
    meeting:
         type: text

templates:
    utter_greet:
        - 'Hello, how can I help you?'
        - 'Hi, I am here to help.'
    utter_goodbye:
        - 'Talk to you later.'
        - 'Bye bye :('
    utter_ask_meeting_time:
        - 'What time would you like me to schedule your meeting?'
    utter_ask_location:
        - 'In what location?'
actions:
    - utter_greet
    - utter_goodbye
    - utter_ask_meeting_time
    - utter_ask_location
    - actions.ActionShowMeeting
    - actions.ActionWeather

Content of stories.md:

## story 01
*greet
    - utter_greet
*goodbye
    - utter_goodbye
*schedule_meeting
    - utter_ask_meeting_time
*search_for_meeting
    - actions.ActionShowMeeting
*inform
    - actions.ActionWeather
* greet
    - utter_greet
* search_for_meeting
    - action_restart

## Generated Story -4387380784712563648
* inform
    - utter_ask_location
* inform{"location": "italy"}
    - slot{"location": "italy"}
    - actions.ActionWeather
erohmensing commented 5 years ago

Yes, it is likely because of your stories -- you need to make sure you have stories for your flows. Right now the only thing your bot knows about that someone would do after greeting is saying goodbye, so when you search_for_meeting, it doesn't know what to do.

At this point, this issue has diverted from the original issue, and is more about usage than a bug. I would recommend that you work on fleshing out your stories (and perhaps your training data) while testing your bot locally through the command line (best way to train a new bot is through interactive learning) before even trying to deploy it on slack -- this will let you know if something is going wrong in the code before the issues are masked by the connector. If you need help implementing your bot in general, please ask our awesome community for help on the forum.

HovHak commented 5 years ago

Yes, it is likely because of your stories -- you need to make sure you have stories for your flows. Right now the only thing your bot knows about that someone would do after greeting is saying goodbye, so when you search_for_meeting, it doesn't know what to do.

At this point, this issue has diverted from the original issue, and is more about usage than a bug. I would recommend that you work on fleshing out your stories (and perhaps your training data) while testing your bot locally through the command line (best way to train a new bot is through interactive learning) before even trying to deploy it on slack -- this will let you know if something is going wrong in the code before the issues are masked by the connector. If you need help implementing your bot in general, please ask our awesome community for help on the forum.

Thank you you have been of great support. I know how to run interactive training and will do so, after i am finished retraining my NLU model i will retrain and see what works best for it. thank you very much. only there is one thing that's bothering me. in the actions.py my code on PyCharm does not recognize the library from apixu.client import ApixuClient although i have installed package WeatherAPIXU has it been changed can i still get the weather check from the geolocations?

image

I am using the code provided in https://github.com/JustinaPetr/Weatherbot_Tutorial/blob/master/Full%20Code%20%5BLatest%20release%20of%20Rasa%20NLU%20and%20Rasa%20Core%5D/actions.py

erohmensing commented 5 years ago

hmm it doesn't look like it comes from WeatherAPIXU package but rather the apixu package on github. Make sure to download all of the requirements in the requirements file using

pip install -r requirements.txt

which should get the library from git+https://github.com/apixu/apixu-python.git for you.

HovHak commented 5 years ago

hmm it doesn't look like it comes from WeatherAPIXU package but rather the apixu package on github. Make sure to download all of the requirements in the requirements file using

pip install -r requirements.txt

which should get the library from git+https://github.com/apixu/apixu-python.git for you.

is there any way to install it on PyCharm ? i am running thorugh its venv where it has all the packages installed

erohmensing commented 5 years ago

Hm, for that i'm not sure, I don't use PyCharm. I would say either google it (the answer with 11 upvotes here looks promising (change the URL to the one in my last comment of course) -- but honestly the easiest way is to just use the Terminal window of your Pycharm to navigate to the project directory with the requirements.txt (you should already be in your venv, but if not, activate it) and use the command to install everything. From the looks of it you might have to restart pycharm to get it to recognize that you have the package installed.

On another note -- if you test your bot and it actually does get the weather (regardless of whether pycharm seems to recognize the library), you're fine.

HovHak commented 5 years ago

Hm, for that i'm not sure, I don't use PyCharm. I would say either google it (the answer with 11 upvotes here looks promising (change the URL to the one in my last comment of course) -- but honestly the easiest way is to just use the Terminal window of your Pycharm to navigate to the project directory with the requirements.txt (you should already be in your venv, but if not, activate it) and use the command to install everything. From the looks of it you might have to restart pycharm to get it to recognize that you have the package installed.

On another note -- if you test your bot and it actually does get the weather (regardless of whether pycharm seems to recognize the library), you're fine.

thank you again i will see to that, you are doing amazing job!