index.js
function (request, slotName, slotType, value, id) {
		'use strict';
		if (!request) {
			throw 'request must be specified to add entity resolution';
		}
		if (!slotName) {
			throw 'slotName must be specified to add entity resolution';
		}
		if (!value) {
			throw 'value must be specified to add entity resolution';
		}
		
		if (!request.request.intent.slots[slotName]) {
			request.request.intent.slots[slotName] = {name: slotName, value: value};
		}
		
		const authority = "amzn1.er-authority.echo-sdk." + this.appId + "." + slotType;
		var valueAdded = false;
		if (request.request.intent.slots[slotName].resolutions) {
			request.request.intent.slots[slotName].resolutions.resolutionsPerAuthority.forEach(rpa => {
				if (!valueAdded && (rpa.authority === authority)) {
					rpa.values.push({
						"value": {
							"name": value,
							"id": id
						}
					});
					valueAdded = true;
				}
			});
		} else {
			request.request.intent.slots[slotName].resolutions = {
				"resolutionsPerAuthority": []
			};
		}
		if (!valueAdded) {
			request.request.intent.slots[slotName].resolutions.resolutionsPerAuthority.push({
				"authority": authority,
				"status": {
					"code": "ER_SUCCESS_MATCH"
				},
				"values": [
					{
						"value": {
							"name": value,
							"id": id
						}
					}
				]
			});
		}
		
		return request;
	}
function (request, slotName, slotType, value, id) {
		'use strict';
		if (!request) {
			throw 'request must be specified to add entity resolution';
		}
		if (!slotName) {
			throw 'slotName must be specified to add entity resolution';
		}
		if (!value) {
			throw 'value must be specified to add entity resolution';
		}
		
		if (!request.request.intent.slots[slotName]) {
			request.request.intent.slots[slotName] = {name: slotName, value: value};
		}
		
		const authority = "amzn1.er-authority.echo-sdk." + this.appId + "." + slotType;
		var valueAdded = false;
		if (request.request.intent.slots[slotName].resolutions) {
			request.request.intent.slots[slotName].resolutions.resolutionsPerAuthority.forEach(rpa => {
				if (!valueAdded && (rpa.authority === authority)) {
					rpa.values.push({
						"value": {
							"name": value,
							"id": id
						}
					});
					valueAdded = true;
				}
			});
		} else {
			request.request.intent.slots[slotName].resolutions = {
				"resolutionsPerAuthority": []
			};
		}
		if (!valueAdded) {
			request.request.intent.slots[slotName].resolutions.resolutionsPerAuthority.push({
				"authority": authority,
				"status": {
					"code": "ER_SUCCESS_MATCH"
				},
				"values": [
					{
						"value": {
							"name": value,
							"id": id
						}
					}
				]
			});
		}
		
		return request;
	}
function ( request , slotName , slotType , value , id ) { 'use strict' ; if ( ! request ) { throw 'request must be specified to add entity resolution' ; } if ( ! slotName ) { throw 'slotName must be specified to add entity resolution' ; } if ( ! value ) { throw 'value must be specified to add entity resolution' ; } if ( ! request . request . intent . slots [ slotName ] ) { request . request . intent . slots [ slotName ] = { name : slotName , value : value } ; } const authority = "amzn1.er-authority.echo-sdk." + this . appId + "." + slotType ; var valueAdded = false ; if ( request . request . intent . slots [ slotName ] . resolutions ) { request . request . intent . slots [ slotName ] . resolutions . resolutionsPerAuthority . forEach ( rpa => { if ( ! valueAdded && ( rpa . authority === authority ) ) { rpa . values . push ( { "value" : { "name" : value , "id" : id } } ) ; valueAdded = true ; } } ) ; } else { request . request . intent . slots [ slotName ] . resolutions = { "resolutionsPerAuthority" : [ ] } ; } if ( ! valueAdded ) { request . request . intent . slots [ slotName ] . resolutions . resolutionsPerAuthority . push ( { "authority" : authority , "status" : { "code" : "ER_SUCCESS_MATCH" } , "values" : [ { "value" : { "name" : value , "id" : id } } ] } ) ; } return request ; }
Adds an entity resolution to the given request.
@param {object} request The intent request to modify.
@param {string} slotName The name of the slot to add the resolution to. If the slot does not exist it is added.
@param {string} slotType The type of the slot.
@param {string} value The value of the slot.
@param {string} id The id of the resolved entity.
@return {object} the given intent request to allow chaining.
Adds an entity resolution to the given request .