BotBuilderCommunity/botbuilder-community-js

unable to use dynamodb storage - what are the database requirements?

Closed this issue · 1 comments

I'm trying to use the dynamo storage package in this project, but whenever I use it in my botkit-based application, I get the following error:

  ValidationException: The provided key element does not match the schema

This is how I'm using this package within my 'bot.js' file:

 const {DynamoDBStorage }= require('@botbuildercommunity/storage-dynamodb');
 const dynamoDBStorage = new DynamoDBStorage( 
	process.env.DYNAMODB_TABLE, 
	process.env.AWS_REGION, 
	{ 
		accessKeyId: process.env.AWS_ACCESS_KEY_ID,  
		secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
	}
	);
  const adapter = new WebAdapter({});

  const controller = new Botkit({
        webhook_uri: '/api/messages',
        adapter: adapter,
        storage: dynamoDBStorage
  });
  ....  etc

I suspect that I did not create the Dynamo database with the required schema, but there is no documentation on what the requirements for this database are. I've created a partition key called 'id'. Could you please clarify what is needed? Or, if you have any other suggestions on what is wrong with the above code, please let me know. Thanks!

After inspecting the source code for this adapter, the response to my question seems to be that the database should be created with a hash key named 'key'. Since I had created my Dynamo db using 'id' as the hash, my code did not work. This database requirement should certainly be part of the documentation for this storage adapter (otherwise the adapter is unusable without first reading the source).