Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/actions/main-action/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ inputs:
environment-code:
description: 'The short upper case code used to identify the environment internally, e.g. STG, PROD, DEV'
required: true
environment:
description: The environment to deploy to, e.g. staging, production, development (Yes, this is a duplicate of the above, but it's needed for the workflow to run... for now)
required: true
send-slack-message:
description: 'Specifies if should send a Slack message at the end of successful run. Defaults to true'
required: false
Expand Down Expand Up @@ -107,7 +110,7 @@ runs:
run: |
cat <<EOT >> .env
HELPLINE_CODE=${{ inputs.helpline-code }}
ENVIRONMENT_CODE=${{ inputs.environment-code }}
ENVIRONMENT=${{ inputs.environment }}
TWILIO_WORKSPACE_SID=${{ inputs.workspace-sid }}
TWILIO_CHAT_TRANSFER_WORKFLOW_SID=${{ inputs.transfer-workflow-sid }}
SYNC_SERVICE_API_KEY=${{ inputs.sync-service-api-key }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/custom_helpline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ jobs:
s3-bucket: $S3_BUCKET
helpline-code: ${{inputs.helpline_code}}
environment-code: ${{inputs.environment_code}}
environment: ${{inputs.environment}}
# Set 'false' if the target environment is production OR the force_enable_operating_hours override option is checked - otherwise 'true'
disable-operating-hours: ${{ (inputs.force_enable_operating_hours || inputs.environment_code == 'PROD') && 'false' || 'true' }}
send-slack-message: ${{ inputs.send-slack-message }}
18 changes: 11 additions & 7 deletions functions/captureChannelWithBot.protected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ import {
error500,
success,
} from '@tech-matters/serverless-helpers';
import { LexClient, BotType } from './helpers/lexClient.private';
import { LexClient } from './helpers/lexClient.private';

type EnvVars = {
HELPLINE_CODE: string;
ENVIRONMENT_CODE: string;
ENVIRONMENT: string;
CHAT_SERVICE_SID: string;
ASELO_APP_ACCESS_KEY: string;
ASELO_APP_SECRET_KEY: string;
Expand All @@ -44,8 +44,8 @@ export type Body = {
message: string; // (in Studio Flow, trigger.message.Body) The triggering message
fromServiceUser: string; // (in Studio Flow, trigger.message.From) The service user unique name
studioFlowSid: string; // (in Studio Flow, flow.flow_sid) The Studio Flow sid. Needed to trigger an API type execution once the channel is released.
language: string;
type: BotType;
language: string; // (in Studio Flow, {{trigger.message.ChannelAttributes.pre_engagement_data.language | default: 'en-US'}} )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is {{trigger.message.ChannelAttributes.pre_engagement_data.language | default: 'en-US'}} valid Studio Flow syntax? Cool!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep 🎉

type: 'pre_survey' | 'post_survey'; // (hardcoded in Studio Flow)
};

export const handler = async (
Expand Down Expand Up @@ -80,6 +80,10 @@ export const handler = async (
resolve(error400('type'));
return;
}
if (!language) {
resolve(error400('language'));
return;
}

const channel = await context
.getTwilioClient()
Expand All @@ -104,9 +108,9 @@ export const handler = async (
}),
);

const { ENVIRONMENT_CODE, HELPLINE_CODE } = context;
const languageSuffix = (language || 'en-US').replace('-', '_');
const botName = `${ENVIRONMENT_CODE}_${HELPLINE_CODE}_${type}_${languageSuffix}`;
const { ENVIRONMENT, HELPLINE_CODE } = context;
const languageSanitized = language.replace('-', '_'); // Lex doesn't accept '-'
const botName = `${ENVIRONMENT}_${HELPLINE_CODE.toLowerCase()}_${languageSanitized}_${type}`;

const chatbotCallbackWebhook = await channel.webhooks().create({
type: 'webhook',
Expand Down
2 changes: 1 addition & 1 deletion tests/captureChannelWithBot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const mockContext = {
TWILIO_WORKSPACE_SID: 'WE23xxx0orre',
SURVEY_WORKFLOW_SID: 'AZexxx903esd',
HELPLINE_CODE: 'AS',
ENVIRONMENT_CODE: 'DEV',
ENVIRONMENT: 'development',
};

const mockEvent: Body = {
Expand Down