Skip to content

Commit

Permalink
Merge pull request #744 from techmatters/CHI-3069-set_delegate_url_ev…
Browse files Browse the repository at this point in the history
…erywhere

CHI-3069: Use flex configuration for twilio lambda URL - small change, merging without review
  • Loading branch information
stephenhand authored Jan 17, 2025
2 parents c08a32d + b67544e commit 4d1e48d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,4 @@ runs:

- name: Add MODICA_TEST_SEND_MESSAGE_URL
run: echo "MODICA_TEST_SEND_MESSAGE_URL=${{ env.MODICA_TEST_SEND_MESSAGE_URL }}" >> .env
shell: bash


- name: Add DELEGATE_WEBHOOK_URL
run: echo "DELEGATE_WEBHOOK_URL=https://hrm-development.tl.techmatters.org/lambda/twilio/account-scoped" >> .env
shell: bash
9 changes: 7 additions & 2 deletions functions/webhooks/taskrouterCallback.protected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,13 @@ const runTaskrouterListeners = async (
) => {
const listeners = getListeners();
let delegatePromise: Promise<any> = Promise.resolve();
if (context.DELEGATE_WEBHOOK_URL) {
const delegateUrl = `${context.DELEGATE_WEBHOOK_URL}/${context.ACCOUNT_SID}${context.PATH}`;
const serviceConfig = await context.getTwilioClient().flexApi.configuration.get().fetch();
const {
feature_flags: { enable_task_router_event_delegation: enableTaskRouterEventDelegation },
hrm_base_url: hrmBaseUrl,
} = serviceConfig.attributes;
if (enableTaskRouterEventDelegation) {
const delegateUrl = `${hrmBaseUrl}/lambda/twilio/account-scoped/${context.ACCOUNT_SID}${context.PATH}`;
const forwardedHeaderEntries = Object.entries(request.headers).filter(
([key]) => key.toLowerCase().startsWith('x-') || key.toLowerCase().startsWith('t-'),
);
Expand Down

0 comments on commit 4d1e48d

Please sign in to comment.