This will listen to Discord WS Gateway events and notify on new message events from a Discord Forum channel. This does not support the general text channel type.
A config.json and token.json file with the following elements should be added to the working directory(mount as a secret config in /usr/src/app/ within Choreo).
{
"GW_TOKEN":"<DIscord BOT token>",
"CHANNEL_ID":"<Discord chanel ID>",
"ALERT1_MINS": 360,
"ALERT2_MINS": 960,
"ALERT3_MINS": 1200,
"ALERT_INTERVAL_MINS": 15,
"ALERT_CHAT_WEBHOOK" : "<Alert chat webhook URL",
"ESCALATION_CHAT_WEBHOOK" : "<Escalation chat webhook url>",
"MAIL_RECEIVER":"<Escalation mail recever's mail address>"
}
- ALERT1_MINS - Number of minutes the app should wait to send the first notification.
- ALERT2_MINS - Number of minutes the app should wait to send the second notification.
- ALERT3_MINS - Number of minutes the app should wait to send the third notification.
- ALERT_INTERVAL_MINS - In order to send alerts, app is checking the pending messages periodically. Define this time in minutes. Make sure it is less than the ALERT1_MINS. Each alert may be delayed by the number of minutes specify here (Worse case).
- DEBUG - This is an optional config with default value false. Set to true to enable debug.
- Get the desired Discord Forum's channel id and specify the CHANNEL_ID config.
- Create a Discord chat bot and add to the server you wish to receive messages. Make sure to provide Message Create, Manage Threads and Read Message History bot permissions.
- Generate a bot token and specify as the GW_TOKEN config.
- ALERT_CHAT_WEBHOOK - The webhook url of the chat group that intended to receive first level alerts.
- MAIL_RECEIVER - Email address of the receiver of second level alerts.
- ESCALATION_CHAT_WEBHOOK - The webhook url of the chat group that intended to receive third level escalations.
- MAIL_SUBJECT - This is an optional config to specify the Subject of the alert mail. Default value is "Discord message response SLA violation!"
{
"type": "authorized_user",
"client_id": "<Client id>",
"client_secret": "<Client secret>",
"refresh_token": "<Refresh token>"
}
We need to configure a mail account to send emails. This accont will be the sender.
- Login to google as the designated user.
- Visit Google API Console, click Create Project, and follow the wizard to create a new project.
- Go to Credentials -> OAuth Consent Screen, enter a product name to be shown to users, and click Save.
- On the Credentials tab, click Create Credentials and select OAuth Client ID.
- Select an application type, enter a name for the application, and specify a redirect URI - https://developers.google.com/oauthplayground
- Click Create. Your Client ID and Client Secret will appear.
- In a separate browser window or tab, visit OAuth 2.0 Playground(https://developers.google.com/oauthplayground). Click on the OAuth 2.0 Configuration icon in the top right corner and click on Use your own OAuth credentials and provide your OAuth Client ID and OAuth Client Secret.
- Select the required Gmail API scopes from the list of API's, and then click Authorize APIs.
- When you receive your authorization code, click Exchange authorization code for tokens to obtain the refresh token and access token.
- Now you should have all the required tokens for the token.json file.
- Also enable the Gmail API in your cloud console - https://console.cloud.google.com/apis/api/gmail.googleapis.com