From 737dba5e45221036264a9ea64f82176755f01ebe Mon Sep 17 00:00:00 2001 From: Murilo Machado Date: Mon, 26 Jun 2023 19:05:56 +0100 Subject: [PATCH 01/24] Add Lex support to multiple languages --- .github/actions/main-action/action.yml | 15 ++++++++---- .github/workflows/custom_helpline.yml | 3 ++- README.md | 2 ++ functions/captureChannelWithBot.protected.ts | 23 +++++++++++++------ functions/helpers/lexClient.private.ts | 24 ++++++++++++++++---- 5 files changed, 50 insertions(+), 17 deletions(-) diff --git a/.github/actions/main-action/action.yml b/.github/actions/main-action/action.yml index 7e649bc1..32827c1e 100644 --- a/.github/actions/main-action/action.yml +++ b/.github/actions/main-action/action.yml @@ -67,8 +67,11 @@ inputs: s3-bucket: description: 'S3 bucket name where Aselo documents are stored' required: true - helpline-name: - description: 'The identifier in the format "-" used for this helpline' + helpline-code: + description: 'The short (usually 2 character) upper case code used to identify the helpline internally, e.g. ZA, IN, BR.' + required: true + environment-code: + description: 'The short upper case code used to identify the environment internally, e.g. STG, PROD, DEV' required: true send-slack-message: description: 'Specifies if should send a Slack message at the end of successful run. Defaults to true' @@ -78,6 +81,8 @@ inputs: description: 'Specifies if we should disable enforcement of operating hours (uuseful for non production accounts). Defaults to false' required: false default: 'false' +env: + helpline-name: ${{inputs.helpline-code}}_${{inputs.environment-code}} runs: using: 'composite' steps: @@ -100,6 +105,8 @@ runs: - name: Fill .env run: | cat <> .env + HELPLINE_CODE=${{ inputs.helpline-code }} + ENVIRONMENT_CODE=${{ inputs.environment-code }} TWILIO_WORKSPACE_SID=${{ inputs.workspace-sid }} TWILIO_CHAT_TRANSFER_WORKFLOW_SID=${{ inputs.transfer-workflow-sid }} SYNC_SERVICE_API_KEY=${{ inputs.sync-service-api-key }} @@ -131,7 +138,7 @@ runs: - name: Execute custom action (if any) uses: ./.github/actions/custom-actions with: - helpline-name: ${{ inputs.helpline-name }} + helpline-name: ${{ env.helpline-name }} account-sid: ${{ inputs.account-sid }} # Install dependencies for the twilio functions - name: Install dependencies for the twilio functions @@ -170,6 +177,6 @@ runs: if: ${{ inputs.send-slack-message != 'false' }} with: channel-id: ${{ env.ASELO_DEPLOYS_CHANNEL_ID }} - slack-message: "`[Serverless]` Deployment to `${{ inputs.helpline-name }}` from ${{ github.ref_type }} `${{ github.ref_name }}` requested by `${{ github.triggering_actor }}` completed using workflow '${{ github.workflow }}' with SHA ${{ github.sha }} :rocket:." + slack-message: "`[Serverless]` Deployment to `${{ env.helpline-name }}` from ${{ github.ref_type }} `${{ github.ref_name }}` requested by `${{ github.triggering_actor }}` completed using workflow '${{ github.workflow }}' with SHA ${{ github.sha }} :rocket:." env: SLACK_BOT_TOKEN: ${{ env.GITHUB_ACTIONS_SLACK_BOT_TOKEN }} diff --git a/.github/workflows/custom_helpline.yml b/.github/workflows/custom_helpline.yml index e15a1ae2..91991a61 100644 --- a/.github/workflows/custom_helpline.yml +++ b/.github/workflows/custom_helpline.yml @@ -191,7 +191,8 @@ jobs: aselo-app-secret-key: $ASELO_APP_SECRET_KEY aws-region: $HELPLINE_AWS_REGION s3-bucket: $S3_BUCKET - helpline-name: ${{inputs.helpline_code}}_${{inputs.environment_code}} + helpline-code: ${{inputs.helpline_code}} + environment-code: ${{inputs.environment_code}} # 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 }} diff --git a/README.md b/README.md index 41698931..bcfeb5e1 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,8 @@ For help on twilio-run commands run: | `S3_ENDPOINT` | _local transcripts only_ http://localhost:4566 | | `ASELO_APP_ACCESS_KEY` | AWS_ACCESS_KEY_ID with access to s3 bucket (can be any string for localstack) | | `ASELO_APP_SECRET_KEY` | AWS_SECRET_ACCESS_KEY for ASELO_APP_ACCESS_KEY (can be any string for localstack | +| `HELPLINE_CODE` | The short (usually 2 character) upper case code used to identify the helpline internally, e.g. ZA, IN, BR. | +| `ENVIRONMENT_CODE` | The short upper case code used to identify the environment internally, e.g. STG, PROD, DEV | ## Deployment diff --git a/functions/captureChannelWithBot.protected.ts b/functions/captureChannelWithBot.protected.ts index 00ce288b..89fd68b4 100644 --- a/functions/captureChannelWithBot.protected.ts +++ b/functions/captureChannelWithBot.protected.ts @@ -26,9 +26,11 @@ import { error500, success, } from '@tech-matters/serverless-helpers'; -import { LexClient } from './helpers/lexClient.private'; +import { LexClient, BotType } from './helpers/lexClient.private'; type EnvVars = { + HELPLINE_CODE: string; + ENVIRONMENT_CODE: string; CHAT_SERVICE_SID: string; ASELO_APP_ACCESS_KEY: string; ASELO_APP_SECRET_KEY: string; @@ -42,7 +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. - botName: string; + language: string; + type: BotType; }; export const handler = async ( @@ -55,7 +58,7 @@ export const handler = async ( const resolve = bindResolve(callback)(response); try { - const { channelSid, message, fromServiceUser, studioFlowSid, botName } = event; + const { channelSid, message, fromServiceUser, studioFlowSid, language, type } = event; if (!channelSid) { resolve(error400('channelSid')); @@ -73,8 +76,12 @@ export const handler = async ( resolve(error400('studioFlowSid')); return; } - if (!botName) { - resolve(error400('botName')); + if (!language) { + resolve(error400('language')); + return; + } + if (!type) { + resolve(error400('type')); return; } @@ -116,7 +123,8 @@ export const handler = async ( fromServiceUser, // Save this in the outer scope so it's persisted for later chatbots // All of this can be passed as url params to the webhook instead channelCapturedByBot: { - botName, + language, + type, botAlias: 'latest', // assume we always use the latest published version studioFlowSid, chatbotCallbackWebhookSid: chatbotCallbackWebhook.sid, @@ -144,7 +152,8 @@ export const handler = async ( const lexClient = require(handlerPath) as LexClient; const lexResponse = await lexClient.postText(context, { - botName: updatedChannelAttributes.channelCapturedByBot.botName, + language: updatedChannelAttributes.channelCapturedByBot.language, + type: updatedChannelAttributes.channelCapturedByBot.type, botAlias: updatedChannelAttributes.channelCapturedByBot.botAlias, inputText: message, userId: channel.sid, diff --git a/functions/helpers/lexClient.private.ts b/functions/helpers/lexClient.private.ts index 328bba73..50dfa81d 100644 --- a/functions/helpers/lexClient.private.ts +++ b/functions/helpers/lexClient.private.ts @@ -16,35 +16,49 @@ import AWS from 'aws-sdk'; type AWSCredentials = { + HELPLINE_CODE: string; + ENVIRONMENT_CODE: string; ASELO_APP_ACCESS_KEY: string; ASELO_APP_SECRET_KEY: string; AWS_REGION: string; }; +export type BotType = 'pre_survey' | 'post_survey'; + export const postText = async ( credentials: AWSCredentials, { - botName, + language, + type, botAlias, inputText, userId, }: { - botName: string; + language: string; + type: BotType; botAlias: string; inputText: string; userId: string; }, ) => { + const { + ASELO_APP_ACCESS_KEY, + ASELO_APP_SECRET_KEY, + AWS_REGION, + ENVIRONMENT_CODE, + HELPLINE_CODE, + } = credentials; AWS.config.update({ credentials: { - accessKeyId: credentials.ASELO_APP_ACCESS_KEY, - secretAccessKey: credentials.ASELO_APP_SECRET_KEY, + accessKeyId: ASELO_APP_ACCESS_KEY, + secretAccessKey: ASELO_APP_SECRET_KEY, }, - region: credentials.AWS_REGION, + region: AWS_REGION, }); const Lex = new AWS.LexRuntime(); + const botName = `${ENVIRONMENT_CODE}_${HELPLINE_CODE}_${type}_${language.replace('-', '_')}`; const lexResponse = await Lex.postText({ botName, botAlias, inputText, userId }).promise(); return lexResponse; From 789fb1d91cb45f5dcd5145f44c44faebb947b375 Mon Sep 17 00:00:00 2001 From: Murilo Machado Date: Wed, 28 Jun 2023 16:56:18 +0100 Subject: [PATCH 02/24] Fix tests 1 --- tests/captureChannelWithBot.test.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/captureChannelWithBot.test.ts b/tests/captureChannelWithBot.test.ts index 65047ac9..5968be43 100644 --- a/tests/captureChannelWithBot.test.ts +++ b/tests/captureChannelWithBot.test.ts @@ -93,6 +93,8 @@ const mockContext = { AWS_REGION: 'us-east-1', TWILIO_WORKSPACE_SID: 'WE23xxx0orre', SURVEY_WORKFLOW_SID: 'AZexxx903esd', + HELPLINE_CODE: 'AS', + ENVIRONMENT_CODE: 'DEV', }; const mockEvent: Body = { @@ -100,7 +102,8 @@ const mockEvent: Body = { message: 'Message sent', fromServiceUser: 'Test User', studioFlowSid: 'FL0123xxdew', - botName: 'C6HUSTIFBR', + language: 'en_US', + type: 'pre_survey', }; const mockCallback = jest.fn(); @@ -139,7 +142,8 @@ describe('captureChannelWithBot', () => { message: 'Message sent', fromServiceUser: 'Test User', studioFlowSid: 'FL0123xxdew', - botName: 'C6HUSTIFBR', + language: 'en_US', + type: 'pre_survey', }; await captureChannelWithBot(mockContext, event, mockCallback); From a4a483264204ee9085baaaf9c0c78ad8394ede1e Mon Sep 17 00:00:00 2001 From: Murilo Machado Date: Mon, 3 Jul 2023 13:41:05 +0100 Subject: [PATCH 03/24] Fix tests --- functions/webhooks/chatbotCallback.protected.ts | 5 ++++- tests/webhooks/chatbotCallback.test.ts | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/functions/webhooks/chatbotCallback.protected.ts b/functions/webhooks/chatbotCallback.protected.ts index d707903a..ce710faa 100644 --- a/functions/webhooks/chatbotCallback.protected.ts +++ b/functions/webhooks/chatbotCallback.protected.ts @@ -30,6 +30,8 @@ import type { WebhookEvent } from '../helpers/customChannels/flexToCustomChannel import { LexClient } from '../helpers/lexClient.private'; type EnvVars = { + HELPLINE_CODE: string; + ENVIRONMENT_CODE: string; CHAT_SERVICE_SID: string; ASELO_APP_ACCESS_KEY: string; ASELO_APP_SECRET_KEY: string; @@ -82,7 +84,8 @@ export const handler = async ( const lexClient = require(handlerPath) as LexClient; const lexResponse = await lexClient.postText(context, { - botName: channelAttributes.channelCapturedByBot.botName, + language: channelAttributes.channelCapturedByBot.language, + type: channelAttributes.channelCapturedByBot.type, botAlias: channelAttributes.channelCapturedByBot.botAlias, inputText: Body, userId: channel.sid, diff --git a/tests/webhooks/chatbotCallback.test.ts b/tests/webhooks/chatbotCallback.test.ts index 2c4fea47..0459c0b6 100644 --- a/tests/webhooks/chatbotCallback.test.ts +++ b/tests/webhooks/chatbotCallback.test.ts @@ -106,6 +106,8 @@ const context = { ASELO_APP_SECRET_KEY: 'KA23xxx09i', AWS_REGION: 'us-east-1', TWILIO_WORKSPACE_SID: 'Waer3xxx98', + HELPLINE_CODE: 'AS', + ENVIRONMENT_CODE: 'DEV', }; const mockCallback = jest.fn(); From 25e0daf2f86404f7369a2da77b9c91392292bdc6 Mon Sep 17 00:00:00 2001 From: Murilo Machado Date: Mon, 3 Jul 2023 13:53:16 +0100 Subject: [PATCH 04/24] add space --- .github/actions/main-action/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/main-action/action.yml b/.github/actions/main-action/action.yml index 32827c1e..bad68136 100644 --- a/.github/actions/main-action/action.yml +++ b/.github/actions/main-action/action.yml @@ -82,7 +82,7 @@ inputs: required: false default: 'false' env: - helpline-name: ${{inputs.helpline-code}}_${{inputs.environment-code}} + helpline-name: ${{ inputs.helpline-code }}_${{ inputs.environment-code }} runs: using: 'composite' steps: From 25e66c4b932e723909dbddb0b28032a958bcce33 Mon Sep 17 00:00:00 2001 From: Murilo Machado Date: Mon, 3 Jul 2023 14:22:08 +0100 Subject: [PATCH 05/24] test 01 --- .github/actions/main-action/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/main-action/action.yml b/.github/actions/main-action/action.yml index bad68136..77413b34 100644 --- a/.github/actions/main-action/action.yml +++ b/.github/actions/main-action/action.yml @@ -82,7 +82,7 @@ inputs: required: false default: 'false' env: - helpline-name: ${{ inputs.helpline-code }}_${{ inputs.environment-code }} + helpline-name: ${{ github.event.inputs.helpline-code }}_${{ github.event.inputs.environment-code }} runs: using: 'composite' steps: From d5b865ded40f9cac25cd512db32969f01c762022 Mon Sep 17 00:00:00 2001 From: Murilo Machado Date: Mon, 3 Jul 2023 14:41:53 +0100 Subject: [PATCH 06/24] test 02 --- .github/actions/main-action/action.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/actions/main-action/action.yml b/.github/actions/main-action/action.yml index 77413b34..01970198 100644 --- a/.github/actions/main-action/action.yml +++ b/.github/actions/main-action/action.yml @@ -81,11 +81,13 @@ inputs: description: 'Specifies if we should disable enforcement of operating hours (uuseful for non production accounts). Defaults to false' required: false default: 'false' -env: - helpline-name: ${{ github.event.inputs.helpline-code }}_${{ github.event.inputs.environment-code }} runs: using: 'composite' steps: + - name: Set helpline-name + run: echo "helpline-name=${{ inputs.helpline-code }}_${{ inputs.environment-code }}" >> $GITHUB_ENV + - name: Test helpline-name + run: echo ${{ env.helpline-name }} # Set any env vars needed from Parameter Store here # Slack env - name: Set GITHUB_ACTIONS_SLACK_BOT_TOKEN From b40fdbf5e5f3423617328a09726ddb47a310aa21 Mon Sep 17 00:00:00 2001 From: Murilo Machado Date: Mon, 3 Jul 2023 14:43:19 +0100 Subject: [PATCH 07/24] test 03 --- .github/actions/main-action/action.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/actions/main-action/action.yml b/.github/actions/main-action/action.yml index 01970198..98d2c728 100644 --- a/.github/actions/main-action/action.yml +++ b/.github/actions/main-action/action.yml @@ -86,8 +86,10 @@ runs: steps: - name: Set helpline-name run: echo "helpline-name=${{ inputs.helpline-code }}_${{ inputs.environment-code }}" >> $GITHUB_ENV + shell: bash - name: Test helpline-name run: echo ${{ env.helpline-name }} + shell: bash # Set any env vars needed from Parameter Store here # Slack env - name: Set GITHUB_ACTIONS_SLACK_BOT_TOKEN From 809fc92f6b8b20ad99706804033a0bf716c95d15 Mon Sep 17 00:00:00 2001 From: Murilo Machado Date: Mon, 3 Jul 2023 16:40:48 +0100 Subject: [PATCH 08/24] Save botName on channel attributes --- functions/captureChannelWithBot.protected.ts | 9 +++++---- functions/helpers/lexClient.private.ts | 17 +++-------------- functions/webhooks/chatbotCallback.protected.ts | 5 +---- tests/webhooks/chatbotCallback.test.ts | 2 -- 4 files changed, 9 insertions(+), 24 deletions(-) diff --git a/functions/captureChannelWithBot.protected.ts b/functions/captureChannelWithBot.protected.ts index 89fd68b4..d9c08ea8 100644 --- a/functions/captureChannelWithBot.protected.ts +++ b/functions/captureChannelWithBot.protected.ts @@ -108,6 +108,9 @@ export const handler = async ( }), ); + const { ENVIRONMENT_CODE, HELPLINE_CODE } = context; + const botName = `${ENVIRONMENT_CODE}_${HELPLINE_CODE}_${type}_${language.replace('-', '_')}`; + const chatbotCallbackWebhook = await channel.webhooks().create({ type: 'webhook', configuration: { @@ -123,8 +126,7 @@ export const handler = async ( fromServiceUser, // Save this in the outer scope so it's persisted for later chatbots // All of this can be passed as url params to the webhook instead channelCapturedByBot: { - language, - type, + botName, botAlias: 'latest', // assume we always use the latest published version studioFlowSid, chatbotCallbackWebhookSid: chatbotCallbackWebhook.sid, @@ -152,8 +154,7 @@ export const handler = async ( const lexClient = require(handlerPath) as LexClient; const lexResponse = await lexClient.postText(context, { - language: updatedChannelAttributes.channelCapturedByBot.language, - type: updatedChannelAttributes.channelCapturedByBot.type, + botName: updatedChannelAttributes.botName, botAlias: updatedChannelAttributes.channelCapturedByBot.botAlias, inputText: message, userId: channel.sid, diff --git a/functions/helpers/lexClient.private.ts b/functions/helpers/lexClient.private.ts index 50dfa81d..c2269987 100644 --- a/functions/helpers/lexClient.private.ts +++ b/functions/helpers/lexClient.private.ts @@ -16,8 +16,6 @@ import AWS from 'aws-sdk'; type AWSCredentials = { - HELPLINE_CODE: string; - ENVIRONMENT_CODE: string; ASELO_APP_ACCESS_KEY: string; ASELO_APP_SECRET_KEY: string; AWS_REGION: string; @@ -28,26 +26,18 @@ export type BotType = 'pre_survey' | 'post_survey'; export const postText = async ( credentials: AWSCredentials, { - language, - type, + botName, botAlias, inputText, userId, }: { - language: string; - type: BotType; + botName: string; botAlias: string; inputText: string; userId: string; }, ) => { - const { - ASELO_APP_ACCESS_KEY, - ASELO_APP_SECRET_KEY, - AWS_REGION, - ENVIRONMENT_CODE, - HELPLINE_CODE, - } = credentials; + const { ASELO_APP_ACCESS_KEY, ASELO_APP_SECRET_KEY, AWS_REGION } = credentials; AWS.config.update({ credentials: { accessKeyId: ASELO_APP_ACCESS_KEY, @@ -58,7 +48,6 @@ export const postText = async ( const Lex = new AWS.LexRuntime(); - const botName = `${ENVIRONMENT_CODE}_${HELPLINE_CODE}_${type}_${language.replace('-', '_')}`; const lexResponse = await Lex.postText({ botName, botAlias, inputText, userId }).promise(); return lexResponse; diff --git a/functions/webhooks/chatbotCallback.protected.ts b/functions/webhooks/chatbotCallback.protected.ts index ce710faa..d707903a 100644 --- a/functions/webhooks/chatbotCallback.protected.ts +++ b/functions/webhooks/chatbotCallback.protected.ts @@ -30,8 +30,6 @@ import type { WebhookEvent } from '../helpers/customChannels/flexToCustomChannel import { LexClient } from '../helpers/lexClient.private'; type EnvVars = { - HELPLINE_CODE: string; - ENVIRONMENT_CODE: string; CHAT_SERVICE_SID: string; ASELO_APP_ACCESS_KEY: string; ASELO_APP_SECRET_KEY: string; @@ -84,8 +82,7 @@ export const handler = async ( const lexClient = require(handlerPath) as LexClient; const lexResponse = await lexClient.postText(context, { - language: channelAttributes.channelCapturedByBot.language, - type: channelAttributes.channelCapturedByBot.type, + botName: channelAttributes.channelCapturedByBot.botName, botAlias: channelAttributes.channelCapturedByBot.botAlias, inputText: Body, userId: channel.sid, diff --git a/tests/webhooks/chatbotCallback.test.ts b/tests/webhooks/chatbotCallback.test.ts index 0459c0b6..2c4fea47 100644 --- a/tests/webhooks/chatbotCallback.test.ts +++ b/tests/webhooks/chatbotCallback.test.ts @@ -106,8 +106,6 @@ const context = { ASELO_APP_SECRET_KEY: 'KA23xxx09i', AWS_REGION: 'us-east-1', TWILIO_WORKSPACE_SID: 'Waer3xxx98', - HELPLINE_CODE: 'AS', - ENVIRONMENT_CODE: 'DEV', }; const mockCallback = jest.fn(); From 4a62d09e329de4a43dd6eb59b8ef0f190439a584 Mon Sep 17 00:00:00 2001 From: Murilo Machado Date: Mon, 3 Jul 2023 16:50:41 +0100 Subject: [PATCH 09/24] Fix --- functions/captureChannelWithBot.protected.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/captureChannelWithBot.protected.ts b/functions/captureChannelWithBot.protected.ts index d9c08ea8..e6a42d41 100644 --- a/functions/captureChannelWithBot.protected.ts +++ b/functions/captureChannelWithBot.protected.ts @@ -154,7 +154,7 @@ export const handler = async ( const lexClient = require(handlerPath) as LexClient; const lexResponse = await lexClient.postText(context, { - botName: updatedChannelAttributes.botName, + botName: updatedChannelAttributes.channelCapturedByBot.botName, botAlias: updatedChannelAttributes.channelCapturedByBot.botAlias, inputText: message, userId: channel.sid, From 7ec20f95f224f51f249caa69efcdd12605091677 Mon Sep 17 00:00:00 2001 From: Murilo Machado Date: Mon, 3 Jul 2023 18:05:24 +0100 Subject: [PATCH 10/24] save controlTaskSid --- functions/captureChannelWithBot.protected.ts | 28 +++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/functions/captureChannelWithBot.protected.ts b/functions/captureChannelWithBot.protected.ts index e6a42d41..20aacb16 100644 --- a/functions/captureChannelWithBot.protected.ts +++ b/functions/captureChannelWithBot.protected.ts @@ -120,9 +120,24 @@ export const handler = async ( }, }); + // Cleanup task for captured channel by the bot + const controlTask = await context + .getTwilioClient() + .taskrouter.workspaces(context.TWILIO_WORKSPACE_SID) + .tasks.create({ + workflowSid: context.SURVEY_WORKFLOW_SID, + attributes: JSON.stringify({ + isChatCaptureControl: true, + channelSid, + }), + taskChannel: 'survey', + timeout: 45600, // 720 minutes or 12 hours + }); + const updated = await channel.update({ attributes: JSON.stringify({ ...channelAttributes, + controlTaskSid: controlTask.sid, fromServiceUser, // Save this in the outer scope so it's persisted for later chatbots // All of this can be passed as url params to the webhook instead channelCapturedByBot: { @@ -136,19 +151,6 @@ export const handler = async ( const updatedChannelAttributes = JSON.parse(updated.attributes); - // Cleanup task for captured channel by the bot - await context - .getTwilioClient() - .taskrouter.workspaces(context.TWILIO_WORKSPACE_SID) - .tasks.create({ - workflowSid: context.SURVEY_WORKFLOW_SID, - attributes: JSON.stringify({ - isChatCaptureControl: true, - channelSid, - }), - taskChannel: 'survey', - timeout: 45600, // 720 minutes or 12 hours - }); const handlerPath = Runtime.getFunctions()['helpers/lexClient'].path; const lexClient = require(handlerPath) as LexClient; From fd3fc74f285096ce05deeede84a0f8e016813ed9 Mon Sep 17 00:00:00 2001 From: Murilo Machado Date: Mon, 3 Jul 2023 18:24:24 +0100 Subject: [PATCH 11/24] fix lint --- functions/captureChannelWithBot.protected.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/functions/captureChannelWithBot.protected.ts b/functions/captureChannelWithBot.protected.ts index 20aacb16..4e97d0e6 100644 --- a/functions/captureChannelWithBot.protected.ts +++ b/functions/captureChannelWithBot.protected.ts @@ -151,7 +151,6 @@ export const handler = async ( const updatedChannelAttributes = JSON.parse(updated.attributes); - const handlerPath = Runtime.getFunctions()['helpers/lexClient'].path; const lexClient = require(handlerPath) as LexClient; From 56afffe9fade11ffeb241315fbc371bf1988252f Mon Sep 17 00:00:00 2001 From: Murilo Machado Date: Mon, 3 Jul 2023 18:36:57 +0100 Subject: [PATCH 12/24] move control task to canceled --- functions/webhooks/chatbotCallback.protected.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/webhooks/chatbotCallback.protected.ts b/functions/webhooks/chatbotCallback.protected.ts index d707903a..8591c15b 100644 --- a/functions/webhooks/chatbotCallback.protected.ts +++ b/functions/webhooks/chatbotCallback.protected.ts @@ -127,7 +127,7 @@ export const handler = async ( client.taskrouter.v1 .workspaces(context.TWILIO_WORKSPACE_SID) .tasks(channelAttributes.controlTaskSid) - .update({ assignmentStatus: 'completed' }), + .update({ assignmentStatus: 'canceled' }), // Remove this webhook from the channel channel .webhooks() From d9b8c94fce28c1f0bf5c41191eb9f9b61933e733 Mon Sep 17 00:00:00 2001 From: Murilo Machado Date: Mon, 3 Jul 2023 19:21:32 +0100 Subject: [PATCH 13/24] Undo latest changes --- functions/captureChannelWithBot.protected.ts | 29 +++++++++---------- .../webhooks/chatbotCallback.protected.ts | 4 +-- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/functions/captureChannelWithBot.protected.ts b/functions/captureChannelWithBot.protected.ts index 4e97d0e6..e6a42d41 100644 --- a/functions/captureChannelWithBot.protected.ts +++ b/functions/captureChannelWithBot.protected.ts @@ -120,24 +120,9 @@ export const handler = async ( }, }); - // Cleanup task for captured channel by the bot - const controlTask = await context - .getTwilioClient() - .taskrouter.workspaces(context.TWILIO_WORKSPACE_SID) - .tasks.create({ - workflowSid: context.SURVEY_WORKFLOW_SID, - attributes: JSON.stringify({ - isChatCaptureControl: true, - channelSid, - }), - taskChannel: 'survey', - timeout: 45600, // 720 minutes or 12 hours - }); - const updated = await channel.update({ attributes: JSON.stringify({ ...channelAttributes, - controlTaskSid: controlTask.sid, fromServiceUser, // Save this in the outer scope so it's persisted for later chatbots // All of this can be passed as url params to the webhook instead channelCapturedByBot: { @@ -151,6 +136,20 @@ export const handler = async ( const updatedChannelAttributes = JSON.parse(updated.attributes); + // Cleanup task for captured channel by the bot + await context + .getTwilioClient() + .taskrouter.workspaces(context.TWILIO_WORKSPACE_SID) + .tasks.create({ + workflowSid: context.SURVEY_WORKFLOW_SID, + attributes: JSON.stringify({ + isChatCaptureControl: true, + channelSid, + }), + taskChannel: 'survey', + timeout: 45600, // 720 minutes or 12 hours + }); + const handlerPath = Runtime.getFunctions()['helpers/lexClient'].path; const lexClient = require(handlerPath) as LexClient; diff --git a/functions/webhooks/chatbotCallback.protected.ts b/functions/webhooks/chatbotCallback.protected.ts index 8591c15b..41195c7b 100644 --- a/functions/webhooks/chatbotCallback.protected.ts +++ b/functions/webhooks/chatbotCallback.protected.ts @@ -126,8 +126,8 @@ export const handler = async ( // Move control task to complete state client.taskrouter.v1 .workspaces(context.TWILIO_WORKSPACE_SID) - .tasks(channelAttributes.controlTaskSid) - .update({ assignmentStatus: 'canceled' }), + .tasks(channelAttributes.controlTaskSid) // Who set this sid? + .update({ assignmentStatus: 'completed' }), // Remove this webhook from the channel channel .webhooks() From 4e0ff3b5c6d8b1fd0a753a65991c0b6e14128dce Mon Sep 17 00:00:00 2001 From: Murilo Machado Date: Tue, 4 Jul 2023 13:38:40 +0100 Subject: [PATCH 14/24] language default to en-US --- functions/captureChannelWithBot.protected.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/functions/captureChannelWithBot.protected.ts b/functions/captureChannelWithBot.protected.ts index e6a42d41..19838dd8 100644 --- a/functions/captureChannelWithBot.protected.ts +++ b/functions/captureChannelWithBot.protected.ts @@ -58,7 +58,7 @@ export const handler = async ( const resolve = bindResolve(callback)(response); try { - const { channelSid, message, fromServiceUser, studioFlowSid, language, type } = event; + const { channelSid, message, fromServiceUser, studioFlowSid, language = 'en-US', type } = event; if (!channelSid) { resolve(error400('channelSid')); @@ -76,10 +76,6 @@ export const handler = async ( resolve(error400('studioFlowSid')); return; } - if (!language) { - resolve(error400('language')); - return; - } if (!type) { resolve(error400('type')); return; From e0a22c00e6b89c3cd6d60a6cfb57b71f0bc171ed Mon Sep 17 00:00:00 2001 From: Murilo Machado Date: Tue, 4 Jul 2023 13:44:40 +0100 Subject: [PATCH 15/24] Add some fixes from Gian's PR --- .../webhooks/chatbotCallback.protected.ts | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/functions/webhooks/chatbotCallback.protected.ts b/functions/webhooks/chatbotCallback.protected.ts index 41195c7b..f5ce10e9 100644 --- a/functions/webhooks/chatbotCallback.protected.ts +++ b/functions/webhooks/chatbotCallback.protected.ts @@ -99,18 +99,26 @@ export const handler = async ( const releasedChannelAttributes = { ...omit(channelAttributes, 'channelCapturedByBot'), memory: lexResponse.slots, + preSurveyComplete: true, }; // TODO: This is now only assuming pre-survey bot. We should have a way to specify what's the next step after the bot execution is ended - const nextAction = client.studio.v2 - .flows(channelAttributes.channelCapturedByBot.studioFlowSid) - .executions.create({ - from: ChannelSid, - to: ChannelSid, - parameters: { - ChannelAttributes: releasedChannelAttributes, + const nextAction = () => + channel.webhooks().create({ + type: 'studio', + configuration: { + flowSid: channelAttributes.channelCapturedByBot.studioFlowSid, }, }); + // const nextAction = client.studio.v2 + // .flows(channelAttributes.channelCapturedByBot.studioFlowSid) + // .executions.create({ + // from: ChannelSid, + // to: ChannelSid, + // parameters: { + // ChannelAttributes: releasedChannelAttributes, + // }, + // }); await Promise.all([ // Delete Lex session. This is not really needed as the session will expire, but that depends on the config of Lex. @@ -123,23 +131,33 @@ export const handler = async ( channel.update({ attributes: JSON.stringify(releasedChannelAttributes), }), + /* I think we're not storing controlTaskSid anywhere. Also, if it's not assigned, + * it cannot be moved to 'completed' status. (maybe 'canceled'?) // Move control task to complete state client.taskrouter.v1 .workspaces(context.TWILIO_WORKSPACE_SID) .tasks(channelAttributes.controlTaskSid) // Who set this sid? .update({ assignmentStatus: 'completed' }), + */ // Remove this webhook from the channel channel .webhooks() .get(channelAttributes.channelCapturedByBot.chatbotCallbackWebhookSid) .remove(), // Trigger the next step once the channel is released - nextAction, + nextAction(), ]); console.log('Channel unblocked and bot session deleted'); } + // Why we need to send this message? + await channel.messages().create({ + body: lexResponse.message, + from: 'Bot', + xTwilioWebhookEnabled: 'true', + }); + resolve(success('All messages sent :)')); return; } From 5db22dcef4754068d915523153cea59e08da2212 Mon Sep 17 00:00:00 2001 From: Murilo Machado Date: Tue, 4 Jul 2023 13:56:45 +0100 Subject: [PATCH 16/24] fix language suffix --- functions/captureChannelWithBot.protected.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/functions/captureChannelWithBot.protected.ts b/functions/captureChannelWithBot.protected.ts index 19838dd8..2ef30d7c 100644 --- a/functions/captureChannelWithBot.protected.ts +++ b/functions/captureChannelWithBot.protected.ts @@ -58,7 +58,7 @@ export const handler = async ( const resolve = bindResolve(callback)(response); try { - const { channelSid, message, fromServiceUser, studioFlowSid, language = 'en-US', type } = event; + const { channelSid, message, fromServiceUser, studioFlowSid, language, type } = event; if (!channelSid) { resolve(error400('channelSid')); @@ -105,7 +105,8 @@ export const handler = async ( ); const { ENVIRONMENT_CODE, HELPLINE_CODE } = context; - const botName = `${ENVIRONMENT_CODE}_${HELPLINE_CODE}_${type}_${language.replace('-', '_')}`; + const languageSuffix = (language || 'en-US').replace('-', '_'); + const botName = `${ENVIRONMENT_CODE}_${HELPLINE_CODE}_${type}_${languageSuffix}`; const chatbotCallbackWebhook = await channel.webhooks().create({ type: 'webhook', From 230c4743a282fda8d8ac0db67b976926cf49bdea Mon Sep 17 00:00:00 2001 From: Murilo Machado Date: Tue, 4 Jul 2023 13:59:56 +0100 Subject: [PATCH 17/24] comment failing test --- tests/webhooks/chatbotCallback.test.ts | 51 +++++++++++++------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/tests/webhooks/chatbotCallback.test.ts b/tests/webhooks/chatbotCallback.test.ts index 2c4fea47..3a40a50e 100644 --- a/tests/webhooks/chatbotCallback.test.ts +++ b/tests/webhooks/chatbotCallback.test.ts @@ -144,31 +144,32 @@ afterEach(() => { }); describe('chatbotCallback', () => { - test('should return lexResonse, update channel, and resolve with succes', async () => { - const event: Body = { - Body: 'Test body', - From: 'channelAttributes', - ChannelSid: 'Test channelSid', - EventType: 'onMessageSent', - }; - - await chatbotCallback(context, event, mockCallback); - - // Assert that the necessary functions were called with the correct arguments - expect(context.getTwilioClient).toHaveBeenCalled(); - expect(context.getTwilioClient().chat.services).toHaveBeenCalledWith(context.CHAT_SERVICE_SID); - expect(context.getTwilioClient().chat.services().channels).toHaveBeenCalledWith( - event.ChannelSid, - ); - expect(context.getTwilioClient().chat.services().channels().fetch).toHaveBeenCalled(); - expect(mockCallback.mock.calls[0][0]).toBeNull(); - expect(mockCallback.mock.calls[0][1]).toEqual( - expect.objectContaining({ - _body: 'All messages sent :)', - _statusCode: 200, - }), - ); - }); + // TODO: Fix test + // test('should return lexResonse, update channel, and resolve with succes', async () => { + // const event: Body = { + // Body: 'Test body', + // From: 'channelAttributes', + // ChannelSid: 'Test channelSid', + // EventType: 'onMessageSent', + // }; + + // await chatbotCallback(context, event, mockCallback); + + // // Assert that the necessary functions were called with the correct arguments + // expect(context.getTwilioClient).toHaveBeenCalled(); + // expect(context.getTwilioClient().chat.services).toHaveBeenCalledWith(context.CHAT_SERVICE_SID); + // expect(context.getTwilioClient().chat.services().channels).toHaveBeenCalledWith( + // event.ChannelSid, + // ); + // expect(context.getTwilioClient().chat.services().channels().fetch).toHaveBeenCalled(); + // expect(mockCallback.mock.calls[0][0]).toBeNull(); + // expect(mockCallback.mock.calls[0][1]).toEqual( + // expect.objectContaining({ + // _body: 'All messages sent :)', + // _statusCode: 200, + // }), + // ); + // }); test('should handle the event and ignore it', async () => { const event: Body = { From 97e6f40c456881ea53aaa4abd0018d7055ed1c03 Mon Sep 17 00:00:00 2001 From: Murilo Machado Date: Tue, 4 Jul 2023 14:13:17 +0100 Subject: [PATCH 18/24] cleanup survey task --- functions/captureChannelWithBot.protected.ts | 28 +++++++++---------- .../webhooks/chatbotCallback.protected.ts | 9 ++---- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/functions/captureChannelWithBot.protected.ts b/functions/captureChannelWithBot.protected.ts index 2ef30d7c..9600e7dc 100644 --- a/functions/captureChannelWithBot.protected.ts +++ b/functions/captureChannelWithBot.protected.ts @@ -117,6 +117,19 @@ export const handler = async ( }, }); + const surveyTask = await context + .getTwilioClient() + .taskrouter.workspaces(context.TWILIO_WORKSPACE_SID) + .tasks.create({ + workflowSid: context.SURVEY_WORKFLOW_SID, + attributes: JSON.stringify({ + isChatCaptureControl: true, + channelSid, + }), + taskChannel: 'survey', + timeout: 45600, // 720 minutes or 12 hours + }); + const updated = await channel.update({ attributes: JSON.stringify({ ...channelAttributes, @@ -127,26 +140,13 @@ export const handler = async ( botAlias: 'latest', // assume we always use the latest published version studioFlowSid, chatbotCallbackWebhookSid: chatbotCallbackWebhook.sid, + surveyTaskSid: surveyTask.sid, }, }), }); const updatedChannelAttributes = JSON.parse(updated.attributes); - // Cleanup task for captured channel by the bot - await context - .getTwilioClient() - .taskrouter.workspaces(context.TWILIO_WORKSPACE_SID) - .tasks.create({ - workflowSid: context.SURVEY_WORKFLOW_SID, - attributes: JSON.stringify({ - isChatCaptureControl: true, - channelSid, - }), - taskChannel: 'survey', - timeout: 45600, // 720 minutes or 12 hours - }); - const handlerPath = Runtime.getFunctions()['helpers/lexClient'].path; const lexClient = require(handlerPath) as LexClient; diff --git a/functions/webhooks/chatbotCallback.protected.ts b/functions/webhooks/chatbotCallback.protected.ts index f5ce10e9..a507626c 100644 --- a/functions/webhooks/chatbotCallback.protected.ts +++ b/functions/webhooks/chatbotCallback.protected.ts @@ -131,14 +131,11 @@ export const handler = async ( channel.update({ attributes: JSON.stringify(releasedChannelAttributes), }), - /* I think we're not storing controlTaskSid anywhere. Also, if it's not assigned, - * it cannot be moved to 'completed' status. (maybe 'canceled'?) - // Move control task to complete state + // Move survey task to canceled state client.taskrouter.v1 .workspaces(context.TWILIO_WORKSPACE_SID) - .tasks(channelAttributes.controlTaskSid) // Who set this sid? - .update({ assignmentStatus: 'completed' }), - */ + .tasks(channelAttributes.channelCapturedByBot.surveyTaskSid) + .update({ assignmentStatus: 'canceled' }), // Remove this webhook from the channel channel .webhooks() From e356f122f9fedce1fff6bfaa8a61fa5b310907fc Mon Sep 17 00:00:00 2001 From: Murilo Machado Date: Tue, 4 Jul 2023 14:23:42 +0100 Subject: [PATCH 19/24] Remove duplicated messages from bot --- functions/webhooks/chatbotCallback.protected.ts | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/functions/webhooks/chatbotCallback.protected.ts b/functions/webhooks/chatbotCallback.protected.ts index a507626c..aecae979 100644 --- a/functions/webhooks/chatbotCallback.protected.ts +++ b/functions/webhooks/chatbotCallback.protected.ts @@ -88,12 +88,6 @@ export const handler = async ( userId: channel.sid, }); - await channel.messages().create({ - body: lexResponse.message, - from: 'Bot', - xTwilioWebhookEnabled: 'true', - }); - // If the session ended, we should unlock the channel to continue the Studio Flow if (lexClient.isEndOfDialog(lexResponse.dialogState)) { const releasedChannelAttributes = { @@ -110,15 +104,6 @@ export const handler = async ( flowSid: channelAttributes.channelCapturedByBot.studioFlowSid, }, }); - // const nextAction = client.studio.v2 - // .flows(channelAttributes.channelCapturedByBot.studioFlowSid) - // .executions.create({ - // from: ChannelSid, - // to: ChannelSid, - // parameters: { - // ChannelAttributes: releasedChannelAttributes, - // }, - // }); await Promise.all([ // Delete Lex session. This is not really needed as the session will expire, but that depends on the config of Lex. From 22e75bea975f43883745640b2ea603b765f17e1f Mon Sep 17 00:00:00 2001 From: Murilo Machado Date: Tue, 4 Jul 2023 14:34:24 +0100 Subject: [PATCH 20/24] Undo canceling survey task --- functions/captureChannelWithBot.protected.ts | 27 +++++++++---------- .../webhooks/chatbotCallback.protected.ts | 16 +++++++---- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/functions/captureChannelWithBot.protected.ts b/functions/captureChannelWithBot.protected.ts index 9600e7dc..503a0822 100644 --- a/functions/captureChannelWithBot.protected.ts +++ b/functions/captureChannelWithBot.protected.ts @@ -117,19 +117,6 @@ export const handler = async ( }, }); - const surveyTask = await context - .getTwilioClient() - .taskrouter.workspaces(context.TWILIO_WORKSPACE_SID) - .tasks.create({ - workflowSid: context.SURVEY_WORKFLOW_SID, - attributes: JSON.stringify({ - isChatCaptureControl: true, - channelSid, - }), - taskChannel: 'survey', - timeout: 45600, // 720 minutes or 12 hours - }); - const updated = await channel.update({ attributes: JSON.stringify({ ...channelAttributes, @@ -140,13 +127,25 @@ export const handler = async ( botAlias: 'latest', // assume we always use the latest published version studioFlowSid, chatbotCallbackWebhookSid: chatbotCallbackWebhook.sid, - surveyTaskSid: surveyTask.sid, }, }), }); const updatedChannelAttributes = JSON.parse(updated.attributes); + await context + .getTwilioClient() + .taskrouter.workspaces(context.TWILIO_WORKSPACE_SID) + .tasks.create({ + workflowSid: context.SURVEY_WORKFLOW_SID, + attributes: JSON.stringify({ + isChatCaptureControl: true, + channelSid, + }), + taskChannel: 'survey', + timeout: 45600, // 720 minutes or 12 hours + }); + const handlerPath = Runtime.getFunctions()['helpers/lexClient'].path; const lexClient = require(handlerPath) as LexClient; diff --git a/functions/webhooks/chatbotCallback.protected.ts b/functions/webhooks/chatbotCallback.protected.ts index aecae979..078f167b 100644 --- a/functions/webhooks/chatbotCallback.protected.ts +++ b/functions/webhooks/chatbotCallback.protected.ts @@ -116,11 +116,17 @@ export const handler = async ( channel.update({ attributes: JSON.stringify(releasedChannelAttributes), }), - // Move survey task to canceled state - client.taskrouter.v1 - .workspaces(context.TWILIO_WORKSPACE_SID) - .tasks(channelAttributes.channelCapturedByBot.surveyTaskSid) - .update({ assignmentStatus: 'canceled' }), + // Move control task to complete state + (async () => { + try { + await client.taskrouter.v1 + .workspaces(context.TWILIO_WORKSPACE_SID) + .tasks(channelAttributes.controlTaskSid) + .update({ assignmentStatus: 'completed' }); + } catch (err) { + console.log(err); + } + })(), // Remove this webhook from the channel channel .webhooks() From 070818b1fd0b6fb9c87e64efc42576c901024aec Mon Sep 17 00:00:00 2001 From: Murilo Machado Date: Tue, 4 Jul 2023 15:38:11 +0100 Subject: [PATCH 21/24] Fix tests --- tests/webhooks/chatbotCallback.test.ts | 51 +++++++++++++------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/tests/webhooks/chatbotCallback.test.ts b/tests/webhooks/chatbotCallback.test.ts index 3a40a50e..ac3503ff 100644 --- a/tests/webhooks/chatbotCallback.test.ts +++ b/tests/webhooks/chatbotCallback.test.ts @@ -69,6 +69,7 @@ const context = { get: jest.fn().mockReturnValue({ remove: jest.fn().mockReturnValue({}), }), + create: jest.fn(), }), }), messages: jest.fn().mockReturnValue({ @@ -145,31 +146,31 @@ afterEach(() => { describe('chatbotCallback', () => { // TODO: Fix test - // test('should return lexResonse, update channel, and resolve with succes', async () => { - // const event: Body = { - // Body: 'Test body', - // From: 'channelAttributes', - // ChannelSid: 'Test channelSid', - // EventType: 'onMessageSent', - // }; - - // await chatbotCallback(context, event, mockCallback); - - // // Assert that the necessary functions were called with the correct arguments - // expect(context.getTwilioClient).toHaveBeenCalled(); - // expect(context.getTwilioClient().chat.services).toHaveBeenCalledWith(context.CHAT_SERVICE_SID); - // expect(context.getTwilioClient().chat.services().channels).toHaveBeenCalledWith( - // event.ChannelSid, - // ); - // expect(context.getTwilioClient().chat.services().channels().fetch).toHaveBeenCalled(); - // expect(mockCallback.mock.calls[0][0]).toBeNull(); - // expect(mockCallback.mock.calls[0][1]).toEqual( - // expect.objectContaining({ - // _body: 'All messages sent :)', - // _statusCode: 200, - // }), - // ); - // }); + test('should return lexResonse, update channel, and resolve with succes', async () => { + const event: Body = { + Body: 'Test body', + From: 'channelAttributes', + ChannelSid: 'Test channelSid', + EventType: 'onMessageSent', + }; + + await chatbotCallback(context, event, mockCallback); + + // Assert that the necessary functions were called with the correct arguments + expect(context.getTwilioClient).toHaveBeenCalled(); + expect(context.getTwilioClient().chat.services).toHaveBeenCalledWith(context.CHAT_SERVICE_SID); + expect(context.getTwilioClient().chat.services().channels).toHaveBeenCalledWith( + event.ChannelSid, + ); + expect(context.getTwilioClient().chat.services().channels().fetch).toHaveBeenCalled(); + expect(mockCallback.mock.calls[0][0]).toBeNull(); + expect(mockCallback.mock.calls[0][1]).toEqual( + expect.objectContaining({ + _body: 'All messages sent :)', + _statusCode: 200, + }), + ); + }); test('should handle the event and ignore it', async () => { const event: Body = { From 2613c49eb46ddfad34afba77e5b10152d6bc728f Mon Sep 17 00:00:00 2001 From: Murilo Machado Date: Tue, 4 Jul 2023 15:43:16 +0100 Subject: [PATCH 22/24] remove test step --- .github/actions/main-action/action.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/actions/main-action/action.yml b/.github/actions/main-action/action.yml index 98d2c728..4e3e533f 100644 --- a/.github/actions/main-action/action.yml +++ b/.github/actions/main-action/action.yml @@ -87,9 +87,6 @@ runs: - name: Set helpline-name run: echo "helpline-name=${{ inputs.helpline-code }}_${{ inputs.environment-code }}" >> $GITHUB_ENV shell: bash - - name: Test helpline-name - run: echo ${{ env.helpline-name }} - shell: bash # Set any env vars needed from Parameter Store here # Slack env - name: Set GITHUB_ACTIONS_SLACK_BOT_TOKEN From 268b5eabf3393088a02b6d4d935b1681da6ff416 Mon Sep 17 00:00:00 2001 From: Murilo Machado Date: Wed, 5 Jul 2023 12:45:18 +0100 Subject: [PATCH 23/24] remove comment --- tests/webhooks/chatbotCallback.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/webhooks/chatbotCallback.test.ts b/tests/webhooks/chatbotCallback.test.ts index ac3503ff..45494bf7 100644 --- a/tests/webhooks/chatbotCallback.test.ts +++ b/tests/webhooks/chatbotCallback.test.ts @@ -145,7 +145,6 @@ afterEach(() => { }); describe('chatbotCallback', () => { - // TODO: Fix test test('should return lexResonse, update channel, and resolve with succes', async () => { const event: Body = { Body: 'Test body', From b5be8fd850784d8cb13d2f8b3851232cafb6f06a Mon Sep 17 00:00:00 2001 From: Murilo Machado Date: Wed, 5 Jul 2023 16:14:26 +0100 Subject: [PATCH 24/24] remove comment --- functions/webhooks/chatbotCallback.protected.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/functions/webhooks/chatbotCallback.protected.ts b/functions/webhooks/chatbotCallback.protected.ts index 078f167b..6b70c7d5 100644 --- a/functions/webhooks/chatbotCallback.protected.ts +++ b/functions/webhooks/chatbotCallback.protected.ts @@ -139,7 +139,6 @@ export const handler = async ( console.log('Channel unblocked and bot session deleted'); } - // Why we need to send this message? await channel.messages().create({ body: lexResponse.message, from: 'Bot',