diff --git a/hrm-form-definitions/form-definitions/sg/v1/profileForms/Sections.json b/hrm-form-definitions/form-definitions/sg/v1/profileForms/Sections.json index ed3f60b20b..5b783a7066 100644 --- a/hrm-form-definitions/form-definitions/sg/v1/profileForms/Sections.json +++ b/hrm-form-definitions/form-definitions/sg/v1/profileForms/Sections.json @@ -7,23 +7,5 @@ "rows": 20, "width": 500, "placeholder": "Enter a summary of the client" - }, - { - "name": "recommendedApproach", - "label": "Recommended Approach", - "editLabel": "Edit Recommended Approach", - "type": "textarea", - "rows": 20, - "width": 500, - "placeholder": "Enter recommended approach" - }, - { - "name": "details", - "label": "Details", - "editLabel": "Edit Details", - "type": "textarea", - "rows": 20, - "width": 500, - "placeholder": "Enter Details" } ] diff --git a/hrm-form-definitions/form-definitions/zm/v1/tabbedForms/ChildInformationTab.json b/hrm-form-definitions/form-definitions/zm/v1/tabbedForms/ChildInformationTab.json index d95a5eb3ce..9ddfd75435 100644 --- a/hrm-form-definitions/form-definitions/zm/v1/tabbedForms/ChildInformationTab.json +++ b/hrm-form-definitions/form-definitions/zm/v1/tabbedForms/ChildInformationTab.json @@ -360,6 +360,10 @@ "label": "Vulnerable Groups", "type": "listbox-multiselect", "options": [ + { + "value": "Asylum seeker", + "label": "Asylum seeker" + }, { "value": "HIV Positive?", "label": "HIV Positive?" @@ -400,6 +404,10 @@ "value": "Out-of-school child", "label": "Out-of-school child" }, + { + "value": "Refugees", + "label": "Refugees" + }, { "value": "Other", "label": "Other" diff --git a/plugin-hrm-form/src/components/contact/ContactDetailsHome.tsx b/plugin-hrm-form/src/components/contact/ContactDetailsHome.tsx index 67fe40593e..96f66d2a2b 100644 --- a/plugin-hrm-form/src/components/contact/ContactDetailsHome.tsx +++ b/plugin-hrm-form/src/components/contact/ContactDetailsHome.tsx @@ -293,14 +293,15 @@ const ContactDetailsHome: React.FC = function ({ ); const addedToCaseBanner = () => ; + const showAddcaseButton = !isDraft && !showRemovedFromCaseBanner; - const renderCaseButton = () => { + const renderCaseBanners = () => { if (featureFlags.enable_case_merging) { return ( <> {caseId ? addedToCaseBanner() - : !showRemovedFromCaseBanner && ( + : showAddcaseButton && ( = function ({ )} - {renderCaseButton()} + {renderCaseBanners()} } diff --git a/plugin-hrm-form/src/permissions/sg.json b/plugin-hrm-form/src/permissions/sg.json index 4bf909407b..112f4eb71f 100644 --- a/plugin-hrm-form/src/permissions/sg.json +++ b/plugin-hrm-form/src/permissions/sg.json @@ -30,7 +30,7 @@ "unflagProfile": [["isSupervisor"]], "createProfileSection": [["everyone"]], "viewProfileSection": [["everyone"]], - "editProfileSection": [["everyone"]], + "editProfileSection": [["isSupervisor"]], "viewPostSurvey": [["isSupervisor"]], diff --git a/plugin-hrm-form/src/translations/en-NZ/messages.json b/plugin-hrm-form/src/translations/en-NZ/messages.json index 1df1528d01..f866ca5eb6 100644 --- a/plugin-hrm-form/src/translations/en-NZ/messages.json +++ b/plugin-hrm-form/src/translations/en-NZ/messages.json @@ -1,6 +1,6 @@ { "WelcomeMsg": "Kia ora, you're now talking with a Youthline counsellor. How can we support you?", - "GoodbyeMsg": "We've closed this conversation on our side - you're welcome to reach out to us again the next time you need support. As a reminder, if you're feeling unsafe at any time you can get urgent support by calling 111, or the number for your area at www.health.govt.nz/cateams", + "GoodbyeMsg": "We've closed this conversation on our side - you're welcome to reach out to us again the next time you need support. As a reminder, if you're feeling unsafe at any time you can get urgent support by calling 111, or the number for your area at info.health.nz/crisis-assessment-teams", "EndChatMsg": "The client has clicked 'End Chat'. Thank you for reaching out. Please contact us again if you need more help.", "ClosedOutOfShift": "You've reached the Helpline outside our webchat hours. If you'd like to talk to us now, please txt us for free on 234 or call us for free on 0800376633", "ClosedHolidays": "The helpline is closed due to a holiday." diff --git a/plugin-hrm-form/src/utils/task.ts b/plugin-hrm-form/src/utils/task.ts index a7f2bc3a75..901c9cbd47 100644 --- a/plugin-hrm-form/src/utils/task.ts +++ b/plugin-hrm-form/src/utils/task.ts @@ -25,14 +25,18 @@ const getContactValueFromWebchat = task => { return preEngagementData.contactIdentifier; }; +/** + * IMPORTANT: keep up to date with serverless/functions/getProfileFlagsForIdentifier + */ const trimSpaces = (s: string) => s.replaceAll(' ', ''); - +const trimHyphens = (s: string) => s.replaceAll('-', ''); +const phoneNumberStandardization = (s: string) => [trimSpaces, trimHyphens].reduce((accum, f) => f(accum), s); type TransformIdentifierFunction = (c: string) => string; const channelTransformations: { [k in ChannelTypes]: TransformIdentifierFunction[] } = { - voice: [trimSpaces], - sms: [trimSpaces], - whatsapp: [s => s.replace('whatsapp:', ''), trimSpaces], - modica: [s => s.replace('modica:', ''), trimSpaces], + voice: [phoneNumberStandardization], + sms: [phoneNumberStandardization], + whatsapp: [s => s.replace('whatsapp:', ''), phoneNumberStandardization], + modica: [s => s.replace('modica:', ''), phoneNumberStandardization], facebook: [s => s.replace('messenger:', '')], instagram: [], line: [], diff --git a/twilio-iac/helplines/as/production.hcl b/twilio-iac/helplines/as/production.hcl index 0fc89a217a..9251090ade 100644 --- a/twilio-iac/helplines/as/production.hcl +++ b/twilio-iac/helplines/as/production.hcl @@ -9,14 +9,18 @@ locals { flow_vars = { capture_channel_with_bot_function_sid = "ZHd9eb5ce1b230abe29d9eafccc88b16d3" chatbot_callback_cleanup_function_sid = "ZH757387715913592aa1938b284411f18b" + send_message_janitor_function_sid = "ZHdfbbef84918d1e31fab54ab0cab8d0f7" bot_language = "en-US" + widget_from = "Aselo" + chat_blocked_message = "Sorry, you're not able to contact SafeSpot from this device or account" + error_message = "There has been an error with your message, please try writing us again." } channels = { webchat : { channel_type = "web" contact_identity = "" - templatefile = "/app/twilio-iac/helplines/templates/studio-flows/messaging-lex-v2.tftpl" + templatefile = "/app/twilio-iac/helplines/templates/studio-flows/messaging-lex-v2-blocking.tftpl" channel_flow_vars = {} chatbot_unique_names = [] }, @@ -24,7 +28,7 @@ locals { messaging_mode = "conversations" channel_type = "facebook" contact_identity = "messenger:105642325869250" - templatefile = "/app/twilio-iac/helplines/templates/studio-flows/messaging-lex-v3.tftpl" + templatefile = "/app/twilio-iac/helplines/templates/studio-flows/messaging-lex-v3-blocking.tftpl" channel_flow_vars = {} chatbot_unique_names = [] }, @@ -32,7 +36,7 @@ locals { messaging_mode = "conversations" channel_type = "whatsapp" contact_identity = "whatsapp:+15079441697" - templatefile = "/app/twilio-iac/helplines/templates/studio-flows/messaging-lex-v3.tftpl" + templatefile = "/app/twilio-iac/helplines/templates/studio-flows/messaging-lex-v3-blocking.tftpl" channel_flow_vars = {} chatbot_unique_names = [] }, @@ -40,7 +44,7 @@ locals { messaging_mode = "conversations" channel_type = "custom" contact_identity = "instagram" - templatefile = "/app/twilio-iac/helplines/templates/studio-flows/messaging-lex-v3.tftpl" + templatefile = "/app/twilio-iac/helplines/templates/studio-flows/messaging-custom-channel-lex-v3-blocking.tftpl" channel_flow_vars = {} chatbot_unique_names = [] }, @@ -48,7 +52,7 @@ locals { messaging_mode = "conversations" channel_type = "custom" contact_identity = "line" - templatefile = "/app/twilio-iac/helplines/templates/studio-flows/messaging-lex-v3.tftpl" + templatefile = "/app/twilio-iac/helplines/templates/studio-flows/messaging-custom-channel-lex-v3-blocking.tftpl" channel_flow_vars = {} chatbot_unique_names = [] }, diff --git a/twilio-iac/helplines/as/staging.hcl b/twilio-iac/helplines/as/staging.hcl index cbaed19bc9..bf3a583ab1 100644 --- a/twilio-iac/helplines/as/staging.hcl +++ b/twilio-iac/helplines/as/staging.hcl @@ -11,7 +11,11 @@ locals { flow_vars = { capture_channel_with_bot_function_sid = "ZH979fc67a70a4a9572552c81a0d5d41d7" chatbot_callback_cleanup_function_sid = "ZH31416a207f81bf504a1391ed7649400e" + send_message_janitor_function_sid = "ZH91e33557d45b6dd60100876452e2428b" bot_language = "en-US" + widget_from = "Aselo" + chat_blocked_message = "Sorry, you're not able to contact Aselo from this device or account" + error_message = "There has been an error with your message, please try writing us again." } @@ -19,7 +23,7 @@ locals { webchat : { channel_type = "web" contact_identity = "" - templatefile = "/app/twilio-iac/helplines/templates/studio-flows/messaging-lex-v2.tftpl" + templatefile = "/app/twilio-iac/helplines/templates/studio-flows/messaging-lex-v2-blocking.tftpl" channel_flow_vars = {} chatbot_unique_names = [] }, @@ -27,7 +31,7 @@ locals { messaging_mode = "conversations" channel_type = "messenger" contact_identity = "messenger:131329426738030" - templatefile = "/app/twilio-iac/helplines/templates/studio-flows/messaging-lex-v3.tftpl" + templatefile = "/app/twilio-iac/helplines/templates/studio-flows/messaging-lex-v3-blocking.tftpl" channel_flow_vars = {} chatbot_unique_names = [] }, @@ -35,7 +39,7 @@ locals { messaging_mode = "conversations" channel_type = "whatsapp" contact_identity = "whatsapp:+12055189944" - templatefile = "/app/twilio-iac/helplines/templates/studio-flows/messaging-lex-v3.tftpl" + templatefile = "/app/twilio-iac/helplines/templates/studio-flows/messaging-lex-v3-blocking.tftpl" channel_flow_vars = {} chatbot_unique_names = [] }, @@ -43,7 +47,7 @@ locals { messaging_mode = "conversations" channel_type = "custom" contact_identity = "line" - templatefile = "/app/twilio-iac/helplines/templates/studio-flows/messaging-lex-v3.tftpl" + templatefile = "/app/twilio-iac/helplines/templates/studio-flows/messaging-custom-channel-lex-v3-blocking.tftpl" channel_flow_vars = {} chatbot_unique_names = [] }, @@ -51,7 +55,7 @@ locals { messaging_mode = "conversations" channel_type = "custom" contact_identity = "telegram" - templatefile = "/app/twilio-iac/helplines/templates/studio-flows/messaging-lex-v3.tftpl" + templatefile = "/app/twilio-iac/helplines/templates/studio-flows/messaging-custom-channel-lex-v3-blocking.tftpl" channel_flow_vars = {} chatbot_unique_names = [] }, @@ -59,7 +63,7 @@ locals { messaging_mode = "conversations" channel_type = "custom" contact_identity = "instagram" - templatefile = "/app/twilio-iac/helplines/templates/studio-flows/messaging-lex-v3.tftpl" + templatefile = "/app/twilio-iac/helplines/templates/studio-flows/messaging-custom-channel-lex-v3-blocking.tftpl" channel_flow_vars = {} chatbot_unique_names = [] }, diff --git a/twilio-iac/helplines/templates/studio-flows/messaging-lex-v3-blocking.tftpl b/twilio-iac/helplines/templates/studio-flows/messaging-lex-v3-blocking.tftpl new file mode 100644 index 0000000000..445b3d8f44 --- /dev/null +++ b/twilio-iac/helplines/templates/studio-flows/messaging-lex-v3-blocking.tftpl @@ -0,0 +1,356 @@ +${ + jsonencode( + { + "description": flow_description, + "states": [ + { + "name": "Trigger", + "type": "trigger", + "transitions": [ + { + "event": "incomingMessage" + }, + { + "event": "incomingCall" + }, + { + "next": "getProfileFlagsForIdentifier", + "event": "incomingConversationMessage" + }, + { + "event": "incomingRequest" + }, + { + "event": "incomingParent" + } + ], + "properties": { + "offset": { + "x": -60, + "y": -540 + } + } + }, + { + "name": "getProfileFlagsForIdentifier", + "type": "make-http-request", + "transitions": [ + { + "next": "contact_routing", + "event": "success" + }, + { + "next": "pre_survey_complete", + "event": "failed" + } + ], + "properties": { + "offset": { + "x": -350, + "y": -280 + }, + "method": "POST", + "content_type": "application/json;charset=utf-8", + "add_twilio_auth": false, + "body": "{ \"trigger\": {{trigger | to_json}}, \"channelType\": \"${channel_name}\"}", + "url": "${serverless_url}/getProfileFlagsForIdentifier" + } + }, + { + "name": "send_blocked_message", + "type": "send-message", + "transitions": [ + { + "event": "sent" + }, + { + "event": "failed" + } + ], + "properties": { + "offset": { + "x": -640, + "y": 210 + }, + "service": "{{trigger.conversation.InstanceSid}}", + "channel": "{{trigger.conversation.ChannelSid}}", + "from": flow_vars["widget_from"], + "to": "{{contact.channel.address}}", + "body": flow_vars["chat_blocked_message"] + } + }, + { + "name": "contact_routing", + "type": "split-based-on", + "transitions": [ + { + "next": "pre_survey_complete", + "event": "noMatch" + }, + { + "next": "send_blocked_message", + "event": "match", + "conditions": [ + { + "friendly_name": "If value contains blocked", + "arguments": [ + "{{widgets.getProfileFlagsForIdentifier.parsed.flags}}" + ], + "type": "contains", + "value": "blocked" + } + ] + } + ], + "properties": { + "input": "{{widgets.getProfileFlagsForIdentifier.parsed.flags}}", + "offset": { + "x": -690, + "y": -60 + } + } + }, + { + "name": "attributes", + "type": "send-to-flex", + "transitions": [ + { + "event": "callComplete" + }, + { + "next": "webhook_notify_failed_to_enqueue", + "event": "failedToEnqueue" + }, + { + "event": "callFailure" + } + ], + "properties": { + "offset": { + "x": 420, + "y": 970 + }, + "workflow": workflow_sids["master"], + "channel": task_channel_sids["chat"], + "attributes":channel_attributes["default"] + } + }, + { + "name": "pre_survey_complete", + "type": "split-based-on", + "transitions": [ + { + "next": "capture_channel_with_bot", + "event": "noMatch" + }, + { + "next": "attributes", + "event": "match", + "conditions": [ + { + "friendly_name": "If value equal_to true", + "arguments": [ + "{{trigger.conversation.ChannelAttributes.preSurveyComplete}}" + ], + "type": "equal_to", + "value": "true" + } + ] + } + ], + "properties": { + "input": "{{trigger.conversation.ChannelAttributes.preSurveyComplete}}", + "offset": { + "x": 150, + "y": 200 + } + } + }, + { + "name": "capture_channel_with_bot", + "type": "run-function", + "transitions": [ + { + "event": "success" + }, + { + "next": "webhook_notify_error", + "event": "fail" + } + ], + "properties": { + "service_sid": serverless_service_sid, + "environment_sid": serverless_environment_sid, + "offset": { + "x": -130, + "y": 500 + }, + "function_sid": flow_vars["capture_channel_with_bot_function_sid"], + "parameters": [ + { + "value": "{{flow.channel.address}}", + "key": "channelSid" + }, + { + "value": "trigger_pre_survey", + "key": "message" + }, + { + "value": "{{flow.flow_sid}}", + "key": "studioFlowSid" + }, + { + "value": "en-US", + "key": "language" + }, + { + "value": "pre_survey", + "key": "botSuffix" + }, + { + "value": "withUserMessage", + "key": "triggerType" + }, + { + "value": "triggerStudioFlow", + "key": "releaseType" + }, + { + "value": "preSurveyComplete", + "key": "releaseFlag" + }, + { + "value": "{{trigger.conversation.Source | downcase}}", + "key": "channelType" + }, + { + "value": "true", + "key": "isConversation" + } + ], + "url": "${serverless_url}/channelCapture/captureChannelWithBot" + } + }, + { + "name": "channel_cleanup", + "type": "run-function", + "transitions": [ + { + "next": "attributes", + "event": "success" + }, + { + "next": "send_message_run_janitor", + "event": "fail" + } + ], + "properties": { + "service_sid": serverless_service_sid, + "environment_sid": serverless_environment_sid, + "offset": { + "x": -210, + "y": 1080 + }, + "function_sid": flow_vars["chatbot_callback_cleanup_function_sid"], + "parameters": [ + { + "value": "{{flow.channel.address}}", + "key": "channelSid" + } + ], + "url": "${serverless_url}/channelCapture/chatbotCallbackCleanup" + } + }, + { + "name": "webhook_notify_error", + "type": "make-http-request", + "transitions": [ + { + "next": "channel_cleanup", + "event": "success" + }, + { + "next": "channel_cleanup", + "event": "failed" + } + ], + "properties": { + "offset": { + "x": 0, + "y": 730 + }, + "method": "POST", + "content_type": "application/json;charset=utf-8", + "add_twilio_auth": false, + "body": "{ \"text\": \"Issue detected on ${short_helpline} ${short_environment} Flow SID: {{flow.flow_sid}} Execution SID: {{flow.sid}} \" }", + "url": webhook_url_studio_errors + } + }, + { + "name": "webhook_notify_failed_to_enqueue", + "type": "make-http-request", + "transitions": [ + { + "event": "success" + }, + { + "event": "failed" + } + ], + "properties": { + "offset": { + "x": 540, + "y": 1250 + }, + "method": "POST", + "content_type": "application/json;charset=utf-8", + "add_twilio_auth": false, + "body": "{ \"text\": \"Issue detected [Failed to Enqueue] on ${short_helpline} ${short_environment} Flow SID: {{flow.flow_sid}} Execution SID: {{flow.sid}} \" }", + "url": webhook_url_studio_errors + } + }, + { + "name": "send_message_run_janitor", + "type": "run-function", + "transitions": [ + { + "event": "success" + }, + { + "event": "fail" + } + ], + "properties": { + "service_sid": serverless_service_sid, + "environment_sid": serverless_environment_sid, + "offset": { + "x": 110, + "y": 1260 + }, + "function_sid": flow_vars["send_message_janitor_function_sid"], + "parameters": [ + { + "value": "{{flow.channel.address}}", + "key": "channelSid" + }, + { + "value": flow_vars["error_message"], + "key": "message" + }, + { + "value": flow_vars["widget_from"], + "key": "from" + } + ], + "url": "${serverless_url}/sendMessageAndRunJanitor" + } + } + ], + "initial_state": "Trigger", + "flags": { + "allow_concurrent_calls": true + } +} + + ) +} \ No newline at end of file diff --git a/twilio-iac/helplines/templates/workflows/queue-transfers.tftpl b/twilio-iac/helplines/templates/workflows/queue-transfers.tftpl index 5ebc9cf657..795c69444f 100644 --- a/twilio-iac/helplines/templates/workflows/queue-transfers.tftpl +++ b/twilio-iac/helplines/templates/workflows/queue-transfers.tftpl @@ -8,7 +8,8 @@ "expression": "transferTargetType == 'queue' AND targetSid == '${value}'", "targets": [ { - "queue": "${key == "survey" ? (contains(keys(task_queues), "master") ? task_queues.master : task_queues.survey) : value}" + "queue": "${key == "survey" ? (contains(keys(task_queues), "master") ? task_queues.master : task_queues.survey) : value}", + "expression": "(worker.waitingOfflineContact != true AND ((task.channelType == 'voice' AND worker.channel.chat.assigned_tasks == 0) OR (task.channelType != 'voice' AND worker.channel.voice.assigned_tasks == 0)) AND ((task.transferTargetType == 'worker' AND task.targetSid == worker.sid) OR (task.transferTargetType != 'worker' AND worker.sid != task.ignoreAgent))) OR (worker.waitingOfflineContact == true AND task.targetSid == worker.sid AND task.isContactlessTask == true)" } ] }%{ if length(task_queues) > 1 && key != keys(task_queues)[length(task_queues)-1] },%{ endif } diff --git a/twilio-iac/helplines/zm/production.hcl b/twilio-iac/helplines/zm/production.hcl index db4b27a43f..1a1e3b5ada 100644 --- a/twilio-iac/helplines/zm/production.hcl +++ b/twilio-iac/helplines/zm/production.hcl @@ -26,6 +26,14 @@ locals { templatefile = "/app/twilio-iac/helplines/zm/templates/studio-flows/messaging.tftpl" channel_flow_vars = {} chatbot_unique_names = [] + }, + voice : { + channel_type = "voice" + contact_identity = "" + templatefile = "/app/twilio-iac/helplines/zm/templates/studio-flows/voice-ac.tftpl" + channel_flow_vars = { + } + chatbot_unique_names = [] } } #Studio flow @@ -36,6 +44,8 @@ locals { capture_channel_with_bot_function_sid = "ZH38598267c5c40e659e4fef46a019dd24" widget_from = "Lifeline/Childline Zambia" chat_blocked_message = "Hi, you've been blocked from accessing Childline/Lifeline services and we are not able to read or receive further messages from you." + voice_ivr_language = "en-US", + voice_ivr_blocked_message = "Hi, you've been blocked from accessing Childline/Lifeline services and we are not able to receive further calls from you." } } } \ No newline at end of file diff --git a/twilio-iac/helplines/zm/staging.hcl b/twilio-iac/helplines/zm/staging.hcl index a697644bf8..33966ab3dc 100644 --- a/twilio-iac/helplines/zm/staging.hcl +++ b/twilio-iac/helplines/zm/staging.hcl @@ -27,6 +27,14 @@ locals { templatefile = "/app/twilio-iac/helplines/zm/templates/studio-flows/messaging-conv.tftpl" channel_flow_vars = {} chatbot_unique_names = [] + }, + voice : { + channel_type = "voice" + contact_identity = "" + templatefile = "/app/twilio-iac/helplines/zm/templates/studio-flows/voice-ac.tftpl" + channel_flow_vars = { + } + chatbot_unique_names = [] } } #Studio flow @@ -36,6 +44,8 @@ locals { chatbot_callback_cleanup_function_sid = "ZHc633e352ec3541df3eea9f9ae4af1ad4" widget_from = "Lifeline/Childline Zambia" chat_blocked_message = "Hi, you've been blocked from accessing Childline/Lifeline services and we are not able to read or receive further messages from you." + voice_ivr_language = "en-US", + voice_ivr_blocked_message = "Hi, you've been blocked from accessing Childline/Lifeline services and we are not able to receive further calls from you." } ui_editable = true diff --git a/twilio-iac/helplines/zm/templates/studio-flows/voice-ac.tftpl b/twilio-iac/helplines/zm/templates/studio-flows/voice-ac.tftpl new file mode 100644 index 0000000000..886524c7e2 --- /dev/null +++ b/twilio-iac/helplines/zm/templates/studio-flows/voice-ac.tftpl @@ -0,0 +1,147 @@ +${ + jsonencode( +{ + "description": flow_description, + "states": [ + { + "name": "Trigger", + "type": "trigger", + "transitions": [ + { + "event": "incomingMessage" + }, + { + "next": "getProfileFlagsForIdentifier", + "event": "incomingCall" + }, + { + "event": "incomingConversationMessage" + }, + { + "event": "incomingRequest" + }, + { + "event": "incomingParent" + } + ], + "properties": { + "offset": { + "x": -10, + "y": 0 + } + } + }, + { + "name": "SendCallToAgent", + "type": "send-to-flex", + "transitions": [ + { + "event": "callComplete" + }, + { + "event": "failedToEnqueue" + }, + { + "event": "callFailure" + } + ], + "properties": { + "offset": { + "x": 300, + "y": 760 + }, + "workflow": workflow_sids[ + "master" + ], + "channel": task_channel_sids[ + "voice" + ], + "attributes": "{ \"type\": \"inbound\", \"name_old\": \"{{trigger.call.From}}\",\"name\":\"{{trigger.call.From | replace: 'sip:', '' | split: '@' | first}}\",\"ignoreAgent\":\"\", \"transferTargetType\":\"\",\"channelType\":\"voice\", \"aseloCallId\": \"{{trigger.call.SipHeader_X-Aselo-Call-Id}}\",\"aseloHostId\": \"{{trigger.call.SipHeader_X-Aselo-Call-Id | split: ':' | last}}\", \"helpline\":\"{{trigger.call.SipHeader_X-Aselo-Helpline}}\"}" + } + }, + { + "name": "getProfileFlagsForIdentifier", + "type": "make-http-request", + "transitions": [ + { + "next": "contact_routing", + "event": "success" + }, + { + "next": "SendCallToAgent", + "event": "failed" + } + ], + "properties": { + "offset": { + "x": 130, + "y": 190 + }, + "method": "POST", + "content_type": "application/json;charset=utf-8", + "add_twilio_auth": false, + "body": "{\"trigger\": {{trigger | to_json}}}", + "url": "${serverless_url}/getProfileFlagsForIdentifier" + } + }, + { + "name": "contact_routing", + "type": "split-based-on", + "transitions": [ + { + "next": "SendCallToAgent", + "event": "noMatch" + }, + { + "next": "blocked", + "event": "match", + "conditions": [ + { + "friendly_name": "If value contains blocked", + "arguments": [ + "{{widgets.getProfileFlagsForIdentifier.parsed}}" + ], + "type": "contains", + "value": "blocked" + } + ] + } + ], + "properties": { + "input": "{{widgets.getProfileFlagsForIdentifier.parsed}}", + "offset": { + "x": -220, + "y": 400 + } + } + }, + { + "name": "blocked", + "type": "say-play", + "transitions": [ + { + "event": "audioComplete" + } + ], + "properties": { + "offset": { + "x": -300, + "y": 710 + }, + "loop": 1, + "say": flow_vars[ + "voice_ivr_blocked_message" + ], + "language": flow_vars[ + "voice_ivr_language" + ] + } + } + ], + "initial_state": "Trigger", + "flags": { + "allow_concurrent_calls": true + } + } +) +} \ No newline at end of file diff --git a/twilio-iac/helplines/zw/production.hcl b/twilio-iac/helplines/zw/production.hcl index ce0a1e036a..d4ca014528 100644 --- a/twilio-iac/helplines/zw/production.hcl +++ b/twilio-iac/helplines/zw/production.hcl @@ -7,12 +7,12 @@ locals { local_config = { - custom_task_routing_filter_expression = "channelType =='web' OR isContactlessTask == true OR twilioNumber == 'messenger:123236277715368'" + custom_task_routing_filter_expression = "channelType =='web' OR isContactlessTask == true OR twilioNumber == 'messenger:123236277715368'" - flow_vars = { - widget_from = "Childline Zimbabwe" - chat_blocked_message = "Hi, you've been blocked from accessing Childline services and we are not able to read or receive further messages from you." + flow_vars = { + widget_from = "Childline Zimbabwe" + chat_blocked_message = "Hi, you've been blocked from accessing Childline services and we are not able to read or receive further messages from you." } @@ -32,6 +32,16 @@ locals { templatefile = "/app/twilio-iac/helplines/templates/studio-flows/messaging-blocking.tftpl" channel_flow_vars = {} chatbot_unique_names = [] + }, + voice : { + channel_type = "voice" + contact_identity = "" + templatefile = "/app/twilio-iac/helplines/zw/templates/studio-flows/voice-ac.tftpl" + channel_flow_vars = { + voice_ivr_language = "en-US", + voice_ivr_blocked_message = "Hi, you've been blocked from accessing Childline services and we are not able to receive further calls from you." + } + chatbot_unique_names = [] } } diff --git a/twilio-iac/helplines/zw/staging.hcl b/twilio-iac/helplines/zw/staging.hcl index cc10ce9b60..c54b1d46e9 100644 --- a/twilio-iac/helplines/zw/staging.hcl +++ b/twilio-iac/helplines/zw/staging.hcl @@ -10,8 +10,8 @@ locals { flow_vars = { - widget_from = "Childline Zimbabwe" - chat_blocked_message = "Hi, you've been blocked from accessing Childline services and we are not able to read or receive further messages from you." + widget_from = "Childline Zimbabwe" + chat_blocked_message = "Hi, you've been blocked from accessing Childline services and we are not able to read or receive further messages from you." } channels = { @@ -21,6 +21,7 @@ locals { templatefile = "/app/twilio-iac/helplines/zw/templates/studio-flows/messaging-greeting-message-blocking.tftpl" channel_flow_vars = { chat_greeting_message = "Thank you for contacting Childline Zimbabwe, a counsellor will be with you shortly. If this is an emergency or you wait longer than 30 min, we recommend you call us for free at 116." + } chatbot_unique_names = [] }, @@ -32,10 +33,13 @@ locals { chatbot_unique_names = [] }, voice : { - channel_type = "voice" - contact_identity = "" - templatefile = "/app/twilio-iac/helplines/zw/templates/studio-flows/voice-ac.tftpl" - channel_flow_vars = {} + channel_type = "voice" + contact_identity = "" + templatefile = "/app/twilio-iac/helplines/zw/templates/studio-flows/voice-ac.tftpl" + channel_flow_vars = { + voice_ivr_language = "en-US", + voice_ivr_blocked_message = "Hi, you've been blocked from accessing Childline services and we are not able to receive further calls from you." + } chatbot_unique_names = [] } } diff --git a/twilio-iac/helplines/zw/templates/studio-flows/voice-ac.tftpl b/twilio-iac/helplines/zw/templates/studio-flows/voice-ac.tftpl index 9751ce2a90..aa77c3049a 100644 --- a/twilio-iac/helplines/zw/templates/studio-flows/voice-ac.tftpl +++ b/twilio-iac/helplines/zw/templates/studio-flows/voice-ac.tftpl @@ -11,7 +11,7 @@ ${ "event": "incomingMessage" }, { - "next": "SendCallToAgent", + "next": "getProfileFlagsForIdentifier", "event": "incomingCall" }, { @@ -47,12 +47,85 @@ ${ ], "properties": { "offset": { - "x": 30, - "y": 180 + "x": -30, + "y": 620 }, "workflow": workflow_sids["master"], "channel": task_channel_sids["voice"], - "attributes": "{ "type": "inbound", "name_old": "{{trigger.call.From}}","name":"{{trigger.call.From | replace: 'sip:', '' | split: '@' | first}}","ignoreAgent":"", "transferTargetType":"","channelType":"voice", "aseloCallId": "{{trigger.call.SipHeader_X-Aselo-Call-Id}}","aseloHostId": "{{trigger.call.SipHeader_X-Aselo-Call-Id | split: ':' | last}}"}" + "attributes": "{ \"type\": \"inbound\", \"name_old\": \"{{trigger.call.From}}\",\"name\":\"{{trigger.call.From | replace: 'sip:', '' | split: '@' | first}}\",\"ignoreAgent\":\"\", \"transferTargetType\":\"\",\"channelType\":\"voice\", \"aseloCallId\": \"{{trigger.call.SipHeader_X-Aselo-Call-Id}}\",\"aseloHostId\": \"{{trigger.call.SipHeader_X-Aselo-Call-Id | split: ':' | last}}\"}" + } + }, + { + "name": "getProfileFlagsForIdentifier", + "type": "make-http-request", + "transitions": [ + { + "next": "contact_routing", + "event": "success" + }, + { + "event": "failed" + } + ], + "properties": { + "offset": { + "x": 160, + "y": 170 + }, + "method": "POST", + "content_type": "application/x-www-form-urlencoded;charset=utf-8", + "add_twilio_auth": false, + "body": "{\"trigger\": {{trigger | to_json}}}", + "url": "${serverless_url}/getProfileFlagsForIdentifier" + } + }, + { + "name": "blocked", + "type": "say-play", + "transitions": [ + { + "event": "audioComplete" + } + ], + "properties": { + "offset": { + "x": 740, + "y": 610 + }, + "loop": 1, + "say": channel_flow_vars["voice_ivr_blocked_message"], + "language": channel_flow_vars["voice_ivr_language"] + } + }, + { + "name": "contact_routing", + "type": "split-based-on", + "transitions": [ + { + "next": "SendCallToAgent", + "event": "noMatch" + }, + { + "next": "blocked", + "event": "match", + "conditions": [ + { + "friendly_name": "If value contains blocked", + "arguments": [ + "{{widgets.getProfileFlagsForIdentifier.parsed}}" + ], + "type": "contains", + "value": "blocked" + } + ] + } + ], + "properties": { + "input": "{{widgets.getProfileFlagsForIdentifier.parsed}}", + "offset": { + "x": 350, + "y": 390 + } } } ],