Message Menu in Slack

Hey, I am trying out different features that can be incorporated in a slack channel. i was able to figure out how to display and track a button control. But similarly would like to know how to incorporate other interactive components like message menu into Slack. also I would like to know how to send files into the channel via custom actions

Hi again Aysa,

Most of the actions you are looking for are found in rasa_core.channels.slack – there you’ll find methods like send_text_with_buttons and _get_button_reply as well as send_attachment.

@erohmensing i’m very new to rasa could you please provide sample code for send_attachment

@mohan, have you set up your slack channel yet?

Yes… I tried using Creating a graph in the custom action and rendering the graph to the UI but i’m not getting any attachment in chat window and also not getting any error. Here is the code

   from rasa_core.channels.slack import SlackBot
   my_slack = SlackBot('slack token')
   my_slack.send_attachment(recipient_id=None,attachment='attachment path')

Is your slackbot working at all? I.e. are you getting a message in the chat window with no attachment? Can you successfully send messages? That will help me figure out if it’s an attachment problem

@erohmensing Yes I’m able to send and receive messages… but for attachment i get Attachment: file_name, do i have to configure slack to receive images or have to work with the code?

If you’re trying to send images, I think you want send_image_url rather than send_attachment.

Here’s what the method looks like:

def send_image_url(self, recipient_id, image_url, message=""):
        image_attachment = [{"image_url": image_url,
                             "text": message}]
        recipient = self.slack_channel or recipient_id
        return super(SlackBot, self).api_call("chat.postMessage",
                                              channel=recipient,
                                              as_user=True,
                                              attachments=image_attachment)
1 Like

Thank you @erohmensing , It didn’t help i want to send image itself.