1. Help
  2. HubSpot Integrations

HubSpot and Discord Integration

This article discusses the steps for integrating HubSpot and Discord. For this use case, we will create a ticketing bot in Discord that will integrate with HubSpot for service tickets.

HubSpot is a CRM that brings all your customer management activities under one roof. Discord, on the other hand, is a trusted and popular instant messaging platform with a diverse set of specialized communities. 

We will be covering the following in the article:

(Feel free to skip to the section of your choice, by simply clicking on it)

Workflow

For a detailed understanding, let’s consider the example of a support ticket system where the customer can create a ticket in discord. The information of the ticket needs to be reflected in HubSpot by the creation of a new ticket, establishing two-way integration between both platforms.

To understand the workflow of this integration and test application, refer to the diagram below:

HubSpot and Discord Integration.drawio

It’s a three-step process with the description of each as follows:

1. Creation of Discord Bot


We need to create a discord bot to cater to the requests of the user and transfer messages between both platforms.

2. Setup of Application Server


The application server handles the workflow of detecting the message type – open ticket, close ticket, and other messages. Afterwards, the workflow is executed accordingly for each of these.

3. Creation of Ticket in HubSpot CRM


Upon the opening of the ticket, a new ticket shall be created in HubSpot. Also, the workflow shall be capable of sending messages via the HubSpot CRM directly.

Creating a Discord Bot

Discord is a very developer-friendly platform. As a first step will be creating a Discord bot, which is essentially creating an application in Discord. Here are the steps to create an application:

  1. Navigate to the developer portal of Discord. Select Applications from the sidebar.

    Screenshot 2022-04-13 at 1.35.15 AM-2
  2. Select your application and then click on Bot from the sidebar.
     
    3-1
  3. Assign a username to your bot under the USERNAME input field.
     
    3 username-1
  4. Upon scrolling, you can find Bot Permissions. Check all the boxes of permissions you need to assign to your bot.
     
    Bot permissions-1
  5. We have selected ‘Administrator’ in this case. You would notice that a PERMISSION INTEGER is generated that helps in integration ahead by specifying the permission.
     
    permission Integer 1
  6. Next is to authorize the bot and for that, navigate to this section.

Authorizing the Discord Bot

After the creation of the bot, you need to authorize it for the utilization of its API in the integration process. To authorize your created discord bot, follow these steps:

  1. Navigate to OAuth2 in the developer portal of the selected application. Here you can find the CLIENT ID under the Client information.
     
    OAuth2-4
  2. Go to discord.com/oauth2/authorize/?client_id=<your_client_id>&permissions=<permission_integer>&scope=bot%20applications.commands
     
    link
  3. Select the server you want to add the bot into.

    bot continue 1
  4. Click on Continue.
     
    bot continue 2
  5. After that, you will be able to see this bot in your discord application.
     
    Screenshot 2022-04-13 at 1.39.21 AM

Setting up the Application Server

After the creation and authorization of the discord bot, you need to set up an application server and workflows between both platforms. And, following are the steps for it:

  1. We have python code to handle each of the messaging operations. To make the bot online, the event handler of on_ready is created.
     
    Screenshot 2022-04-13 at 1.42.37 AM
  2. Once you run this code, you will see that the bot has started running.
     
    Screenshot 2022-04-13 at 1.40.51 AM
  3. You can confirm the bot turning online from your discord application as well.
     
    Screenshot 2022-04-13 at 1.39.21 AM
  4. Next up, you need to set up the ticket tool. Navigate to the section of setting up the ticket system for this purpose.
  5. After the set-up, you need to have the on_message event handler to detect the ticket closing and other messages.
     
    on_message
  6. You will see that a default message is sent to the ticket upon its creation.
     
    Default message-1
  7. For linking the messages with HubSpot, you need to create the webhook. It is created under the createNewTicket event handler.
     
    Screenshot 2022-04-13 at 1.43.03 AM
  8. Similarly, the event handler for closeTicketHubspot is created that closes the ticket in HubSpot upon receiving this event from Discord.
     
    closeTicketHubspot
  9. Afterwards, the createNote event handler is written for sending the messages along with the author’s name to the HubSpot.
     
    Screenshot 2022-04-13 at 1.43.35 AM
  10. Lastly, the changeChannelName code is written to complete this setup.
     
    Screenshot 2022-04-13 at 1.43.45 AM

Setting up the Ticket Tool

For this application, we will be using a third-party tool, named Ticket Tool to handle the process of tickets. The steps of setting up the tool are as follows:

  1. Here you can see how the Ticket Tool appears in your discord application.
     
    ticket tool
  2. To set it up, go to the Ticket Tool. Navigate to Panel Configs.

    Panel Configs-1
  3. Click on Create Panel.
     
    Create Panel-1
  4. Enter the name of a panel under the Panel Name input field.

    Panel Name
  5. Select the permissions of the support team under the Support Team Roles input field.

    Support Team
  6. Select the channel from the Panel Channel dropdown.

    PaaneChannel 
  7. You will be able to see the created setup with the name of the channel which in this case had been kept as ‘Support’.
     
    support name
  8. Click on Create ticket to create a new ticket in the discord application.
     
    create ticket-1
  9. You will see a new ticket with a unique number assigned to it.
     
    Screenshot 2022-04-13 at 1.46.36 AM
  10. This completes the Ticket Tool setup.

Visualizing Tickets in HubSpot

After all the setup, it's time to look into how these tickets are created in HubSpot along with the workflow. For that, the steps are as follows:

  1. Go into your HubSpot account and click on Tickets.

    Tickets-1

  2. Here you can see the tickets with the starting name of Discord. These are the ones created by Discord into the HubSpot based on the workflow.

    Ticket Discord-2
  3. Once you open any of the tickets, you can see all the details relevant to them.
     
    orange
  4. You can see the messages of that ticket under the Discord messaging panel.
     
    testing ticket
  5. To reply to the ticket, you can write your message under the Discord message input field.
     
    Discord Message
  6. And, this is what the workflow in HubSpot looks like. It’s about the closing of tickets. The particular workflow, upon detection of its closing from discord, executes a custom code.
     
    Screenshot 2022-04-13 at 1.49.58 AM
  7. This is what the custom code looks like. It looks for the content to be ‘$closeTicket’ to detect the closing of it.
     
    Screenshot 2022-04-13 at 1.50.25 AM-1
  8. That's all about it! 

Conclusion

This article discussed the details of integrating HubSpot and Discord. We considered an example of a ticket system, set up using Ticket Tool to understand this two-dimensional connection between both platforms.