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
10 changes: 10 additions & 0 deletions functions/channelCapture/channelCaptureHandlers.private.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export type CapturedChannelAttributes = {
environment: string;
helplineCode: string;
botLanguage: string;
botLanguageV1: string;
botSuffix: string;
controlTaskSid: string;
releaseType: ReleaseTypes;
Expand Down Expand Up @@ -114,6 +115,7 @@ const updateChannelWithCapture = async (
environment,
helplineCode,
botLanguage,
botLanguageV1,
botSuffix,
controlTaskSid,
chatbotCallbackWebhookSid,
Expand Down Expand Up @@ -145,6 +147,7 @@ const updateChannelWithCapture = async (
environment,
helplineCode,
botLanguage,
botLanguageV1,
botSuffix,
controlTaskSid,
chatbotCallbackWebhookSid,
Expand All @@ -171,6 +174,7 @@ type CaptureChannelOptions = {
environment: string;
helplineCode: string;
botLanguage: string;
botLanguageV1: string;
botSuffix: string;
inputText: string;
userId: string;
Expand All @@ -196,6 +200,7 @@ const triggerWithUserMessage = async (
helplineCode,
botSuffix,
botLanguage,
botLanguageV1,
inputText,
controlTaskSid,
releaseType,
Expand All @@ -212,6 +217,7 @@ const triggerWithUserMessage = async (
// trigger Lex first, in order to reduce the time between the creating the webhook and sending the message
const lexResult = await lexClient.postText(context, {
botLanguage,
botLanguageV1,
botSuffix,
enableLexV2,
environment,
Expand Down Expand Up @@ -253,6 +259,7 @@ const triggerWithUserMessage = async (
environment,
helplineCode,
botLanguage,
botLanguageV1,
botSuffix,
controlTaskSid,
releaseType,
Expand Down Expand Up @@ -312,6 +319,7 @@ const triggerWithNextMessage = async (
environment,
helplineCode,
botLanguage,
botLanguageV1,
botSuffix,
inputText,
controlTaskSid,
Expand Down Expand Up @@ -369,6 +377,7 @@ const triggerWithNextMessage = async (
environment,
helplineCode,
botLanguage,
botLanguageV1,
botSuffix,
controlTaskSid,
releaseType,
Expand Down Expand Up @@ -552,6 +561,7 @@ export const handleChannelCapture = async (
helplineCode: HELPLINE_CODE.toLowerCase(),
botSuffix,
botLanguage: languageSanitized.toLowerCase(),
botLanguageV1: languageSanitized,
releaseType,
studioFlowSid,
memoryAttribute,
Expand Down
12 changes: 10 additions & 2 deletions functions/channelCapture/chatbotCallback.protected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,19 @@ export const handler = async (
const capturedChannelAttributes =
channelAttributes.capturedChannelAttributes as CapturedChannelAttributes;

const { botLanguage, botSuffix, enableLexV2, environment, helplineCode, userId } =
capturedChannelAttributes;
const {
botLanguage,
botLanguageV1,
botSuffix,
enableLexV2,
environment,
helplineCode,
userId,
} = capturedChannelAttributes;

const lexResult = await lexClient.postText(context, {
botLanguage,
botLanguageV1,
botSuffix,
enableLexV2,
environment,
Expand Down
3 changes: 2 additions & 1 deletion functions/channelCapture/chatbotCallbackCleanup.protected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export const chatbotCallbackCleanup = async ({
}
};

const { botLanguage, botSuffix, enableLexV2, environment, helplineCode, userId } =
const { botLanguage, botLanguageV1, botSuffix, enableLexV2, environment, helplineCode, userId } =
capturedChannelAttributes;

const shouldDeleteSession = botLanguage && botSuffix && environment && helplineCode && userId;
Expand All @@ -128,6 +128,7 @@ export const chatbotCallbackCleanup = async ({
shouldDeleteSession &&
lexClient.deleteSession(context, {
botLanguage,
botLanguageV1,
botSuffix,
enableLexV2,
environment,
Expand Down
14 changes: 9 additions & 5 deletions functions/channelCapture/lexClient.private.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,16 @@ const deleteSessionV1 = async (
};

const getBotNameV1 = ({
botLanguage,
botLanguageV1,
botSuffix,
environment,
helplineCode,
}: {
environment: string;
helplineCode: string;
botLanguage: string;
botLanguageV1: string;
botSuffix: string;
}) => `${environment}_${helplineCode}_${botLanguage}_${botSuffix}`;
}) => `${environment}_${helplineCode}_${botLanguageV1}_${botSuffix}`;

export const LexV1 = {
postText: postTextV1,
Expand Down Expand Up @@ -289,6 +289,7 @@ export const postText = async (
credentials: AWSCredentials,
{
botLanguage,
botLanguageV1,
botSuffix,
enableLexV2,
environment,
Expand All @@ -300,6 +301,7 @@ export const postText = async (
environment: string;
helplineCode: string;
botLanguage: string;
botLanguageV1: string;
botSuffix: string;
inputText: string;
userId: string;
Expand Down Expand Up @@ -330,7 +332,7 @@ export const postText = async (
return res;
}

const botName = LexV1.getBotName({ botLanguage, botSuffix, environment, helplineCode });
const botName = LexV1.getBotName({ botLanguageV1, botSuffix, environment, helplineCode });
const botAlias = 'latest'; // Assume we always use the latest published version

const res = await LexV1.postText(credentials, { botAlias, botName, inputText, userId });
Expand All @@ -347,6 +349,7 @@ export const deleteSession = async (
credentials: AWSCredentials,
{
botLanguage,
botLanguageV1,
botSuffix,
enableLexV2,
environment,
Expand All @@ -357,6 +360,7 @@ export const deleteSession = async (
environment: string;
helplineCode: string;
botLanguage: string;
botLanguageV1: string;
botSuffix: string;
userId: string;
},
Expand Down Expand Up @@ -384,7 +388,7 @@ export const deleteSession = async (
});
}

const botName = LexV1.getBotName({ botLanguage, botSuffix, environment, helplineCode });
const botName = LexV1.getBotName({ botLanguageV1, botSuffix, environment, helplineCode });
const botAlias = 'latest'; // Assume we always use the latest published version

return await LexV1.deleteSession(credentials, { botAlias, botName, userId });
Expand Down
10 changes: 9 additions & 1 deletion functions/taskrouterListeners/postSurveyListener.private.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ const isTriggerPostSurvey = (
* Checks the event type to determine if the listener should handle the event or not.
* If it returns true, the taskrouter will invoke this listener.
*/
export const shouldHandle = (event: EventFields) => eventTypes.includes(event.EventType);
export const shouldHandle = () => false;
// export const shouldHandle = (event: EventFields) => eventTypes.includes(event.EventType);

export const handleEvent = async (context: Context<EnvVars>, event: EventFields) => {
const {
Expand All @@ -99,6 +100,13 @@ export const handleEvent = async (context: Context<EnvVars>, event: EventFields)
const serviceConfig = await client.flexApi.configuration.get().fetch();
const { feature_flags: featureFlags, helplineLanguage } = serviceConfig.attributes;

if (featureFlags.enable_lambda_post_survey_processing) {
console.debug(
'enable_lambda_post_survey_processing is set, the post survey handler will be process in twilio lambda.',
);
return;
}

if (featureFlags.enable_post_survey) {
const { channelSid, conversationSid, channelType, customChannelType } = taskAttributes;

Expand Down
Loading