discord connector (#3023)

* discord: frontend and backend poll connector

* added requirements for discord installation

* fixed the mypy errors

* process messages not part of any thread

* minor change

* updated the connector; this logic works & am able to docs when i print

* minor change

* ability to enter a start date to pull docs from and refactor

* added the load connector and fixed mypy errors

* local commit test

done!

* minor refactor and properly commented everything

* updated the logic to handle permissions and index active/archived threads

* basic discord test template

* cleanup

* going away with the danswer discord client class ; using an async context manager

* moved to proper folder

* minor fixes

* needs improvement

* fixed discord icon

---------

Co-authored-by: hagen-danswer <hagen@danswer.ai>
This commit is contained in:
Ishankoradia
2025-01-07 04:24:22 +05:30
committed by GitHub
parent 82eab9d704
commit ceb34a41d9
12 changed files with 434 additions and 0 deletions

BIN
web/public/discord.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

View File

@@ -68,6 +68,7 @@ import zendeskIcon from "../../../public/Zendesk.svg";
import dropboxIcon from "../../../public/Dropbox.png";
import egnyteIcon from "../../../public/Egnyte.png";
import slackIcon from "../../../public/Slack.png";
import discordIcon from "../../../public/Discord.png";
import airtableIcon from "../../../public/Airtable.svg";
import s3Icon from "../../../public/S3.png";
@@ -258,6 +259,20 @@ export const ColorSlackIcon = ({
);
};
export const ColorDiscordIcon = ({
size = 16,
className = defaultTailwindCSS,
}: IconProps) => {
return (
<div
style={{ width: `${size}px`, height: `${size}px` }}
className={`w-[${size}px] h-[${size}px] ` + className}
>
<Image src={discordIcon} alt="Logo" width="96" height="96" />
</div>
);
};
export const LiteLLMIcon = ({
size = 16,
className = defaultTailwindCSS,

View File

@@ -1031,6 +1031,36 @@ For example, specifying .*-support.* as a "channel" will cause the connector to
],
advanced_values: [],
},
discord: {
description: "Configure Discord connector",
values: [],
advanced_values: [
{
type: "list",
query: "Enter Server IDs to include:",
label: "Server IDs",
name: "server_ids",
description: `Specify 0 or more server ids to include. Only channels inside them will be used for indexing`,
optional: true,
},
{
type: "list",
query: "Enter channel names to include:",
label: "Channels",
name: "channel_names",
description: `Specify 0 or more channels to index. For example, specifying the channel "support" will cause us to only index all content within the "#support" channel. If no channels are specified, all channels the bot has access to will be indexed.`,
optional: true,
},
{
type: "text",
query: "Enter the Start Date:",
label: "Start Date",
name: "start_date",
description: `Only messages after this date will be indexed. Format: YYYY-MM-DD`,
optional: true,
},
],
},
freshdesk: {
description: "Configure Freshdesk connector",
values: [],

View File

@@ -195,6 +195,10 @@ export interface AxeroCredentialJson {
axero_api_token: string;
}
export interface DiscordCredentialJson {
discord_bot_token: string;
}
export interface FreshdeskCredentialJson {
freshdesk_domain: string;
freshdesk_password: string;
@@ -335,6 +339,7 @@ export const credentialTemplates: Record<ValidSources, any> = {
web: null,
not_applicable: null,
ingestion_api: null,
discord: { discord_bot_token: "" } as DiscordCredentialJson,
// NOTE: These are Special Cases
google_drive: { google_tokens: "" } as GoogleDriveCredentialJson,
@@ -368,6 +373,9 @@ export const credentialDisplayNames: Record<string, string> = {
// Slack
slack_bot_token: "Slack Bot Token",
// Discord
discord_bot_token: "Discord Bot Token",
// Gmail and Google Drive
google_tokens: "Google Oauth Tokens",
google_service_account_key: "Google Service Account Key",

View File

@@ -36,6 +36,7 @@ import {
GoogleStorageIcon,
ColorSlackIcon,
XenforoIcon,
ColorDiscordIcon,
FreshdeskIcon,
FirefliesIcon,
EgnyteIcon,
@@ -80,6 +81,12 @@ export const SOURCE_METADATA_MAP: SourceMap = {
docs: "https://docs.onyx.app/connectors/slack",
oauthSupported: true,
},
discord: {
icon: ColorDiscordIcon,
displayName: "Discord",
category: SourceCategory.Messaging,
docs: "https://docs.onyx.app/connectors/discord",
},
gmail: {
icon: GmailIcon,
displayName: "Gmail",

View File

@@ -314,6 +314,7 @@ export enum ValidSources {
GoogleSites = "google_sites",
Loopio = "loopio",
Dropbox = "dropbox",
Discord = "discord",
Salesforce = "salesforce",
Sharepoint = "sharepoint",
Teams = "teams",