Amazon Connect Quota Visibility

Not being able to see what your applied quota settings were has been a huge sore spot with Connect. We’ve resorted to keeping track of quotas on a spreadsheet and having AWS support provide updated numbers every 6 months. However, this is not scalable and generally a pain. I was very please when the following announcement was made, which states:

You can now view applied quota values for resources within each of your Amazon Connect instances using AWS Service Quotas. …

I immediately went to one of our Connect instances and was very disappointed at first. Because, the way AWS decided to present the applied quota as it’s not obvious. If you go to the Service Quotas > AWS Services> Amazon Connect. You see all applicable quotas for Connect. In this case let’s focus on Quick Connects. Notice that the “Applied quota value” is still the default.

Amazon Connect Service Quotas

Amazon Connect Service Quotas

If you click on the actual quota. You will still see the default at the top, but at the bottom right you’ll see the true applied number.

Quick Connects Per Instance Service Quota

Quick Connects Per Instance Service Quota

I’m happy this is here, but I wish AWS would just go the extra mile and not require us to click on the actual quote to see the true number. I’ve not validated this via the CLI, but I am hopeful it’s more obvious there.


How does Amazon Connect CCP Agent Login and Logout Work

I didn’t think a call center platform could make the topic of an agent login and logout interesting, but Amazon Connect has figured out a way to make me question my sanity with the design decision they have made.

We are going to do a deep dive into some of the uniqueness and outright strange behavior the CCP has when it comes to agent login and logout. This assumes you’re running the out of the box CCP, which means zero customization. Additionally, we’re going to be looking at 5 different screens at the same time to get an overall picture of what is going on and it’s impact to reporting. We will be looking at the Amazon Connect Dashboard, CCP, Real Time Agent reporting, Login/Logout report and Agent activity audit report.

Login to CCP

There are two ways that agents could login to CCP. The first is by logging into the Connect Dashboard (htts://<your-instance> then having agents launch CCP from there here’s what you need to know. The second way is to go to the CCP directly (https://<your-instance> Let’s walk through the first method step by step and see some of the reporting implications.

Step 1: A dashboard login:

  • Will show up in the Login/Logout report.
  • Will not show up in the Real Time Agent report.
  • Will not show up in the Agent activity audit report.

Why is this important? From the Dashboard to taking a call center call, the agent still needs to launch CCP and go into the Available state. I would argue that a better metric of login would be when the agent launches the CCP and not just logs into the Dashboard. The documentation for the Login/Logout report state this:

The Login/Logout report displays the login and logout information for the users in your contact center (for example, agents, managers, and administrators).

So the documentation is aligned with the behavior you see, but I would argue that, when it comes to agents, this report is misleading as an agent still has a few steps to follow before they are ready to take a call. Now, if you open the Agent activity audit report you will not see any data either which makes sense based on the Login/Logout report. Thankfully, both reports line up. Now, let’s get our agent from the Dashboard to CCP. By default the CCP should be in the Offline state.

Step 2: Launch CCP and:

  • The Login/Logout report doesn’t change as this is based on the Dashboard login.
  • You still will NOT show up in the Real Time Agent report.
  • You still will NOT show up in the Agent activity audit report.

Our agent has logged in to the Dashboard, launched CCP and is in an Offline state, but we’re still not seeing anything outside of the Login/Logout report. I would have expected the Real Time Agent report to show me the state of the agent, but that’s not happening. What’s even more infuriating is that if the agent changes states and then goes back to Offline, the Real Time Agent metrics have data about my agent. So why is Offline after login any different than going from one state to Offline state? To be fair, the agent will drop off from the statistics in about 3 minutes, however I think AWS should change this behavior and by default show any agent who is logged in and Offline to make things more consistent.

Logout of CCP

You would think that logout would be much easier, but there are still a few gotchas on this. The biggest thing to remember is that just closing the CCP window will not log you out. Another thing to consider is that a CCP logout will put you in Offline first then log you out. This is important to note if you have custom states you want to use for logout. However, if you are in the Dashboard and you launched the CCP and you logout from the Dashboard it will not properly log you out of the CCP. The CCP will eventually give you a login screen, but:

  • Real Time Agent metrics will still show you in the last state you were in.
  • Login/Logout report will show you logged out.
  • Agent Activity audit will still show you in the last state you were in.

Make it Better

Here are what I believe to be some simple suggestions to make this experience better. I hope that someone at AWS takes some of these and puts them in the next sprint.

  1. Offline state shows up in Real Time Agent metrics.
  2. The Routing Profile allows for configuring the default agent state upon login. This will put agents in any state when they first login.
  3. Dashboard or CCP logout behave the same way and reflect correctly across all reports.

Login and Logout at a Glance

Action Real Time Agent Login/Logout Report Agent Activity Audit
CCP Launch No Data Login time recorded either from Dashboard or CCP login No Data
CCP State Change State Data No Change State Data
Dashboard Logout Previous State Continues Logout time recorded No Data
CCP Logout Offline for about 3 minutes then stats disappear. Logout time recorded Offline State


Transcribe Your Audio Files To Migrate to Amazon Connect

This is an update to an earlier post covering the same thing now with updated code.

As we are working our way out of Cisco UCCE to Amazon Connect we find ourselves needing to transcribe thousands of prompts. I wanted to revisit this piece of code to ensure it is still working. If you want to use this and are starting from scratch here are the steps you need to take:

– Install Studio Code
– Install Python 3.9
– Create the folder where you will keep your project.
– Create a virtual environment.
– Activate your virtual environment.
– pip install python-dotenv, boto3, pandas
– *Remove the profile_name or update it.
– Update the .env file with the region you’ll be using.

You can find the full source code here.

The script works like this: It creates an S3 bucket, grabs the first file, checks if the file is in S3 and uploads it, creates a transcription job, waits for the transcription to complete, grabs the results, writes a CSV. I’ve tried to catch as many potential errors as possible, but I’m sure there are some lingering. Expect the transcription to take around 1 minute per file. Assuming normal IVR prompts.

AWS Transcribe* I have many AWS profiles, which might not the be case for others. If you only have a single profile change this line session = boto3.session.Session(profile_name=’MyProfile’) to session = boto3.session.Session()

I hope this helps others.


Contact Flow Block

Amazon Connect Contact Flow Editor Frustrations and Annoyances

The last few weeks have given me an opportunity to dig deeper into the AWS’s Amazon Connect solution. The purpose of this post will be to document some of my frustrations with the contact flow editor which I believe should be easy to fix. There are a few more frustrations which I don’t believe are easy, so I’ll save those for another post.

In the Contact flows screen there are a few things I would love to see. Firsts, make the Name, Type, and Description columns sortable. When there’s a very long list of flows this allows to quickly see specific groupings of flows together. Second, add an action menu at the end of the row which allows for a quick way to publish, duplicate, or delete a flow. This simple menu would save at least 2 extra clicks and covers some of the common actions one takes once inside the editor.

Amazon Connect Contact Flows Screen

Amazon Connect Contact Flows Screen

Let’s click on a specific contact flow and take it from the top down. Perhaps the most important thing here would be an auto save or confirmation that you might lose your changes if you try to navigate away from the editor screen. It’s very common that you have to go find a queue or prompt ARN, as they are not available in the editor, so if you browse away from the editor without saving you’ve lost your progress.

In an ideal world you would be able to easily switch from flow to flow without having to go back to the main contact flows screen. A drop down next to the flow name to quickly switch between flows would be great. This is specially useful when you want to copy and paste blocks between flows.

Contact Flow Editor Top Bar

Contact Flow Editor Top Bar

I’ve covered this one before, but it fits nicely with this post. You can save a flow or publish a flow and you can do both by using the publish button. However, the confirmation notification that you performed one or the other doesn’t confirm which one you did. This is minor annoyance as you can then move your eyes from the far left of the screen where the notification is found to the top right of your screen to see the Latest button label which will tell you the status of your current flow. It would be nice if the notification confirmed which action you took, I find myself  savings when I meant to publish and it always takes me a second to confirm which one I did.

Screen Shot 2021-06-23 at 6.07.16 AM

The workspace or the big white area with a grid where you place your blocks is the next focus. It’s nice to have infinite room to the right and bottom, but it would be nice if the same would be applied to the top and left. As your flow has more and more branching you find yourself scrolling further and further down, it would be nice if by default your start of the flow would be centered by default.

Remembering the zoom level or setting a default zoom level per flow will save a few clicks. As the flows gets bigger you start having to zoom in and out a lot more. When the flow is rather large, there’s very little reason why the default zoom level is the same as a flow which only has a few blocks. Below is the default view of two different flows. While this default view is useful for smaller flows, for bigger flows it’s not as useful and you immediately have to scroll around or zoom out to get to where you want to go faster.

Default View of Two Different Flows

Default View of Two Different Flows

One of the great things about contact flows is how many things you can do dynamically. However, you first have to bring in a lot of that data over to the flow. You do this with a Set contact attributes block. However, as you add more attributes it starts to become harder to find the right attribute you want to reference. Adding a way to sort or collapse every attribute details would make it much easier to find the attribute you’re looking for. This is specially important as the editor doesn’t tell you what attributes have already been defined. If that was the case this point might not be as important. Imagine having to scroll through a dozen of the aqua blocks below, having to  read each name to get to the one you want. Painful!

Amazon Connect Set Contact Attribute

Amazon Connect Set Contact Attribute

And finally, my biggest annoyance: block details. Block details are the configuration options each block has. You can get to them by clicking the top dark gray bar of any block.

Contact Flow Block

Contact Flow Block

There are two annoyances here. First, you can’t click on the workspace to close the block details. Even if you didn’t make a change you have to move your mouse to the far bottom left or right to click the cancel/x buttons. Heck, let me use the escape key to get out of there. So often I just need to see the configuration without making changes and having to cancel out every time takes unnecessary steps.

Contact Flow Configuration Details

Contact Flow Configuration Details

And finally, do not show me the details of a block that has nothing for me to configure. If by mistake I clicked on the gray bar of a terminate block. There’s nothing of value that this screen adds. Others might find the link to the documentation helpful, but I don’t. This annoyance would be lessen if I could quickly  escape from this screen, but since I’m being held captive by it and there’s no useful information displayed it just makes my blood boil.

Terminate Block Details

Terminate Block Details

I hope this post is not taken as me saying that Amazon Connect is not a good solution, far from it. This post is out there in hopes that someone at AWS who has the power to make things better sees what I believe are common frustrations.


Revisiting Initial Observations of Amazon Connect

Back in 2018 I made a series of posts detailing some of the good things and not so great things about Amazon Connect. Now that I’ve spent a few weeks getting reacquainted with the product I want to revisit one particular post (Initial Observations of Amazon Connect) and provide some update. While I love and am passionate about Cisco’s contact center offerings, I tried to check my bias as much as possible while working through this.

First, let’s cover some of the things I labeled as strange and provide an update:

  • Can’t change agent state while reserved or talking. Update: Has not changed.
  • If you use a desk phone, you can’t reject the call. Update: Has not changed.
  • Changes take about a minute or two to propagate and there’s no notification if your changes are live or not. Update: Has not changed.
  • If you create a new agent and then login as that agent using the same browser as before your admin session will be moved over to the new agent credentials. Painful when trying to test permissions on agents. Update: Has not changed. However, this is not an Amazon Connect issue as much as a browser caching and using multiple tabs issues.
  • You can’t re-route a connector by clicking on the start point, you must first delete the existing line and then create your new connector. Update: This has changed! You can re-route connectors by just clicking on the arrow.

Second, here are the things I said made no sense back in 2018 and their update:

  • Every step should have a Lambda invocation option. This would make the scripting a lot cleaner. Update: Has not changed.
  • If you reject a call and you’re the only agent you’re automatically set back to ready. Queue must be drained before last agent can change states out of available. Update: This has changed! You’re able to change to a non-routable state after you reject a call.
  • No default routing? I disabled the only queue and calls just dropped when I tried to route to that queue. You would think that the system would force some sort of default routing option just in case you make a mistake. Update: Has not changed. It is on the flow designer to account for queues being disabled.
  • Contact flow editor, no easy way to get back to all your contact flows. Update: Has not changed.
  • Agent auto accept takes about 12 seconds to trigger using soft-phone, this would impact agent stats and I really don’t see the point of having this feature if it’s going to take this long to connect an agent. Due to some limitation, I can’t re-rest.
  • When you save or publish a contact flow you get the same message “Contact flow saved successfully!” Different message for publish would be nice. Update: Has not changed. Seems to be such an easy change and would make the development of scripts so much easier.
  • No easy way to move the whole script. Work area should have infinite scroll to all sides. Update: I’ll give it a half change. While you still can’t select all blocks, you can zoom out and hold the control click and select the whole script or part of the script and move it. The fact that the script is still anchored to the top left corner still presents some challenges when you try to move things around.
  • You can’t select multiple nodes and move them, you must move one by one. Update: This has changed! Holding the control key allows you to select multiple nodes.
  • Flows don’t auto save drafts, if for some reason you don’t remember to save you’re SOL. Update: Has not changed.
  • How draft flows and published flows are handled is confusing. Not very user friendly. Update: Has not changed. While I’ve gotten more accustomed to it, it’s still could be a bit more intuitive.
  • Checking contact attributes doesn’t offer a NULL or NOT NULL condition check. Update: Has not changed.
  • When a connector goes behind a flow node, you can’t delete the connector. Update: I’ve not been able to reproduce this so I believe this has changed and the editor is better at automatically placing the lines.
  • No way to duplicate nodes. You must configure a new node from scratch every time. Update: This has changed! Holding the control key while you click a block allows you to copy it. This is probably the biggest change for me!

Amazon is pushing out tremendous new features and capabilities around Connect, but there are still some pretty glaring gaps which I believe could be easily solved. I will say the speed to develop and integrate feel unlimited, but once you get beyond the basics you need a good handle on code and AWS security and infrastructure to make your vision a reality.


AWS CLI Success

AWS CLI with SSL and Multiple AWS Instances

I’m ramping up to start a new Amazon Connect project and similar to what I did in the past I wanted to capture as many useful tidbits as I run into in the hopes that they will both help me remember things and help others doing similar things. In this blog we’re going to talk about setting up the AWS CLI when you have multiple AWS instances and are using SSO.

First, let’s cover why you would want to configure the AWS CLI. Many of us who have been in the contact center world for a long time either do no programming or very little programming. The programming we do is generally around solving very specific repetitive tasks or something very niche. However, with the race to the cloud and providers such as Amazon Connect and Twilio you will have to do some programming in order to truly leverage your CC platform. The AWS CLI allows that. Even if you feel that you will never do any programming or are opposed to it, the CLI allows for much faster access to AWS services. Once you get familiar with it you’ll realize that using the CLI allows you to understand your AWS configuration much better. You don’t have to know every command, but you’ll start with a few favorites and take it from there.

I’m setting this up on both Windows  and macOS and will try to call out the differences were possible.

To start, make sure you install AWS CLI version 2. If you have version 1 uninstall it before installing version 2. If you don’t have the latest version make sure you update it.  The documentation linked above works great on both Windows and macOS. Once it’s installed you want to validate it’s working by running the command in bold:

dmacias@MBP ~ % aws –version
aws-cli/2.2.8 Python/3.8.8 Darwin/20.3.0 exe/x86_64 prompt/off

Next, let’s configure your access. Remember that in this case our AWS account is SSO enabled and we are dealing with multiple instances so we’re going to setup our CLI to provide access using SSO and to use named profiles to get to each instance. First we’re going through the automatic configuration then we’ll go through the manual configuration to validate that everything is configured correctly.

Automatic Configuration

There are a few things you need to taken in to account. Your SSO URL must end in /start and your region must support SSO. Remember that this region could be different than your default region where you’re spinning up your resources. Finally, choose a profile name that is easy to remember. I generally go with instance name and role type when there are multiple of either.

dmacias@MBP ~ % aws configure sso
SSO start URL [None]:
SSO Region [None]: us-east-2
Attempting to automatically open the SSO authorization page in your default browser.
If the browser does not open or you wish to use a different device to authorize this request, open the following URL:

Then enter the code:

There are 2 AWS accounts available to you.
Using the account ID 3382948573928
The only role available to you is: AdministratorAccess
Using the role name “AdministratorAccess”
CLI default client Region [us-east-1]: us-west-2
CLI default output format [JSON]: json
CLI profile name [AdministratorAccess-3382948573928]: dev-profile

To use this profile, specify the profile name using –profile, as shown:

aws s3 ls –profile dev-profile

If SSO fails and you get an “Invalid_grant Invalid grant provided” error check your SSO region. You more than likely have the wrong one.



What you want to see to know everything is good is this.

AWS CLI Success

AWS CLI Success

Manual Configuration

You can repeat the above steps for any other instances and roles you want to configure. To validate the configuration or make changes to what is already configured you can run the same command above or you can open the AWS CLI config file located in macOS ~/.aws/config or in Windows %UserProfile%/.aws/config. Below you’ll see two different profiles configured.

[profile dev-profile]
sso_start_url =
sso_region = us-east-2
sso_account_id = 3382948573928
sso_role_name = AdministratorAccess
region = us-west-2
output = json
[profile stage-profile]
sso_start_url =
sso_region = us-east-2
sso_account_id = 2834343234234234
sso_role_name = AdministratorAccess
region = us-east-2
output = json

Now to ensure your profiles work as expected run a command. In this case I want to see all the S3 buckets configured and that I have access to.

dmacias@MBP ~ % aws s3 ls –profile dev-profile
2021-05-01 01:23:42 amazon-connect-123a3dam9834

Finally, if you want to logout you can run

dmacias@MBP ~ % aws sso logout

Then to log back in or to change profiles you do this

dmacias@MBP ~ % aws sso login –profile dev-profile


Microsoft and Nuance a Brilliant Play for Redmond

Bloomberg reports that Microsoft “is in advanced talks” to purchase Nuance. I’ve not been able to stop thinking of this move and I’ll be the first to admit that it surprised me, but the more I think about it and the more I talk to others in the industry this is an absolutely brilliant move. Here are my crystal ball predictions:

The patent play: Nuance comes with over 2000 patents. This is a huge cache which will no doubt be useful for the upcoming AI wars. This will be a huge boosts to Microsoft’s already huge R&D commitment in this space.

This hospital bill is brought to you by Microsoft: Nuance makes the majority of their money from the healthcare sector. We’re not talking just dictations or document management, we’re talking EHR, billing, and diagnosis software. Windows and Office are already prevalent in the healthcare space, this puts MS in the heart (get it?) of hospital operations and processes.

Cortana, it was the best of times it was the worst of times: Did you know that Windows 10 was Cortana’s big debut in the desktop space? Yeah neither did anyone else. Cortana began in 2014 as a direct competition to Alexa which was released the year before. At the time Microsoft was beginning to make some heavy bets in to the mobile space with Windows mobile. Well it’s a decade later and Windows mobile is dead, Cortana’s OS integration has been neutered and I’ve never seen another human being speak to their Windows PC. I believe this is going to change that with a huge marketing push of some college student dictating their final paper to their Microsoft Surface device while getting a manicure.

Where we’re going we don’t need passwords: Nuance comes with perhaps one of the oldest if not best speech biometrics software. Imagine joining a Microsoft Teams meetings where you call in and start speaking and you’re authenticated immediately. Or allow for “signatures” based solely on your voice. Verification and authentication continue to be huge and the rise of better and better “deep fake” technology will allow for some sort of trust verification service with Nuance biometrics in the middle of it.

(Part 1) We’re taking our ball and going home: This one is near and dear to me heart. If a Cisco call center customer wanted to have speech recognition or text to speech there was only one name in town. Nuance. This has changed a bit in the last few years with the introduction of LumenVox as an additional option. And this has changed even further in the last 18 months with Cisco supporting Google’s DialogFlow, but Nuance still reigns supreme. I can see MS increasing the pricing of an already very expensive product making it prohibitive for some call centers to run their software.

(Part 2) I can see clearly now the rain is gone: Did you know that Azure stands for the color blue of a cloudless sky? Microsoft will be able to create a very defensible moat around their Azure offerings by being the only provider to have the latest and greatest Nuance services. In addition, some telephony cloud provider, who are already battling Amazon and who white label Nuance products as part of their offering, might be forced to either consume more Azure resources to get better pricing or completely get priced out from this technology and watch the competition pass them by. This sets the stage for Microsoft to be in the driver’s seat of what UC or CC provider you might choose next if you have an already deep Nuance integration or if your call center must use Nuance.







Amazon Connect CCP (Agent Desktop) Walkthrough

I was talking to a few people about Connect and we were focusing on the agent desktop. For someone who is coming from Cisco Finesse, CCP is a big departure and I couldn’t find a good resource which showed all the out of the box functionality in a concise way. So, here it is. Everything you need to know about straight out of the box CCP.

CCP Highlights

  • 100% web-based.
  • Uses WebRTC and Opus audio codec.

Login Screen

  • Can be integrated to SSO.
  • Allows for password self-service.


Initial Screen

  • Will set you to whatever state you last had before you logged off or killed the client.
  • Transfer buttons are semi context aware (more on this later).
  • Agent status/state menu.
  • Log out is not a state, but a separate button.
  • Ability to get calls via a hard phone/PSTN instead of over the web.
  • Ability to download agent side logs (JSON format) from first login to right now.
  • Multi-lingual support 8 languages.


Call Screen

  • Agent whisper of queue name.
  • ANI of caller.
  • Transfer numbers based on queue name.
  • Can transfer to another queue, another agent, or external. Can even transfer to yourself which makes no sense.
  • Multi line support.
  • Can make outbound calls manually.




Bringing Amazon Lex into your Amazon Connect flows

In this blog we’ll continue our discussion around Amazon Lex. Talk about a few things to keep in mind when integrating your Amazon Lex bot with your Amazon Connect flow. In my particular use case I wanted to use Amazon Lex to look at my Gmail calendar and book a meeting if I’m available. If you want to skip to the very end you can see the end result via video. You’ll see one video of the voice interaction and one of the Facebook Messenger interaction.

First, you might want to reference my previous post around Lex validation. Now let’s talk about our use case:

  • Lex easily allows you to build a bot which understand both voice and text, so our bot needs to handle calls into our call center as well as Facebook Messenger interactions.
  • Bot needs to to ask a few question in order to find out what time the user would like to meet.
  • Bot should only schedule calls between Monday-Friday and 10 AM – 4 PM Easter Time
  • Bot (using Lambda) should schedule a meeting and if slot already taken then suggest an alternate time to meet.

Second, let’s take a quick look at the Lex screen. The bot I created is very simple and it follows closely the Flowers example provided by Amazon. These are the slots I’m requiring my bot to confirm.


I used two different Lambda functions. One for validation and one for fulfillment. While most examples seem to focus on using the same function for both, for me it was easier to have different code bases for each with the added benefit of keeping the code manageable. As it is both validation and fulfillment both came in at around 250 lines of code, but fulfillment had around 9 megabytes of dependencies.


Finally, here are sample utterances I used for the main intent.


What this gets us is the following. The first video is the voice interaction. I went about it the long way to show some of the validation rules being set by the bot, such as no weekend meetings and no meetings too early in the day. At the end of the video you see I refresh the Gmail calendar to show the new appointment has been saved.

In the second video I go through the same Lex bot using Facebook Messenger and then show the calendar to prove that the appointment was saved.

Ultimately, Amazon makes it extremely easy to create a mutli channel bot, however the integration to back end systems is the tricky part. This bot needs a lot of tuning to make it more natural, but for just a few hours of work there’s very little out there that can get your call center to have some bot integration for self service.


Creating a Lambda Function to Validate Lex Input

In this blog we’re going to step a bit away from Amazon Connect and focus on building a conversational interface using Amazon Lex. As you can probably guess down the line, this interface/bot is going to be connected to Amazon Connect for even more contact center goodness. Here we’re going to focus on creating a Lambda function strictly for validation, not for fulfillment.

First, let’s talk about what I’m building. I’m building a bot which can schedule a time to have a call with me. You tell your intention to the bot “schedule a meeting/call” and the bot will then ask you a few questions using directed language to figure out when you want to meet. Once Lex has all the information it needs it goes out to my calendar to figure out if I’m free or busy. Second, the validation code I have is mainly based on one of Amazon’s great blueprint for ordering flowers. I recommend you start with that before trying to write your own from scratch. Finally, read through the code and pay close attention to the comments marked in bold as these were the biggest gotchas as I went through.

A couple of things to keep in mind when building a conversation interface with Amazon Lex and you’re using validation.

– Have a clear scope of the conversation. I’m not a VUI designer by any means, but if you’re planning on going with an open-ended prompt “How may I help you?” you will be working on this for a long time. Instead try to focus on the smallest possible outcome. Ultimately, it is my opinion that no IVR is really NLU and they are all just directed speech apps with a lot more money sunk into them so they can be called NLU IVRs.

– If you’re going to use input validation, every user input will be ran through Lambda. This means that you must account for people saying random things which aren’t related to what your bot does and these random things will be processed through the validation function and might generate errors. Thus, you need to ignore this input and direct the customer to answer your question, so you can move on.

– Separating validation from fulfillment makes the most sense. Other than making your code easier to read and manage, you’re also able to separate responsibilities and permissions between your two Lambda functions.

– Play around with the examples Amazon provides. They are a great tool to get started and give you a ton of building blocks you can use in your own bot.

Here’s the validation code as well as some notes, hopefully this helps someone else along the way.

'use strict';

// --------------- Helpers to build responses which match the structure of the necessary dialog actions -----------------------

//elicitSlot is in charge of building the request back to Lex and tell Lex what slot needs to be re-filled.
function elicitSlot(sessionAttributes, intentName, slots, slotToElicit, message) {
return {
dialogAction: {
type: 'ElicitSlot',

function close(sessionAttributes, fulfillmentState, message) {
return {
dialogAction: {
type: 'Close',

function delegate(sessionAttributes, slots) {
return {
dialogAction: {
type: 'Delegate',

function confirm(sessionAttributes, intentName, slots){
type: 'ConfirmIntent',
message: {
contentType: 'PlainText',
content: 'We are set, do you want to schedule this meeting?'
// ---------------- Helper Functions --------------------------------------------------

function isDateWeekday(date) {
const myDate = parseLocalDate(date);
if (myDate.getDay() == 0 || myDate.getDay() == 6) {
console.log("Date is a weekend.");
return false;
} else {
console.log("Date is a weekday.");
return true;

function parseLocalDate(date) {
* Construct a date object in the local timezone by parsing the input date string, assuming a YYYY-MM-DD format.
* Note that the Date(dateString) constructor is explicitly avoided as it may implicitly assume a UTC timezone.

const dateComponents = date.split(/\-/);
return new Date(dateComponents[0], dateComponents[1] - 1, dateComponents[2]);

function isValidDate(date) {
try {
return !(isNaN(parseLocalDate(date).getTime()));
} catch (err) {
return false;
function buildValidationResult(isValid, violatedSlot, messageContent) {
if (messageContent == null) {
return {

return {
message: { contentType: 'PlainText', content: messageContent },

function validateMeeting(meetingDate, meetingTime, meetingLength) {

if (meetingDate) {
if (!isValidDate(meetingDate)) {
return buildValidationResult(false, 'MeetingDate', 'That date did not make sense. What date would you like to meet?');

if (parseLocalDate(meetingDate) < new Date()) {
return buildValidationResult(false, 'MeetingDate', 'You can only schedule meetings starting the next business day. What day would you like to meet?');

if (!isDateWeekday(meetingDate)) {
return buildValidationResult(false, 'MeetingDate', 'You can only schedule meetings during the normal weekday. What day would you like to meet?');

if (meetingTime) {
if (meetingTime.length !== 5) {
// Not a valid time; use a prompt defined on the build-time model.
return buildValidationResult(false, 'MeetingTime', null);
const hour = parseInt(meetingTime.substring(0, 2), 10);
const minute = parseInt(meetingTime.substring(3), 10);
if (isNaN(hour) || isNaN(minute)) {
//Not a valid time; use a prompt defined on the build-time model.
return buildValidationResult(false, 'MeetingTime', null);
if (hour < 10 || hour > 16) {
//Outside of business hours

return buildValidationResult(false, 'MeetingTime', 'Meetings can only be scheduled between 10 AM and 4 PM. Can you specify a time during this range?');


return buildValidationResult(false, 'MeetingLength', 'Will this be a short or long meeting?');
return buildValidationResult(true, null, null);

//--------------- Functions that control the bot's behavior -----------------------
function orderFlowers(intentRequest, callback) {
const source = intentRequest.invocationSource;
//get appointment slots
const meetingDate = intentRequest.currentIntent.slots.MeetingDate;
const meetingTime = intentRequest.currentIntent.slots.MeetingTime;
const meetingLength = intentRequest.currentIntent.slots.MeetingLength;

//For fullfilment source will NOT be DialogCodeHook
if (source === 'DialogCodeHook') {
//Perform basic validation on the supplied input slots. Use the elicitSlot dialog action to re-prompt for the first violation detected.
const slots = intentRequest.currentIntent.slots;
const validationResult = validateMeeting(meetingDate, meetingTime, meetingLength);

if (!validationResult.isValid) {
slots[`${validationResult.violatedSlot}`] = null;
callback(elicitSlot(intentRequest.sessionAttributes,, slots, validationResult.violatedSlot, validationResult.message));

//Pass the price of the flowers back through session attributes to be used in various prompts defined on the bot model.
const outputSessionAttributes = intentRequest.sessionAttributes || {};
callback(delegate(outputSessionAttributes, intentRequest.currentIntent.slots));

// --------------- Intents -----------------------
function dispatch(intentRequest, callback) {
const intentName =;

//Dispatch to your skill's intent handlers
if (intentName === 'MakeAppointment') {
return orderFlowers(intentRequest, callback);
throw new Error(`Intent with name ${intentName} not supported`);

//--------------- Main handler -----------------------
//Route the incoming request based on intent.
//The JSON body of the request is provided in the event slot.
//Execution starts here and moves up based on function exports.handler => dispatch =>orderFlowers=>validateMeeting=>buildValidationResult is the most typical path a request will take.

exports.handler = (event, context, callback) => {
try {
dispatch(event, (response) => callback(null, response));
} catch (err) {