Integrate a CRM Application with Alexa using AWS Lambda: Part-1

  • Basic AWS Lambda understanding
  • Basic knowledge about how Alexa works. Don’t need a deep knowledge
  • Understand what is CRM
  • What is an API

What is CRM

What is Alexa

About the Functionality

  • The skill is invoked by speaking the invocation name to Alexa(for now I have kept the invocation word as my assistant)
  • Ask the specific command based on what you need from CRM
  • In the back end, the skill triggers a Lambda function which calls the CRM API to perform the necessary task like get data, create records etc.
  • The skill gets the output from the Lambda function and responds the data to the user through voice reply
Ask for Lead
Lead in CRM
Create Lead
Lead in CRM

Solution Architecture

Architecture
  • Alexa Skill: This is the skill which gets deployed through the Alexa Developer console. This is the starting point of the flow and handles the voice command to function execution translation.
  • AWS Lambda Function: This is a lambda function with a NodeJS runtime.The Alexa skill calls the Lambda function based on the different voice commands which user speaks to Alexa. Within the Lambda Function, there are different intents which get called based on what voice command user speaks to Alexa. For e.g if user asks to get the top lead, the Get query function from the Lambda function is called which calls the custom wrapper API to query the data from CRM.
  • Custom Wrapper API: This is a custom REST API built with Python and Flask. The API acts as a wrapper around the CRM REST API endpoints. It exposes various REST API endpoints to Query Data, Create records.The custom API endpoints when called, in the back-end, call the CRM API endpoints to perform the data tasks. Technically Lambda can directly call the CRM API but I developed this custom wrapper API and put it in between Lambda and the CRM. The idea is to have more control on what data from CRM is sent back to Lambda for the Alexa skill to consume.The wrapper AI code is built to work with any CRM API with some little changes. As long as the CRM has a REST API enabled, this custom API can communicate with the CRM.
  • REST API in CRM: This is the REST API provided by the CRM application. The endpoints differ based on different CRM application. Here I have used SFDC as an example. Based on what objects and functions we want to enable for the functionality, respective API endpoint need to be used from the CRM and called through the custom wrapper API.
  • Authentication Methods: There are authentication steps added at various stages.The custom wrapper API uses the same credentials from CRM application to authenticate. In the Lambda function, the same authentication details is passed to the wrapper API endpoints. I will go into more details in upcoming post.

Solution Flow

Flow
Alexa... ask my assistant to get my top lead
  1. Once user asks with the voice command, it invokes the specific skill in the back end
  2. The skill is associated with a Lambda function on the back end. The Lambda function gets triggered
  3. The Lambda function consist of a set of Intents which are tied to each of the separate voice commands. For this example, it triggers the intent to query the Lead
  4. The intent executes a function which calls the ‘queryAll’ endpoint from the wrapper API. It also passes the Query parameters for the specific data query and the Authentication details needed. For this example the query parameters passed will be the query to get the lead data from CRM
  5. In the wrapper API, the corresponding function gets executed which is called by the ‘queryAll’ endpoint.
  6. The function sends a GET request to the CRM API and passes the query parameters received from the Lambda function. It also passes the Authentication details to establish the session with CRM API and receive the data response
  7. The wrapper API parses the response from the CRM app and sends it back to the Lambda Function. The Lambda function reads the response and converts the response to a Conversation response format which is specified in the Intent
  8. The Alexa skill gets the Conversational response from the Lambda function and speaks back the response to the user
I found this lead which I think you should work on, Name is Testing C, test@email.com

More Extensions to the Functionality

  • Better Authentication mechanism
  • Provide more CRM functions as voice commands
  • Make the Custom Wrapper API more dynamic to support a plug and play type of behavior with any CRM application

In Posts to come

  • Describe the Custom wrapper API details and how to deploy the API
  • Describe the Lambda function and the Alexa skill. Describe how to setup your own Alexa skill pointing to the Lambda function

Conclusion

--

--

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
Amlan Chakladar

Amlan Chakladar

Cloud architect and DevOps engineer. Love to code and develop new stuff. A nerd by nature.