Giter Club home page Giter Club logo

plugin-queued-callbacks-and-voicemail's Introduction

Twilio

Queued Callbacks and Voicemail for Flex

The Queued Callback and Voicemail for Flex plugin helps Flex admins automate handling of agent callback requests from customers instead of having them wait longer in a queue.

Set up

Requirements

To deploy this plugin, you will need:

  • An active Twilio account with Flex provisioned. Refer to the Flex Quickstart to create one.

  • npm version 5.0.0 or later installed (type npm -v in your terminal to check)

  • Node version 12.21 or later installed (type node -v in your terminal to check)

  • Twilio CLI along with the Flex CLI Plugin and the Serverless Plugin. Run the following commands to install them:

     # Install the Twilio CLI
     npm install twilio-cli -g
     # Install the Serverless and Flex as Plugins
     twilio plugins:install @twilio-labs/plugin-serverless
     twilio plugins:install @twilio-labs/plugin-flex
    
  • A GitHub account

  • Native Dialpad configured on your Flex instance

Twilio Account Settings

Before we begin, we need to collect all the config values we need to run the application:

Config Value Description
Account Sid Your primary Twilio account identifier - find this in the Console.
Serverless Deployment Domain The resulting Serverless domain name after deploying your Twilio Functions
Workspace SID Your Flex Task Assignment workspace SID - find this in the Console TaskRouter Workspaces page

Local development

After the above requirements have been met:

  1. Clone this repository
git clone [email protected]:twilio-labs/plugin-queued-callbacks-and-voicemail.git
  1. Change into the public subdirectory of the repo and run the following:
cd plugin-queued-callbacks-and-voicemail/public && mv appConfig.example.js appConfig.js
  1. Install dependencies
npm install
  1. Deploy your Twilio Functions and Assets

  2. Run the application

twilio flex:plugins:start

See Twilio Account Settings to locate the necessary environment variables.

  1. Run the application
npm start

Alternatively, you can use this command to start the server in development mode. It will reload whenever you change any files.

npm run dev
  1. Navigate to http://localhost:3000

That's it!

Twilio Serverless deployment

You need to deploy the functions associated with the Callback and Voicemail Flex plugin to your Flex instance. The functions are called from the plugin you will deploy in the next step and integrate with TaskRouter, passing in required attributes to generate the callback and voicemail tasks, depending on the customer selection while listening to the in-queue menu options.

Pre-deployment Steps

  1. From the root directory of your copy of the source code, change into serverless and rename .env.example to .env.
cd serverless && mv .env.example .env
  1. Open .env with your text editor and modify TWILIO_WORKSPACE_SID with your Flex Task Assignment SID.
TWILIO_WORKSPACE_SID=WSxxxxxxxxxxxxxxxxxxxxxx`
  1. To deploy your Callback and Voicemail functions and assets, run the following:
$ twilio serverless:deploy --assets

## Example Output
Deploying functions & assets to the Twilio Runtime
Env Variables
⠇ Creating 4 Functions
✔ Serverless project successfully deployed

Deployment Details
Domain: plugin-queued-callbacks-voicemail-functions-xxxx-dev.twil.io
Service:
  plugin-queued-callbacks-voicemail-functions 
Functions:
  https://plugin-queued-callbacks-voicemail-functions-xxxx-dev.twil.io/inqueue-callback
  https://plugin-queued-callbacks-voicemail-functions-xxxx-dev.twil.io/inqueue-utils  
  https://plugin-queued-callbacks-voicemail-functions-xxxx-dev.twil.io/queue-menu
  https://plugin-queued-callbacks-voicemail-functions-xxxx-dev.twil.io/inqueue-voicemail

Assets:
  https://plugin-queued-callbacks-voicemail-functions-xxxx-dev.twil.io/assets/alertTone.mp3
  https://plugin-queued-callbacks-voicemail-functions-xxxx-dev.twil.io/assets/guitar_music.mp3

Note: Copy and save the domain returned when you deploy a function. You will need it in the next step. If you forget to copy the domain, you can also find it by navigating to Functions > API in the Twilio Console.

Debugging Tip: Pass the -l or logging flag to review deployment logs. For example, you can pass -l debug to turn on debugging logs.

Deploy your Flex Plugin

Once you have deployed the function, it is time to deploy the plugin to your Flex instance.

Run the following commands in the plugin root directory. We will leverage the Twilio CLI to build and deploy the Plugin.

  1. Rename .env.example to .env.

  2. Open .env with your text editor and modify the REACT_APP_SERVICE_BASE_URL property to the Domain name you copied in the previous step. Make sure to prefix it with "https://".

    plugin-queued-callbacks-and-voicemail $ mv .env.example .env
    
    # .env
    REACT_APP_SERVICE_BASE_URL=https://plugin-queued-callbacks-voicemail-functions-4135-dev.twil.io
    
  3. When you are ready to deploy the plugin, run the following in a command shell:

    plugin-queued-callbacks-and-voicemail $ twilio flex:plugins:deploy --major --changelog "Updating to use the latest Twilio CLI Flex plugin" --description "Queued callbacks and voicemail"
    
  4. To enable the plugin on your contact center, follow the suggested next step on the deployment confirmation. To enable it via the Flex UI, see the Plugins Dashboard documentation.

Configurations

The serverless implementation can be customized using the file options.private.js. Options include:

  • sayOptions: Attributes for the <Say> verb used to prompt the customer. You can read more about these attributes and their values on TwiML™ Voice: <Say>
  • holdMusicUrl: Relative or absolute path to the audio file for hold music (default: /assets/guitar_music.mp3). If no domain is provided (i.e. relative path), the serverless domain will be used.
  • getEwt: Enable Estimated Waiting Time in voice prompt (default: true)
  • statPeriod: Time interval (in minutes) for Estimated Waiting Time stats evaluation (default: 5 minutes)
  • getQueuePosition: Enable Queue Position in voice prompt (default: true)
  • VoiceMailTaskPriority: Priority for the Task generatared by the VoiceMail (default: 50)
  • VoiceMailAlertTone: Relative or absolute path to the ringback tone that Twilio will play back to the Agent when calling a customer from a voice mail task (default: /assets/alertTone.mp3). If no domain is provided (i.e. relative path), the serverless domain will be used. This is not currently implemented in the Flex plugin, and it's for future usage
  • CallbackTaskPriority: Priority for the Task generatared by VoiceMail (default: 50)
  • CallbackAlertTone: Relative or absolute path to the ringback tone that Twilio will play back to the Agent when calling a customer from a callback task (default: /assets/alertTone.mp3). If no domain is provided (i.e. relative path), the serverless domain will be used. This is not currently implemented in the Flex plugin, and it's for future usage
  • TimeZone: Timezone configuration. This is used to report time and date of voicemail (default America/Los_Angeles)

License

MIT

Disclaimer

No warranty expressed or implied. Software is as is.

plugin-queued-callbacks-and-voicemail's People

Contributors

bermudezmt avatar ktalebian avatar rnairtwilio avatar swarnava avatar vernig avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

plugin-queued-callbacks-and-voicemail's Issues

Syntax error - Can't compile?

InQueueVoicemailComponent.js: JSX value should be either an expression or a quoted JSX text (300:12)

image

That's if I do twilio flex:plugins:start to run locally.
Twilio flex:plugins:deploy just returns failed to compile with no other output

Delete Recordings Fails

When I choose voicemail, call is delivered, when I click on Delete Recordings, nothing happens. When console on, I see the following:

image

The 404 is expected as this is not the correct URL for this plugin. The console.log of the baseUrl on delivery of the call does show the correct value, but this is using an incorrect baseUrl value. See below for initial render of baseURL:

image

Transcription not appearing in UI

Hi,

I am trying to create a voicemail with transcriptions enabled. I created a simple studio flow with a Record Voicemail widget that calls the service of the installed plugin. When I inspect the created task, everything seems to work, as it has the TranscriptText attribute:
Screenshot 2024-04-16 at 10 25 07

But in the UI, the transcription text is not displayed (the recording is working though):
Screenshot 2024-04-16 at 10 23 44

I have an assumption - the VoicemailComponent is looking for an attribute transcriptionText, but this actually doesn't exist - the attribute is called TranscriptText. Can this be the problem, or am I missing something?

Issue with plugin after deployment

I have the plugin compiled and deployed with the fix noted to a previous issue. Things seem to work fine except Place Outbound call for either Callback or Voicemail. When I click place outbound call I see this:

image

I do have legacy dialpad enabled. Behavior is same Firefox/Chrome. Is there somewhere else outbound dialing must be enabled?

Callbacks higher priority = handled out of order

Hello,

We have been using this plugin for a bit now and have noticed that callers who opt for the callback option are called prior to those that wait in the queue due to the callback task having a higher set priority. Ideally, the caller would retain their spot in line vs jumping to the head of the queue, but you aren't able to programmatically set a queue entered date to tell taskrouter that the task has been in queue for longer than the created date.

This should be edited for this plugin as it creates a negative user experience, do you have any guidance on how to fix this?

Hi, Please help me take a look

I got this error when I run twilio flex:plugins:deploy --major --changelog "Change plugin to use the latest Flex plugin for the Twilio CLI" --description "Queued Callback and Voicemail Plugin"

(node:30265) UnhandledPromiseRejectionWarning: Error: Cannot find module 'craco-config-flex-plugin'
Require stack:

  • /Users/pangge/twilio/voicemail/plugin-queued-callbacks-and-voicemail/craco.config.js
  • /Users/pangge/.twilio-cli/node_modules/@craco/craco/lib/config.js
  • /Users/pangge/.twilio-cli/node_modules/@craco/craco/scripts/build.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object. (/Users/pangge/twilio/voicemail/plugin-queued-callbacks-and-voicemail/craco.config.js:1:16)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    (Use node --trace-warnings ... to show where the warning was created)
    (node:30265) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
    (node:30265) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
    Could not find build file. Did you run npm run build first?

callback to different number fails.

Test procedure:
Tool: Monkey Phone-tester

  1. Call to your Flex Phone Number
  2. Go to voicemail, select for Callback option from the main menu choose Option #2 for entering number manually (as per https://github.com/twilio-labs/plugin-queued-callbacks-and-voicemail/blob/main/serverless/functions/inqueue-callback.protected.js#L100)
  3. Enter alternate number
    code file : inqueue-callback.protected.js.
    Line: 100
    message += 'Press 2 to be called at different number';

Result:
In the Task attributes the call-back number is not a valid E-164 format ("+" sign in prefix is missing)
So, when the agent tries to place a call it gives "Dialed number is invalid. Please check the number and try again."

Screenshot 2021-09-13 at 11 02 14

Trigger the Callback/Voicemail after workflow ends

Hello and thanks for sharing the plugin!

I have a workflow with 2 steps, and I would like to trigger the feature only at the end if no one answers.
Should I look for the speciic event and redirect the call to /queue-menu?mode=main or what to dou suggest?

Thanks

Max

Small Bug Fixes

Hi I've been working with the plugin and functions and they are great. As part of my use case I noticed a couple of small issues.

In serverless -> functions -> inqueue-voicemail.protected.js line 93 should be:

({ taskSid } = taskInfo); rather than ({ taskSid } = taskInfo.taskSid);

Also serverless -> functions -> queue-menu.protected.js line 130 it might be worth initiating the task info variable as an object with a status key as if both getEwt and getQueuePosition are set to false the function fails on the next conditional when it looks for taskInfo.status. For my use case I did the following:

let taskInfo = { status: "Not Requested" };

Thanks for putting together a great solution

Runtime warning

Hi,

I'm getting the message "Warning: Each child in an array or iterator should have a unique "key" prop", while creating a custom task type. The warning shows up when clicking the TaskListItem for the custom tasktype.

For now looks like the issue is only occurring when testing the plugin locally.

Steps to reproduce issue:

Deploy plugin locally.
Make a call to create a callback task.
Click on the task to see the details and this is where we get the warning message.

image

Retry option creates a new task in voice channel instead of original task's channel

Test:

No agents are available.
User leaves a voicemail.
When an agent comes online, they pick up the voicemail task.
When they click retry, the task appears in agent's queue, but it is ringing. It is no longer a voicemail talk but a voice task.

Expected behavior:

  • On Retry the new task should be created in the same channel as the original.
  • If this is the intended behavior, provide documentation on flex plugins page.

Screenshot 2024-04-02 at 2 49 51 PM

public/appConfig.js missing accountSid variable

This is the exact step noted from this readme section.There it is instructed to update accountSid variable. But there is no accountSid variable in appConfig.js (code 1). Assuming, I should add the extra variable I did as showed in code 1 (comment ) below.But, the react app didn't work,it didn't show any callback option or voicemail after creating the task in flex.
Step 3: Open appConfig.js with your text editor and update the accountSid variable with your account SID:
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'

//code 1 //assuming here I have to add this line "var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'" var appConfig = { pluginService: { enabled: true, url: '/plugins', }, ytica: false, logLevel: 'info', showSupervisorDesktopView: true, };

Change time attributes in task to camel case

This requires changes in:

Missing parts in UI

Unable to find the voicemail recordings and callback clickable option(voicemailcomponent.js & callbackcomponent.js) in the Flex UI after accepting the task. Any changes made to this? Am I missing any here?

Error thrown when a task is not reserved and callback / voicemail is requested

Test procedure:

  • Make sure no agents are available in Flex
  • Place a phone call
  • Press 1 to access the menu
  • Press 3 to leave a voice message

Result:
In the log for the serverless you should see the following:

Cannot cancel task WTxxxxxxxxxx in workspace WSxxxxxxxxxx for account ACxxxxxxxxxxxx because it is not pending or reserved.

Proposed fix:
Check the status of the task before attempting to cancel it

Improve readability of webhook URLs creation

Suggestion for a better query map builder:

// Have this helper
const urlBuilder = (url, queries) => {
  const params = new URLSearchParams();
  Object.entries(queries).forEach(([key, value]) => params.append(key, value));
  return `${url}?${params}`;
}

// then your `action` here can be
const queries = {
  mode: 'mainProcess',
  callsid: callSid,
  cbphone: explodePhone('format', phone),
};
if (event.taskSid) {
  queries.taskSid = event.taskSid;
}
const action = urlBuilder(`${domain}/inqueue-callback`, queries);

Easier to read IMO

Originally posted by @ktalebian in #20 (comment)

Missing Voicemail Callback Components

Unable to find the voicemail recordings and callback clickable option(voicemailcomponent.js & callbackcomponent.js) in the Flex UI after accepting the task. Not sure if I missed something or not.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.