-1

I am trying to replicate the FYI bot and I am stuck at the below step. I need help with the code on how to send a post request to irccat.etsy.com using slack outgoing webhook. I was able to create outgoing webhook but I am not sure what to keep in URL and also how to send a post request to irccat.etsy.com

Step I am trying to implement:

"When the :fyi: reacji is added to a Slack message (or the ?fyi irccat command is used), an outgoing webhook sends a POST request to irccat.etsy.com with the message details. This triggers a PHP script to save the message text to a SQLite database, and sends an acknowledgement back to the Slack incoming webhook endpoint. The acknowledgement says “OK! Added your FYI”, so the user knows their FYI has been successfully added to the database.

This App cannot be implemented using Events API so below is how I configured the Outgoing webhook. Outgoing Webhook

I need lead to use URL of outgoing Webhook and generate a post request to irccat.etsy.com

Tannu Priya
  • 313
  • 2
  • 15
  • Hi and welcome to SO. Please add the relevant part of your current code to the question. – Erik Kalkoken Jul 01 '19 at 18:28
  • Please also note that Outgoing Webhooks are outdated and should no longer be used. Use Events API instead. – Erik Kalkoken Jul 01 '19 at 18:28
  • Since you are using Python I would recommend building with the official Slack lib. Makes it much easier: https://github.com/slackapi/python-slackclient – Erik Kalkoken Jul 01 '19 at 19:17
  • Thank you for acknowledging the question @ErikKalkoken . I am done building the Bot and I created a custom emoji for the trigger. I am not sure how to connect to [irclib](https://github.com/jbalogh/python-irclib/blob/master/irccat) using . `{ "type": "reaction_added", "user": "XYZ", "reaction": "fyi_emoji", "item_user": "XYZ", "item": { "type": "message", "channel": "XYZ", "ts": "1360782400.498405" }, "event_ts": "1360782804.083113" } ` . Or how to send a post request from the code to irccat – Tannu Priya Jul 01 '19 at 19:26
  • Please add the part of your code to the question (not comment) that relates to your problem – Erik Kalkoken Jul 01 '19 at 19:32
  • @ErikKalkoken There is no code pertaining to POST request and that is what I am seeking. Outgoing Webhook(Please refer Image in question) will create a post request to irccat.etsy.com and what to put in URL of outgoing webhook to trigger irccat.etsy.com is my question. – Tannu Priya Jul 01 '19 at 20:42
  • The recommended approach would be to listen to [reaction_added](https://api.slack.com/events/reaction_added) event. And then have your event worker make the POST request to that API. You can learn about the Events API here: https://api.slack.com/events-api – Erik Kalkoken Jul 01 '19 at 22:31

1 Answers1

0
you can refer this: https://realpython.com/getting-started-with-the-slack-api-using-python-and-flask/

its like:
Add a new function under channel_info named send_message:

    def send_message(channel_id, message):
        slack_client.api_call(
            "chat.postMessage",
            channel=channel_id,
            text=message,
            username='pythonbot',
            icon_emoji=':robot_face:'
        )

send_message takes in the ID for a channel, then posts a message from our “Python bot” to that channel. In addition, modify the main function so that when we run this file, main will call our new send_message function: