Photo by Jaman Asad on Unsplash

Using A Low-Code, Visual Workflow Service To Orchestrate Your Chatbot

Combining AWS Step Functions State Machines & Amazon Lex

Introduction

Looking at the Conversational AI landscape, Lex will most probably not be a go-to Conversational AI solution in of itself. But rather existing products in AWS, needing to extend into a Conversational AI interface, will make use of it from a cost and convenience perspective.

AWS Step Functions lets you coordinate multiple AWS services into serverless workflows so you can build and update apps quickly. Using Step Functions, you can design and run workflows that stitch together services, such as AWS Lambda, AWS Fargate, and Amazon SageMaker, into feature-rich applications.

As seen above, AWS Step Functions lets you coordinate multiple AWS services into serverless workflows so you can build and update apps quickly.

Using Step Functions, you can design and run workflows that stitch together services, such as AWS Lex, AWS Lambda, AWS Fargate, and Amazon SageMaker, into feature-rich applications.

Considering that Gartner listed AWS innovation as one of the strengths of Lex, AWS Step Functions really makes sense.

One can argue that Lex does not have equivalent capability compared to most conversational platforms. Lex might look like a no-code environment, but to scale dialog flow and state management, it will have to be incorporated in a pro-code Lambda functions environment; or something equivalent.

And these Lambda functions, Lex and other AWS services can be orchestrated by a state machine of this nature.

I will be an interesting exercise to build a chatbot using Step Functions as the dialog state management engine…

AWS Step Functions Overview

The AWS Step Functions State Machine has two main components,

  • Actions
  • Flow

Actions are actionable elements from different AWS products. By typing “Lex” into the search bar, the Lex Actions are displayed. Currently Lex is running in two versions, V1 & V2. Care should be taken that the version of the Lex bot targeted and the version of the action are in sync.

Flow has a limited amount of node options, allows for if-then-else scenarios, running processes in parallel, mappings, wait and more.

Flow has a limited amount of node options, allows for if-then-else scenarios, running processes in parallel, mappings, wait and more.

Step Functions give chatbot developers the option to leverage other elements within their organisation’s AWS landscape and orchestrate it in order to serve the conversational agent.

For example, data can be retrieved, Lambda functions can be executed in parallel for back-end processing or lookups. Services like Amazon Transcribe or Amazon Comprehend can be leveraged.

Step Functions & Lex

The Step Functions product is ideal to automate management of the Lex conversational AI environment. Management can be automated, for example to get session details and terminate sessions.

A state machine can be created to list intents, or replaces an existing intent.

The Lex Version 2 actions are listed, these can be dragged and dropped onto the canvas.

Above, the Lex Version 2 actions are listed, these can be dragged and dropped onto the canvas. Text can be submitted to the bot and the JSON payload received.

One of the most compelling use-cases for this state machine environment is automated testing of the bot. A sequence of steps can be followed to ensure the required intents and slots/entities are available, and automated utterances submitted to the bot to confirm availability and function.

For example, the text below is submitted to Lex via the state machine…

"Text": "I want to book a room"

The execution path is shown as the state machine executes, with blue being in progress.

The execution path is shown as the state machine executes, with blue being in progress.

Below is the output from the Lex chatbot interface.

{
"Interpretations": [
{
"Intent": {
"ConfirmationState": "None",
"Name": "BookHotel",
"Slots": {},
"State": "InProgress"
},
"NluConfidence": {
"Score": 0.86
},
"SentimentResponse": {
"Sentiment": "NEUTRAL",
"SentimentScore": {
"Mixed": 0.0032838585320860147,
"Negative": 0.01709270104765892,
"Neutral": 0.8234726786613464,
"Positive": 0.15615078806877136
}
}
},
{
"Intent": {
"Name": "BookCar",
"Slots": {}
},
"NluConfidence": {
"Score": 0.53
},
"SentimentResponse": {
"Sentiment": "NEUTRAL",
"SentimentScore": {
"Mixed": 0.0032838585320860147,
"Negative": 0.01709270104765892,
"Neutral": 0.8234726786613464,
"Positive": 0.15615078806877136
}
}
},
{
"Intent": {
"Name": "FallbackIntent",
"Slots": {}
},
"SentimentResponse": {
"Sentiment": "NEUTRAL",
"SentimentScore": {
"Mixed": 0.0032838585320860147,
"Negative": 0.01709270104765892,
"Neutral": 0.8234726786613464,
"Positive": 0.15615078806877136
}
}
}
],
"Messages": [
{
"Content": "What city will you be staying in?",
"ContentType": "PlainText"
}
],
"SessionId": "12345",
"SessionState": {
"DialogAction": {
"SlotToElicit": "Location",
"Type": "ElicitSlot"
},
"Intent": {
"ConfirmationState": "None",
"Name": "BookHotel",
"Slots": {},
"State": "InProgress"
},
"OriginatingRequestId": "cc21ff0c-71e4-44da-9497-0d5105202c0e"
}
}

Step Functions should be useful in automating bot management and testing tasks. And also at run-time this state machine can be employed to orchestrate services around a customer conversation.

Conclusion

Conversational AI services like Oracle Digital Assistant & Lex are definitely not on par with other end-to-end cloud solutions. Especially the solutions focussing solely on creating conversation experiences are generating real differentiation.

However, when considering a framework like Lex, the cloud solution as a whole should be taken into account. This can be seen as an advantage or disadvantage, depending on the existing level of investment in a particular cloud environment.

--

--

--

NLP/NLU, Chatbots, Voice, Conversational UI/UX, CX Designer, Developer, Ubiquitous User Interfaces. www.cobusgreyling.me

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Code snippets that make you sus

The Journey through the Obstacle Course

Minimal Programs

How to do Nested Joins or Intersect in MySQL

Android Q-First Look

Time Pilot — Movement Experiments

Get Started with Netflix Conductor Workers

SubWallet what it is?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Cobus Greyling

Cobus Greyling

NLP/NLU, Chatbots, Voice, Conversational UI/UX, CX Designer, Developer, Ubiquitous User Interfaces. www.cobusgreyling.me

More from Medium

Chatbot Development Frameworks & Message Abstraction

A New Discord Server about Natural Language Processing

How to build a custom Named-Entity Recognition system for your chatbot engine

FAQ: Using Neurolabs’ Synthetic Computer Vision Solution in Retail

A virtual recreation of a supermarket fridge with virtual recreations of supermarket products in it.