Slack integration error with interactive components

Hey, I integrated my Rasa bot in Slack. I have some buttons defined in my domain file : utter_otherQuestions:

  • text: “Do you have any other question?” buttons:
    • title: “Yes” payload: ‘/affirm’
    • title: “No” payload: ‘/deny’

I followed all the instructions, after running rasa and hitting the button in slack, I get the error: 2020-04-05 13:30:51 WARNING rasa.core.channels.slack - Received message on unsupported channel: D010VBL775H [2020-04-05 13:30:56 +0200] [1376] [ERROR] Exception occurred while handling uri: ‘http://ac8cc757.ngrok.io/webhooks/slack/webhook

So basically when I hit the button in slack, nothing happens. Can someone help me here?

You can set channel specific responses in rasa. Please visit this link :

@athenasaurav Hey, Thanks for the help. I did add the channel specific response in my domain file:

responses:
  utter_greet:
  - text: "Welcome to Rasa digital assistant! It can provide you information about tracked products. What would you like to know?"
    channel: "slack"
    custom:
    - # payload for Slack buttons
    - title: "Location of the product"
      payload: '/Where{"productNumber": "None"}'
    - title: "Business step of the product"
      payload: '/why{"location": "None"}'
    - title: "Products in the location"
      payload: '/what{"location": "None"}'

But still, I get the same error:

2020-04-06 10:51:10 WARNING  rasa.core.channels.slack  - Received message on unsupported channel: D010VBL775H
[2020-04-06 10:51:13 +0200] [24009] [ERROR] Exception occurred while handling uri: 'http://ea7a90fb.ngrok.io/webhooks/slack/webhook'
Traceback (most recent call last):
  File "/home/home/assistant/lib/python3.7/site-packages/sanic/request.py", line 173, in load_json
    self.parsed_json = loads(self.body)
ValueError: Expected object or value

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/home/assistant/lib/python3.7/site-packages/sanic/app.py", line 976, in handle_request
    response = await response
  File "/home/home/assistant/lib/python3.7/site-packages/rasa/core/channels/slack.py", line 356, in webhook
    metadata = self.get_metadata(request)
  File "/home/home/assistant/lib/python3.7/site-packages/rasa/core/channels/slack.py", line 329, in get_metadata
    slack_event = request.json
  File "/home/home/assistant/lib/python3.7/site-packages/sanic/request.py", line 167, in json
    self.load_json()
  File "/home/home/assistant/lib/python3.7/site-packages/sanic/request.py", line 177, in load_json
    raise InvalidUsage("Failed when parsing body as json")
sanic.exceptions.InvalidUsage: Failed when parsing body as json

Any Idea how I can get rid of this error? I am trying to solve it for 4 days, but were not successfull.

1 Like

Hi. Does you buttom appears but payload is not delivered.

@athenasaurav yes, the buttons appear. I hit one and then nothing happens.

when I run ra run --enable-api --cors "*" --debug in my terminal, I also get this:

2020-04-06 11:45:30 DEBUG rasa.nlu.classifiers.diet_classifier - Failed to load model for 'ResponseSelector'. Maybe you did not provide enough training data and no model was trained or the path '/tmp/tmpcaixaoxb/nlu' doesn't exist? And then comes the error I mentioned above.

I thought so too. Can you show your intent, stories and domain data completely

@athenasaurav This is my stories file:

## greet
* greet
  - utter_greet

## goodbye
* goodbye
  - utter_goodbye

## what with correct location name
* what{"location":"Robot area"}
  - action_product_search
  - slot{"location":"Robot area"}
  - slot{"productNumber":"LB-4488-3-A1103"}
  - utter_otherQuestions
* affirm
  - utter_suggestions

## what with correct location name
* what{"location":"Robot area"}
  - action_product_search
  - slot{"location":"Robot area"}
  - slot{"productNumber":"LB-4488-3-A1103"}
  - utter_otherQuestions
* deny
  - utter_goodbye

## greet + what with no location name
* greet
  - utter_greet
* what
  - utter_ask_location
* inform{"location":"Robot area"}
  - action_product_search
  - slot{"location":"Robot area"}
  - slot{"productNumber":"LB-4488-3-A1103"}
  - utter_otherQuestions
* affirm
  - utter_suggestions

## greet + what with no location name
* greet
  - utter_greet
* what
  - utter_ask_location
* inform{"location":"Robot area"}
  - action_product_search
  - slot{"location":"Robot area"}
  - slot{"productNumber":"LB-4488-3-A1103"}
  - utter_otherQuestions
