discord-comment-automation

Add comments to a canban / jira board from a discord message

⚽️ Clients Goal

The clients end goal is to have a discord bot which allows them to add comments to tickets on shortcut.com. This should be achievable from their discord server using slash commands. The client would like 2 features:

  • `/shortcut` can be used to reply to a discord message, the replied message will be the message sent.
  • `/shortcut <message>` this command will allow my client to pass a custom message.

⚠️ Quirks To Concider

The clients goal is to have the message supplied to also be sent to make.com, this will allow the client to add custom intergration and logic inside make.com.

Discord does not support slash commands when replying to a message so we have to use original bot commands to add this feature, for example: !shortcut

🖼️ Architecture

We will be getting data from shortcut before sending the message to make as we need to know what team and what tickets are available, one we have this information and the user has selected this through the discord command then we can send off the message. architecture

🧪 Our Solution

We can start by scoping out the commands, as explained in ⚠️ Quirks To Concider we cannot use slash commands when replying to messages so we will have to take a different approach.

  • `!shortcut` for replying to selected message
  • `/shortcut <message>` for passing custom message

These commands will have very similar logic so they can structure our code to stop repition of code.

We can use discord.ui to create a neat little ui selection of all the available tickets when the discord command is called, this will then take the users input of what ticket was selected.

We need to setup a webhook in make.com so we can POST request our payload to the endpoint, This means we can start a event driven pipeline in make.com when it recives one of our payloads!

Our payload will look something like this:

@dataclass
class Payload:
    group_id: str
    ticket_id: str
    invocation_discord_id : str
    message_discord_id: str
    message: str

💻 PoC Code

Here is how our discord commands will be defined in Python 3.10 code!

"""
Slash command which takes a custom message to send to shortcut.com
"""
@tree.command(name="shortcut")
@describe(message="message to send to shortcut")
async def shortcut(interaction, message):
    # gets users input and sends to shortcut
    
"""
Regular bot command which will take the message you replied to and send it to shortcut.com
"""
@bot.command()  
async def shortcut(ctx):
    if ctx.message.reference is None:
        await ctx.send("`You have not replied to a message!")
        return None