This assumes you've already configured the aws-sdk package to interact with your Lambda, so extending your context store to DynamoDB is a drop-in solution. If you are hosting your SmartApp as an AWS Lambda, this DynamoDB context store makes perfect sense. Amazon AWS DynamoDBĪvailable as a node package on NPM or fork on GitHub.
To get started with our context store example below, we will add a compatible ContextStore plugin that will persist these tokens (among other things) to a database. If you'd like to add a custom context store plugin, please consider contributing. Note that there is no in-memory context store you must use a context store plugin.
This token includes a refresh_token, and will automatically be refreshed by the SDK when necessary.
If you are making out-of-band API calls on behalf of a user's installed app, you will need to use the 24-hour access token that is supplied after the INSTALL and UPDATE lifecycles. These access tokens are not able to be refreshed and should not be stored. These user tokens are ephemeral and last 5 minutes. Making API Calls Outside of an EVENT Handlerīy default, the SmartApp SDK will facilitate API calls on behalf of a user within the EVENT lifecycle. page ( 'mainPage', ( context, page, configData ) => ) on the SmartApp object. enableEventLogging ( 2 ) // logs all lifecycle event requests and responses as pretty-printed JSON. InstallationĬonst SmartApp = require ( ) const express = require ( 'express' ) const server = express ( ) const PORT = 8080 /* Define the SmartApp */ const smartapp = new SmartApp ( ). To learn more about SmartApps, including choosing the best hosting solution for your SmartApp, visit the SmartApp developer documentation. Webhook SmartApps are any publicly-accessible web server that will receive a POST request payload.ĪWS Lambda SmartApps are hosted in the Amazon Web Services cloud and are invoked by ARN instead of a public-DNS address. There are two distinct options for hosting your SmartApp: AWS Lambda and Webhook. Creating a SmartApp allows you to control and get status notifications from SmartThings devices using the SmartThings API. Your application will respond to lifecycle events sent from SmartThings to perform actions on behalf of your users and will execute any scheduled tasks that you have created in the SmartApp. The complexity of execution and the number of expected users will need to be examined to understand the hardware or execution requirements your app needs to handle. All of the SmartApp execution will happen on the server or Lambda that you control.
SmartApps are custom applications that execute outside of the SmartThings Platform.