Git Product home page Git Product logo

Comments (15)

d4mation avatar d4mation commented on June 13, 2024 1

Turns out the Extra Arguments are misleading and are only there because Slack got lazy and didn't want to ensure there was a field for every option with the API Tester for each Endpoint. It isn't meant to pass extra data.

However, I can pass a JSON Object as the Value of a Button, so we can get as much Extra Data through as we could possibly need 👍

from edd-slack.

d4mation avatar d4mation commented on June 13, 2024

Made a quick hack in another branch to add some buttons to every Slack Notification and it looks like we will need to have a Slack App registered. I thought maybe we could just have it point to WP REST API endpoints directly from the Incoming Webhook itself.

This poses a few challenges:

  • It absolutely requires SSL. No SSL, no fancy buttons. Ideally we'd have some kind of error-handler in place to just not add the buttons for non-SSL sites. Maybe by checking get_option( 'siteurl' ) for https?
  • The WP REST API is still usable for this, but everything must point to a single Endpoint and the callback_id will then to call another function like edd_slack_api_<callback_id>. That way the integrations can all seamlessly integrate.

However, the larger challenge for now is the SSL requirement and the requirement that the Server is publicly accessible. This means my local environment won't be able to test these buttons properly as it needs to go from Slack Client -> Slack Servers -> EDD Instance -> Slack Client.

I'd rather not test something like that on RBP as that's all Live Data... Do we have a public WP install that I could just mess around in with no repercussions? I suppose I could potentially spin up something on my Raspberry Pi or something as well, but I'd rather things be a bit more "production ready" than that.

from edd-slack.

d4mation avatar d4mation commented on June 13, 2024

image

from edd-slack.

d4mation avatar d4mation commented on June 13, 2024

Looking at their TOS it may make sense to have a quick tutorial for the User to create their own Slack App to ensure we aren't the ones who end up having to deal with Rate Limiting.

4.9 Rate Limits. You will not attempt to exceed or circumvent limitations on access, calls and use of Slack API, or otherwise use the Slack API in a manner that exceeds reasonable request volume, constitutes excessive or abusive usage, or otherwise fails to comply or is inconsistent with any part of this API TOS or the Documentation. See https://api.slack.com/docs/rate-limits.

Continuing to send messages after being rate limited runs the risk of having your application permanently disabled.

from edd-slack.

brashrebel avatar brashrebel commented on June 13, 2024

@d4mation great info! For starters, WP has an is_ssl() function you can use and I think it would be great to provide the user with a notice of some kind in the admin that the feature is not available until they add SSL.

As for the rest, we have rbmtest.wpengine.com available for purposes like this. Use that all you want. You have access to the install. If you don't have an account then ping Joel. Maybe even reinstall the site if all of Joel's last experiments are no longer applicable.

from edd-slack.

d4mation avatar d4mation commented on June 13, 2024

@brashrebel I just checked rbmtest and it doesn't appear to have SSL.

We may be able to get a Let's Encrypt Cert in there though.

from edd-slack.

d4mation avatar d4mation commented on June 13, 2024

Copying what I threw in Slack here:


I don’t think we’ll be able to do the neat buttons for EDD Slack 😢 😢 😢

Not unless they end up adding support for custom Request URL Endpoints per-Team so we can just publish ours publicly.

Everything I’m finding points to it actually relying on a Bot user behind-the-scenes, and said Bot needs to run on a Server itself (Likely something a little more Real-Time, like Node, rather than Apache/NGINX)

This is why you need OATH to authenticate the App—because you’re really authenticating a Bot in this case.

Wish Slack’s Documentation were more clear on that and I didn’t have to find it within a 3rd party article detailing how to do it 😒

If one day support is added so that multiple people could use their own custom instances of our App, then we could just host the Bot ourselves. I think making a Customer host their own Node.js Server on top of the one running their WP site is a little over the top.

https://medium.com/slack-developer-blog/message-buttons-and-the-slack-api-ab938174af70#b3fc

https://github.com/howdyai/botkit/blob/master/examples/slackbutton_bot_interactivemsg.js

[8:53]
If I’m missing something that would be truly awesome, because I WANT to add this. I’m just afraid that having to distribute two software packages and telling the Customer they need to Host a whole second server for it would be daunting for most.

[8:57]
There is the potential that this could work. Then we could still run everything on the one server:
https://github.com/jclg/php-slack-bot

[8:58]
Although maybe not, since it seems to run via Web Sockets and most Shared/Managed Hosts probably wouldn’t play nicely with that 😕

from edd-slack.

d4mation avatar d4mation commented on June 13, 2024

In regards to the Approve/Deny Vendor Product Edit buttons, currently we only have a trigger for if a Vendor Product is Added. It doesn't listen for Edits. I guess we should add one for those?

from edd-slack.

brashrebel avatar brashrebel commented on June 13, 2024

Yeah, I guess we should. You can go to Downloads - > Settings - > FES - > Emails to see basically all the things in FES we should be triggering from and enable buttons for.

from edd-slack.

d4mation avatar d4mation commented on June 13, 2024

I'm trying to find a way around this, but it looks like the "Extra Data" not associated with the Slack Web API call (WP User ID, etc.) isn't accessible within the scope of the Interaction Button.

This is kind of confusing, so I'm going to make a little flow chart of sorts:

Trigger -> Notification Sent using Extra Data to create Merge Tags -> Button Clicked within Slack Client -> Hits WP Server at a REST Endpoint (Extra Data now missing from the Request made by the Slack Client) -> WP Server sends Response to Slack Client

The Extra Data is pretty necessary in this case since it tells the Endpoint we're hitting what User/Download/etc. we're modifying as a result of the Button Click.

I might be able to do some tomfoolery like passing values like approve_<user_id> and then breaking on the underscore in order to get the Command and the User ID, but I'd rather not do something so... dirty.

I'm going to contact Slack about it and see if I'm missing something or otherwise doing something wrong. Looking at the documentation/tester I can pass Extra Arguments, but they are missing from the Response itself.

from edd-slack.

d4mation avatar d4mation commented on June 13, 2024

Vendor Registration and Submissions are settled.

I need to make a Trigger for Vendor Product Edits so I can make Buttons for it and add in Buttons for Comments (Which should be super easy since it is just changing the Status in the case of Comments).

from edd-slack.

d4mation avatar d4mation commented on June 13, 2024

Although, I just noticed one of the things listed for Comments was "Replying". From what I can tell in the Slack Documentation you can't send typed-out text using these Buttons. That's more something a Slash Commands could do, which would be messy.

from edd-slack.

brashrebel avatar brashrebel commented on June 13, 2024

Then don't bother with replies for now. Just the most basic, obvious buttons.

from edd-slack.

d4mation avatar d4mation commented on June 13, 2024

Approve/Spam Comment Buttons have been added 👍

If the new Comment has been Auto-Approved then the Approve button doesn't show up.

Trigger and Buttons for Editing a Vendor Product to come tomorrow.

from edd-slack.

d4mation avatar d4mation commented on June 13, 2024

Merged into master! Going to tag and SFTP the newest changes to RBP shortly.

from edd-slack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.