* deny
  - utter_goodbye

## where with correct PN
* where{"productNumber":"LB-4488-3-A1103"}
  - action_location_search
  - slot{"productNumber":"LB-4488-3-A1103"}
  - slot{"location":"Cold storage"}
  - utter_otherQuestions
* affirm
  - utter_suggestions

## where with correct PN
* where{"productNumber":"LB-4488-3-A1103"}
  - action_location_search
  - slot{"productNumber":"LB-4488-3-A1103"}
  - slot{"location":"Cold storage"}
  - utter_otherQuestions
* deny
  - utter_goodbye

## greet + where with no PN + affirm
* greet
  - utter_greet
* where
  - utter_ask_productNumber
* inform{"productNumber":"LB-4488-3-A1103"}
  - action_location_search
  - slot{"location":"Robot area"}
  - slot{"productNumber":"LB-4488-3-A1103"}
  - utter_otherQuestions
* affirm
  - utter_suggestions

## greet + where with no PN + deny
* greet
  - utter_greet
* where
  - utter_ask_productNumber
* inform{"productNumber":"LB-4488-3-A1103"}
  - action_location_search
  - slot{"location":"Robot area"}
  - slot{"productNumber":"LB-4488-3-A1103"}
  - utter_otherQuestions
* deny
  - utter_goodbye

## where with different PNs
* where{"productNumber":"LB-4488-3-A1103"}
  - action_location_search
  - slot{"productNumber":"LB-4488-3-A1103"}
  - slot{"location":"Robot area"}
  - utter_otherQuestions
* affirm
  - utter_suggestions
* where{"productNumber":"LB-4488-3-A1102"}
  - action_location_search
  - slot{"productNumber":"LB-4488-3-A1102"}
  - slot{"location":"Pod Tiling area"}
  - utter_otherQuestions
* deny
  - utter_goodbye

## why with correct PN
* why{"productNumber":"LB-4488-3-A1103"}
  - action_bizStep_search
  - slot{"productNumber":"LB-4488-3-A1103"}
  - slot{"location":"Robot area"}
  - utter_otherQuestions
* affirm
  - utter_suggestions

## why with correct PN
* why{"productNumber":"LB-4488-3-A1103"}
  - action_bizStep_search
  - slot{"productNumber":"LB-4488-3-A1103"}
  - slot{"location":"Robot area"}
  - utter_otherQuestions
* deny
  - utter_goodbye

## greet + why with no PN + affirm
* greet
  - utter_greet
* why
  - utter_ask_productNumber
* inform{"productNumber":"LB-4488-3-A1103"}
  - action_bizStep_search
  - slot{"location":"Robot area"}
  - slot{"productNumber":"LB-4488-3-A1103"}
  - utter_otherQuestions
* affirm
  - utter_suggestions

## greet + where with no PN + deny
* greet
  - utter_greet
* why
  - utter_ask_productNumber
* inform{"productNumber":"LB-4488-3-A1103"}
  - action_bizStep_search
  - slot{"location":"Robot area"}
  - slot{"productNumber":"LB-4488-3-A1103"}
  - utter_otherQuestions
* deny
  - utter_goodbye

this is how my domain file looks:

intents:
  - greet
  - goodbye
  - affirm
  - deny
  - what
  - where
  - why
  - inform

entities:
  - productNumber
  - location

slots:
  location:
    type: unfeaturized
    auto_fill: True
  productNumber:
    type: unfeaturized
    auto_fill: True

actions:
  - utter_greet
  - utter_goodbye
  - utter_otherQuestions
  - utter_suggestions
  - utter_ask_location
  - utter_ask_productNumber
  - action_location_search
  - action_bizStep_search
  - action_product_search
  
responses:
  utter_greet:
  - text: "Welcome to Rasa digital assistant! It can provide you information about tracked products. What would you like to know?"
    channel: "SlackBot"
    custom: 
    - # payload for Slack buttons
    buttons:
    - title: "Location of the product"
      payload: '/where'
    - title: "Business step of the product"
      payload: '/why'
    - title: "Products in the location"
      payload: '/what'
  - text: "Welcome to Rasa digital assistant! It can provide you information about tracked products. What would you like to know?"
    buttons:
    - title: "Location of the product"
      payload: '/Where'
    - title: "Business step of the product"
      payload: '/why'
    - title: "Products in the location"
      payload: '/what'

  utter_ask_location:
  - text: "Please tell me a valid location name."
  
  utter_ask_productNumber:
  - text: "Please tell me a valid product number."

  utter_goodbye:
  - text: "Bye!"

  utter_otherQuestions:
  - text: "Do you have any other question?"
    channel: "SlackBot"
    custom:
    - # payload for Slack buttons
    buttons:
    - title: "Yes"
      payload: '/affirm'
    - title: "No"
      payload: '/deny'
  - text: "Do you have any other question?"
    buttons:
    - title: "Yes"
      payload: '/affirm'
    - title: "No"
      payload: '/deny'

  utter_suggestions:
  - text: "What would you like to know?"

session_config:
  session_expiration_time: 60
  carry_over_slots_to_new_session: false

my endpoin is:

action_endpoint:
  url: http://localhost:5055/webhook

and credentials is:

rest:
#  # you don't need to provide anything here - this channel doesn't
#  # require any credentials

slack:
  slack_token: "xoxb-631506400631-1xxxxxx4-TR7ZcBsY5gvXyGlrw6eodw5w"
  slack_channel: "#vui-design"
  slack_retry_reason_header: "x-slack-retry-reason"  # Slack HTTP header name indicating reason that slack send retry request. This configuration is optional.
  slack_retry_number_header: "x-slack-retry-num"  # Slack HTTP header name indicating the attempt number. This configuration is optional.
  errors_ignore_retry: None  # Any error codes given by Slack included in this list will be ignored. Error codes are listed `here <https://api.slack.com/events-api#errors>`_.

rasa:
  url: "http://localhost:5002/api"

Intents also please

Channel need to be Slack not slackbot

@athenasaurav you mean my nlu data?

Yes

@athenasaurav I corrected the channel name to slack, but still the same error. here is my nlu data:

## intent:greet

- hey

- hello

- hi

- good morning

- good evening

- hey there

- hello assistant

- hey assistant

- hi assistant

- hi rasa

- hi digital assistant

- hello rasa

- hello digital assistant

## intent:goodbye

- bye

- goodbye

- see you around

- see you later

- thanks

- that's all. thanks

## intent:affirm

- yes

- indeed

- of course

- that sounds good

- correct

## intent:deny

- no

- never

- I don't think so

- don't like that

- no way

- not really

## intent:what

- what is in [storage](location)

- which product is in [robot](location)

- tell me the products in [tiling](location)

- what product is under [installation](location)

- tell me the products in [Pod Tiling](location)

- what can you find in the [Storage Area](location)

- tell me a list of all products in the [Cold Storage](location)

- i want to know a list of products in this location

- i need to know the products currently [entering](location)

- What's in the [tiling area](location) at the moment

- products in the [Cold](location) area

- Give me a list of all products that are [exiting](location)

- tell me which products are in the [Robot Area](location)?

- what is in the [robot area](location)

- what is in [Robot area](location)?

- what is in [robot area](location)

- what is in the [storage area](location)

- what is in the [storage](location)

- products in the [Tiling](location)

- which products are they [installing](location)

- list of products in [tiling area](location)

- inform me about all products in [pod tiling](location)

- what is [entering and exiting](location)

- what is in currently [entering](location:Cold storage)

- what is in the [room number one](location)

- what is in the [kitchen](location)

- what is in the [business location](location)

- I want to know the products in the [business area](location)

- I want to know the list of products in the [shop floor area](location)

- what else is in this location?

- Products in the location

## intent:where

- Where's the product [LB-4488-3-A1101](productNumber) at the moment

- Find [LB-4488-3-A1102](productNumber)

- Where can I find [LB-4488-3-A1103](productNumber)

- Help me to find the product [LB-4488-3-A1103](productNumber)

- I want to know the current location of the product [LB-4488-3-A1104](productNumber)

- Location of [LB-4488-3-A1102](productNumber)

- Tell me where is [LB-4488-3-A1102](productNumber)

- Let's find [LB-4488-3-A1101](productNumber)

- Tell me in which business location is [LB-4488-3-A1103](productNumber)

- where is [LB-4488-3-A1102](productNumber)

- where is [A1102] (productNumber)

- where is the product [1102](productNumber)

- Location of the product

- Location of a product

- business location

## intent:why

- What is happening to [LB-4488-3-A1101](productNumber)

- [LB-4488-3-A1102](productNumber)

- business step for [LB-4488-3-A1103](productNumber)

- what is the business step for [LB-4488-3-A1103](productNumber)

- at which business step is [A1103](productNumber)

- why is it there?

- Business step of the product

