Skip to content

Commit

Permalink
feat(intro-message): welcome message in #intros slack channel (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
boltdynamics authored May 10, 2024
1 parent 11cef68 commit 022985b
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ tasks:
terraform plan \
-var "xplorers_general_slack_channel_id=${XPLORERS_GENERAL_SLACK_CHANNEL_ID}" \
-var "xplorers_openai_slack_channel_id=${XPLORERS_OPENAI_SLACK_CHANNEL_ID}" \
-var "xplorers_intros_slack_channel_id=${XPLORERS_INTROS_SLACK_CHANNEL_ID}" \
-var "xplorers_artifacts_bucket_name=${XPLORERS_ARTIFACTS_BUCKET_NAME}" \
-var "azure_openai_deployment_id=${AZURE_OPENAI_DEPLOYMENT_ID}"
Expand All @@ -110,6 +111,7 @@ tasks:
terraform apply -auto-approve \
-var "xplorers_general_slack_channel_id=${XPLORERS_GENERAL_SLACK_CHANNEL_ID}" \
-var "xplorers_openai_slack_channel_id=${XPLORERS_OPENAI_SLACK_CHANNEL_ID}" \
-var "xplorers_intros_slack_channel_id=${XPLORERS_INTROS_SLACK_CHANNEL_ID}" \
-var "xplorers_artifacts_bucket_name=${XPLORERS_ARTIFACTS_BUCKET_NAME}" \
-var "azure_openai_deployment_id=${AZURE_OPENAI_DEPLOYMENT_ID}"
Expand All @@ -121,6 +123,7 @@ tasks:
terraform destroy -auto-approve \
-var "xplorers_general_slack_channel_id=${XPLORERS_GENERAL_SLACK_CHANNEL_ID}" \
-var "xplorers_openai_slack_channel_id=${XPLORERS_OPENAI_SLACK_CHANNEL_ID}" \
-var "xplorers_intros_slack_channel_id=${XPLORERS_INTROS_SLACK_CHANNEL_ID}" \
-var "xplorers_artifacts_bucket_name=${XPLORERS_ARTIFACTS_BUCKET_NAME}" \
-var "azure_openai_deployment_id=${AZURE_OPENAI_DEPLOYMENT_ID}"
Expand Down
1 change: 1 addition & 0 deletions configuration/defaults.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ XPLORERS_ARTIFACTS_BUCKET_NAME=xplorers-artifact-bucket
XPLORERS_ARTIFACTS_BUCKET_TERRAFORM_PREFIX=xplorers/bot/terraform/state
XPLORERS_OPENAI_SLACK_CHANNEL_ID=C05G6U88QMC
XPLORERS_GENERAL_SLACK_CHANNEL_ID=CG46GH7CP
XPLORERS_INTROS_SLACK_CHANNEL_ID=C06SWFJEVTQ
TF_WORKSPACE=prod
AZURE_OPENAI_DEPLOYMENT_ID=gpt-4-32k
1 change: 1 addition & 0 deletions src/helpers/constants.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export const SUCCESS_MESSAGE: string = 'Successfully processed slack event';
export const EVENTS_TO_IGNORE: string[] = ['team_join'];
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SUCCESS_MESSAGE } from "./helpers/constants";
import { EVENTS_TO_IGNORE, SUCCESS_MESSAGE } from "./helpers/constants";
import { SlackWebClient } from "./helpers/types";
import { handleSlackMessageEvent } from "./slack/slackEventHandler";
import { postMessageToSlackChannel } from "./slack/slackInteraction";
Expand Down Expand Up @@ -67,6 +67,11 @@ exports.xplorersbot = async function (event: Record<string, any>) {
const message = slackEvent?.text ?? slackEvent?.message?.text;
const ts = slackEvent?.message?.ts ?? slackEvent?.ts;

if (!message && EVENTS_TO_IGNORE.includes(slackEvent?.type)) {
console.log(`Nothing to do for slack event type ${slackEvent?.type}`)
return;
}

const messageStartsWithHeyOpenAI = message
.toLowerCase()
.startsWith("hey openai");
Expand Down
2 changes: 1 addition & 1 deletion src/slack/slackEventStrategies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class ChannelJoinStrategy implements SlackEventStrategy {
slackEvent: SlackChannelJoinEvent
) {
const userId = slackEvent.user;
const slackChannel = slackEvent.channel;
const slackChannel = process.env.XPLORERS_INTROS_SLACK_CHANNEL_ID!;
await handleSlackJoinEvent(slackWebClient, slackChannel, userId);
}
}
Expand Down
1 change: 1 addition & 0 deletions terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ resource "aws_lambda_function" "xplorers-bot" {
environment {
variables = {
XPLORERS_OPENAI_SLACK_CHANNEL_ID = var.xplorers_openai_slack_channel_id
XPLORERS_INTROS_SLACK_CHANNEL_ID = var.xplorers_intros_slack_channel_id
TF_WORKSPACE = terraform.workspace
NODE_PATH = var.lambda_node_path
AZURE_OPENAI_DEPLOYMENT_ID = var.azure_openai_deployment_id
Expand Down
5 changes: 5 additions & 0 deletions terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ variable "xplorers_general_slack_channel_id" {
description = "Slack channel id for the xplorers general slack channel"
}

variable "xplorers_intros_slack_channel_id" {
type = string
description = "Slack channel id for the xplorers intros slack channel"
}

variable "azure_openai_deployment_id" {
type = string
description = "Deployment id for the azure openai deployment"
Expand Down

0 comments on commit 022985b

Please sign in to comment.