Note: The rest of this readme assumes you have your developer environment ready to go and that you have some familiarity with CLI (Command Line Interface) Tools, AWS, and the ASK Developer Portal.
index.js
- Microservice Logic for sending notifications to the hosted on Rocket Chat Alexa Skill
- Node.js (> v8.10)
- Register for an AWS Account
- Register for an Amazon Developer Account
- Install and Setup ASK CLI
- Rocket Chat Server updated to Release 1.0.0-rc3 or later
- Setup a Rocket Chat Alexa Skill
-
Clone the repository.
$ git clone https://github.com/RocketChat/alexa-rocketchat-notification.git
-
Navigating into the repository's root folder.
$ cd alexa-rocketchat-notification
-
Install npm dependencies by running the npm command:
npm install
$ npm install
ASK CLI will create the skill and the lambda function for you. The Lambda function will be created in us-east-1 (Northern Virginia)
by default.
-
Log into your AWS Account and create a new Lambda function. Make sure to choose Runtime as
Node.js 10.x
. In the permissions create a new role, and then go to the IAM console and add policies to access DynamoDB and Cloudwatch. -
Once the function is created, increase the Timeout of the function to 15 minutes in the basic settings down below. Also set a few Environment variables values.
e.g:
- SERVER_URL https://yourservername.rocket.chat
- DDB_NAME (The name of the Dynamo DB table being used by your skill)
- CLIENT_ID (The client ID from your Alexa Developer Console in the Permissions Section of the skill)
- CLIENT_SECRET (The client secret from your Alexa Developer Console in the Permissions Section of the skill)
- API_REGION (For North/South America use US, For Europe/India use EU, For Japan use FE)
-
Log into your AWS Account and go to cloudwatch.
-
Click on Rules -> Create Rule. Give it a fixed rate of 7 minutes. Every 7 minutes it will run the lambda function to check for new messages. We can run it every minute but the minimum expiry time for an Alexa Notification is 5 minutes. So we will check for notification every 7 minutes.
-
Click on Add Target. Choose the Lambda function you created above. Click on configure details and give it a name. Click create rule.
-
The above setup is an external microservice which takes care of sending notifications. But we still need to add the ability for user to sign up for notifications. Please follow the notification steps given in the main repo for adding it to the skill.
-
Also it will be worth checking out this video to get insights
-
Click on Add Target. Choose the Lambda function you created above. Click on configure details and give it a name. Click create rule.
-
Before testing, you must make sure that Account Linking with the main skill has completed. Go to alexa.amazon.com or your alexa app and click account linking to complete the link. And also ensure that you have given the permission to receive notifications.
-
To test, you just need to receive a message, and you'll soon receive a notification on your Alexa Device. Your Alexa Device will light up in green color with a chime sound. You can say "Alexa, what are my notifications." to hear them.
-
./index.js
You can change the notification expiry time, or pre-configured output text.
See the Proactive Events API Documentation for more information.
-
Rocket.Chat API Documentation
The REST API allows you to control and extend Rocket.Chat with ease - REST API Documentation
-
Axios Documentation
Promise based HTTP client for the browser and node.js - Github Page
-
Proactive Events API Documentation
You can use the Proactive Events API to send events to Alexa. The events represent factual data that might interest a customer. Upon receiving an event, Alexa proactively delivers the information to customers subscribed to receive these events. This API currently supports one proactive channel, Alexa Notifications - Documentation Page
-
Dabble Lab Video on Proactive Events
This video explains the proactive events API and setup instructions with example - Alexa Notifications with Proactive Events - Dabble Lab #125
-
ASK Utils Proactive Events
This NPM package helps send proactive events in a much simpler way - ASK Utils Proactive Events
Keep an eye on our issues. We are just beginning and will surely appreciate all the help we can get. All ideas are welcome. Feel free to join the discussion in our Alexa channel - Rocket.Chat Alexa Channel