PipedreamHQ / pipedream

Connect APIs, remarkably fast. Free for developers.
https://pipedream.com
Other
8.79k stars 5.27k forks source link

[TRIGGER] Discord Bot message triggers #1750

Open sirloinofbeef opened 2 years ago

sirloinofbeef commented 2 years ago

Discord Message Whilst Pipedream can trigger actions on Discord, there is no simple way for Discord users to communicate with the Discord bot, triggering Pipedream workflows.

Triggers which would assist with this include:

API https://discord.com/developers/docs/reference Webhooks seem to be an option instead of gateway which may be an easier option.

yasinbordbar commented 2 years ago

Hi, please assign me to do this.

dylburger commented 2 years ago

@sirloinofbeef @yasinbordbar I looked into this more and had a couple of questions.

In the webhooks docs you linked to, I see this:

In your application in the Developer Portal, there is a field on the main page called "Interactions Endpoint URL". If you want to receive Interactions via outgoing webhook, you can set your URL in this field. In order for the URL to be valid, you must be prepared for two things ahead of time...

That means that you can only have a single webhook URL for a bot, and that webhook URL must be entered in the UI, and not programmatically. Our webhook-based event sources typically use subscription webhook API endpoints that allow us to programmatically create webhooks on behalf of users. That way users don't have to worry about any manual webhook configuration.

In these scenarios, we write the event source to poll for new events every few minutes. So you'd look for new messages sent since the last time the source ran. Would that work?

dylburger commented 2 years ago

I looked into slash commands and I did not see a way to list interaction events. That is, I don’t believe we can poll an API endpoint to list slash commands a user has executed ties to the bot.

For that one, we may have to build a service that provides users the ability to create a gateway that sends data to Pipedream. I’d have to research that approach more. That’s on our backlog to look into.

sirloinofbeef commented 2 years ago

In these scenarios, we write the event source to poll for new events every few minutes. So you'd look for new messages sent since the last time the source ran. Would that work?

This is partially available via the 'New Message in Channel' Discord Bot trigger, however each user - bot message channel has a unique ID, as opposed to the single channel ID required by the trigger. This method of polling every few minutes causes the invocations to skyrocket as well.

dylburger commented 2 years ago

Yes I hear you. For the event source to use webhooks, Discord would have to support a subscription webhook API that allows us to dynamically create webhooks to point to specific event sources on event source creation. As a Discord user, you could reach out with that feedback (Google, GitHub, and many other first-class APIs support that).

Otherwise I think we'll have to build a gateway service that allowed specific event sources to subscribe to those events. Since work is required on our part, I'm going to add the blocked label to this ticket for now (but I also shared it with the Product Manager who leads this integration).