- what is happening to it?

- what is happening to this product

- what is the business step

- business step

## intent:inform

- [LB-4488-3-A1101](productNumber)

- [LB-4488-3-A1104](productNumber)

- [LB-4488-3-A1103](productNumber)

- [LB-4488-3-A1102](productNumber)

- [1103](productNumber)

- [A1113](productNumber)

- the product number is [LB-4488-3-A1101](productNumber)

- the product number is [LB-4488-3-A1105](productNumber)

- the location is [robot area](location)

- the location is [cold storage](location)

- [robot](location)

- [storage](location)

- [storage area](location)

- [entering](location)

- [exiting](location)

- [installation](location)

- [tiling](location)

- [pod tiling area](location)

- [pod tiling](location)

- [shop floor](location)

## synonym:Cold storage

- exiting

- cold area

- cold storage

- entering and exiting

- entering

- cold storage area

- Cold Storage

- Cold

- Storage Area

- storage

- storage area

## synonym:Pod Tiling area

- Tiling

- Pod Tiling

- installing

- tiling

- pod tiling

- installation

- tiling area

- pod tiling area

## synonym:Robot area

- robot area

- Robot Area

- robot

Okay i got it. You custom channel payload is incorrect. Your payload should be like.

utter_greet:
- text : "Wecome to Rasa digital assistant"
  channel: "Slack"
  custom:
  - text : "what would u like to know?"
     buttons:
     - title: "Location of the product"
       payload: '/Where's the product LB-4488-3-A1101 at the moment'
    - title: "Business step of the product"
      payload: '/why is it there?'
    - title: "Products in the location"
      payload: '/what is in storage.'

similarly for others.

@athenasaurav Thanks for giving me your time. I did the changes as you proposed in the domain file, but I am still getting the same error. :frowning:

Hello please refer to this thread Slack buttons fail silently

1 Like

@akelad @Juste Hi Rasa team, could you please help me with this issue. Thank you.

Hi Mina,

Under Apps at the bottom of the channels pane, find your app and try sending a direct message.

In the credentials.yml, replace

slack_channel: "#vui-design"

with

slack_channel: "D010VBL775H"

Greg

Thank you for the help so far. However, the problem persists. I investigated the error further and drilled down to slack.py and request.py. The lowest-level error I found is this: “Failed when parsing body as json” in the request.py. line 173. I cannot parse the body of the response and outputting the body reveals to me that the body is not a valid json.

It looks like this (xxx I used to replace real data):

‘payload={“type”:“block_actions”,“user”:{“id”:“UJHLBCLMT”,“username”:“xxx”,“name”:“xxx”,“team_id”:“TJKEWBSJK”},“api_app_id”:“xxx”,“token”:“xxx”,“container”:{“type”:“message”,“message_ts”:“1586512448.003600”,“channel_id”:“D010VBL775H”,“is_ephemeral”:false},“trigger_id”:“1063872498833.631506400631.785c625eb6683cd0e4fc973f28870f67”,“team”:{“id”:“TJKEWBSJK”,“domain”:“biba-workspace”},“channel”:{“id”:“D010VBL775H”,“name”:“directmessage”},“message”:{“bot_id”:“B0118SEML31”,“type”:“message”,“text”:“Welcome+to+Rasa+digital+assistant!+It+can+provide+you+information+about+products.+What+would+you+like+to+know?”,“user”:“U0116RJKP0Q”,“ts”:“1586512448.003600”,“team”:“TJKEWBSJK”,“blocks”:[{“type”:“section”,“block_id”:“B2A”,“text”:{“type”:“plain_text”,“text”:“Welcome+to+Rasa+digital+assistant!+It+can+provide+you+information+about+products.+What+would+you+like+to+know?”,“emoji”:true}},{“type”:“actions”,“block_id”:“WCej”,“elements”:[{“type”:“button”,“action_id”:“1Eq”,“text”:{“type”:“plain_text”,“text”:“Affirm”,“emoji”:true},“value”:“affirm”}]}]},“response_url”:“https://hooks.slack.com/actions/TJKEWBSJK/1063872498705/HyIZ0Vg7Bgwbeug5mjntcZTX”,“actions”:[{“action_id”:“1Eq”,“block_id”:“WCej”,“text”:{“type”:“plain_text”,“text”:“Affirm”,“emoji”:true},“value”:“affirm”,“type”:“button”,“action_ts”:“1586512450.073137”}]}’

To me this looks like Rasa cannot properly process the button response from Slack.