Skip to content

My Jarvis is an Alexa skill that can remember and recall memories from users, providing more contextual answers. It utilizes the Redis Agent Memory Server as a memory layer to provide instant-like responses, making your Alexa device appear more human-like in conversation.

License

Notifications You must be signed in to change notification settings

redis-developer/my-jarvis-alexa-skill

Repository files navigation

Adding memory capabilities to Amazon Alexa with Redis Agent Memory Server

Amazon Alexa is arguably one of the most popular virtual assistant devices available in many homes worldwide. It enables users to automate mundane tasks, such as setting timers, playing music, and making phone calls. It would be great if only one thing weren't true—it doesn't really remember anything. Whatever conversations you have with Alexa, it won't be used in future conversations as context for more elaborate, polished, and well-tailored answers. Therefore, repeating yourself with Alexa is a common occurrence.

This repository changes everything by providing you with a memory-enabled skill for Amazon Alexa, capable of reusing previous memories and providing a more contextual conversation with users, allowing them to use Alexa in a more impactful manner.

my-jarvis-interaction.png

This is implemented as an Alexa skill using Java. The behavior of the skill is deployed as an AWS Lambda function, which in turn manages memories using the Redis Agent Memory Server. The build and deployment of the Alexa skill is fully automated using Bash scripts, Terraform, and the ASK CLI.

🧑🏻‍💻 Account requirements

Account Description
AWS account You need to have an AWS account with permissions to create resources like lambda functions, IAM roles, EC2 instances, security groups, and CloudWatch triggers.
Amazon developer account You need to have a Amazon developer account to create and deploy Alexa skills. You must associate this account with the email you have registered your Alexa devices.
Redis Cloud You need to have an account with Redis Cloud to create a database. This database is required as the persistent store for the Redis Agent Memory Server.

📋 Software requirements

Software Description
Java 21+ Since the Lambda function is implemented in Java, you need JDK 21+ to compile and build it.
Maven 3.9+ Maven is required to manage the dependencies and package the JAR file with the code.
Terraform Terraform is used to create and destroy resources on AWS, as well as on Redis Cloud.
AWS CLI You need to have the AWS CLI installed locally to configure your AWS credentials.
ASK CLI You need to have the ASK CLI installed locally to package and build your the skill.
JQ JSON files are parsed during deployment, and JQ is used for that specific task.
SED SED is used in the bash scripts to find and replace variables in different files.

‍💻 Preparing for deployment

This repository provides scripts that automate the build, deployment, and undeployment of the Alexa skill, along with its required resources. Everything is fully automated, but it requires that you have your accounts configured correctly in the machine you will use for deployment.

Preparing your AWS account

This Alexa skill requires some backend resources to be created so it can function correctly. These resources will primarily be hosted on AWS, including Lambda functions, EC2 instances, and other services. You need to configure your AWS account locally before executing the deployment script.

  1. Install: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
  2. Configure credentials: aws configure (must have access to deploy Lambda, IAM, etc.)

Preparing your Amazon developer account

During deployment, a new skill called My Jarvis will be created for you. However, you need to ensure that your credentials are all set up with your ASK CLI. Follow these steps to configure your credentials.

  1. Install: https://developer.amazon.com/en-US/docs/alexa/smapi/ask-cli-command-reference.html#install
  2. Configure: ask configure (must be linked to your Amazon Developer account)

Preparing your Redis Cloud account

This Alexa skill uses the Redis Agent Memory Server to provide memory capabilities. The memory server requires a Redis database to store and retrieve data. You must use Redis Cloud for this purpose. Follow these steps to make your Redis Cloud account accessible for Terraform.

  1. Obtain your Redis Cloud API access and secret key from your Redis Cloud account.
  2. Export them as environment variables:
export REDISCLOUD_ACCESS_KEY=<THIS_IS_GOING_TO_BE_YOUR_API_ACCOUNT_KEY>
export REDISCLOUD_SECRET_KEY=<THIS_IS_GOING_TO_BE_ONE_API_USER_KEY>

Terraform configuration

During deployment, resources will be created by Terraform based on the variables you provide. You need to create a variables file with the correct information so the deployment can happen successfully.

  1. Create a Terraform variables file by copying the example provided:
cp infrastructure/terraform/terraform.tfvars.example infrastructure/terraform/terraform.tfvars
  1. Edit infrastructure/terraform/terraform.tfvars to set the following required variables:
Variable Description
payment_card_type The credit card associated with your Redis Cloud account (e.g., "Visa").
payment_card_last_four The last four digits of the credit card associated with your Redis Cloud account (e.g., "1234").
essentials_plan_cloud_provider The cloud provider where you want your Redis database to be hosted (e.g., "AWS").
essentials_plan_cloud_region The region where you want your Redis database to be hosted (e.g., "us-east-1").
openai_api_key The OpenAI API key used by the Alexa skill to produce answers and the Agent Memory Server to manage memories.

You can leave the other variables as they are unless you want to customize them.

⚙️ Installation & Deployment

Once all prerequisites and configuration are in place, installation is a single step:

./deploy.sh

Please note that when the script finishes executing, it will print several output values, including the endpoint of the agent memory server, the ARN of the Lambda function created, and an SSH command that you can use to verify the agent memory server. However, it may take several more minutes for the agent memory server to be reachable. Use the provided endpoint to verify that the agent memory server is operational. Alternatively, you can use the skill itself to check this by saying:

"Alexa, ask my jarvis to check the memory server"

🪓 Teardown

To remove all deployed resources and the skill:

./undeploy.sh

📁 Project Structure

my-jarvis-alexa-skill/
├── lambda/                  # Java source code for the Alexa skill (AWS Lambda)
│   ├── pom.xml              # Maven build file
│   └── src/                 # Java source and resources
├── infrastructure/          # Terraform code for AWS infrastructure
├── skill-package/           # Alexa skill manifest and assets
├── interactionModels/       # Alexa interaction models (intents, slots, etc.)
├── deploy.sh                # Deployment script
├── undeploy.sh              # Teardown script
└── README.md                # This file

🗣️ Usage

Invoke your Alexa device with the invocation 'my jarvis' and try commands like:

  • "Alexa, tell my javis to remember that my favorite programming language is Java."
  • "Alexa, ask my jarvis to recall if Java is my favorite programming language."
  • "Alexa, tell my jarvis to remember I have a doctor appointment next Monday at 10 AM."
  • "Alexa, ask my jarvis to suggest what should I do for my birthday party."

📄 License

This project is licensed under the MIT License. See LICENSE for details.

About

My Jarvis is an Alexa skill that can remember and recall memories from users, providing more contextual answers. It utilizes the Redis Agent Memory Server as a memory layer to provide instant-like responses, making your Alexa device appear more human-like in conversation.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published