Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

alexa-message-builder

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

alexa-message-builder - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

75

lib/index.js

@@ -101,2 +101,76 @@ 'use strict'

addDialogDelegate(updatedIntent) {
if (!this.template.response.directives) {
this.template.response.directives = []
}
const directive = {
type: 'Dialog.Delegate'
}
if (updatedIntent) {
directive.updatedIntent = updatedIntent
}
this.template.response.directives.push(directive)
return this
}
addDialogElicitSlot(slot, updatedIntent) {
if (!this.template.response.directives) {
this.template.response.directives = []
}
const directive = {
type: 'Dialog.ElicitSlot',
slotToElicit: slot
}
if (updatedIntent) {
directive.updatedIntent = updatedIntent
}
this.template.response.directives.push(directive)
return this
}
addDialogConfirmSlot(slot, updatedIntent) {
if (!this.template.response.directives) {
this.template.response.directives = []
}
const directive = {
type: 'Dialog.ConfirmSlot',
slotToConfirm: slot
}
if (updatedIntent) {
directive.updatedIntent = updatedIntent
}
this.template.response.directives.push(directive)
return this
}
addDialogConfirmIntent(updatedIntent) {
if (!this.template.response.directives) {
this.template.response.directives = []
}
const directive = {
type: 'Dialog.ConfirmIntent'
}
if (updatedIntent) {
directive.updatedIntent = updatedIntent
}
this.template.response.directives.push(directive)
return this
}
keepSession() {

@@ -108,2 +182,3 @@ this.template.response.shouldEndSession = false

get() {

@@ -110,0 +185,0 @@ return this.template

2

package.json
{
"name": "alexa-message-builder",
"version": "1.1.0",
"version": "1.2.0",
"description": "Simple builder for Alexa replies.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -242,2 +242,104 @@ /* global describe, it, expect */

})
describe('dialog directives', () => {
const intent = {
name: 'TestIntent',
confirmationStatus: 'None',
slots: { }
}
describe('addDialogDelegate', () => {
it('should be a function', () => {
const message = new AlexaMessageBuilder()
expect(typeof message.addDialogDelegate).toBe('function')
})
it('should add a delegate directive', () => {
const message = new AlexaMessageBuilder().addDialogDelegate(intent)
expect(message.get()).toEqual({
version: '1.0',
response: {
shouldEndSession: true,
directives: [
{
type: 'Dialog.Delegate',
updatedIntent: intent
}
]
}
})
})
})
describe('addDialogElicitSlot', () => {
it('should be a function', () => {
const message = new AlexaMessageBuilder()
expect(typeof message.addDialogElicitSlot).toBe('function')
})
it('should add a elicit slot directive', () => {
const message = new AlexaMessageBuilder().addDialogElicitSlot('slotname', intent)
expect(message.get()).toEqual({
version: '1.0',
response: {
shouldEndSession: true,
directives: [
{
type: 'Dialog.ElicitSlot',
slotToElicit: 'slotname',
updatedIntent: intent
}
]
}
})
})
})
describe('addDialogConfirmSlot', () => {
it('should be a function', () => {
const message = new AlexaMessageBuilder()
expect(typeof message.addDialogConfirmSlot).toBe('function')
})
it('should add a confirm slot directive', () => {
const message = new AlexaMessageBuilder().addDialogConfirmSlot('slotname', intent)
expect(message.get()).toEqual({
version: '1.0',
response: {
shouldEndSession: true,
directives: [
{
type: 'Dialog.ConfirmSlot',
slotToConfirm: 'slotname',
updatedIntent: intent
}
]
}
})
})
})
describe('addDialogConfirmIntent', () => {
it('should be a function', () => {
const message = new AlexaMessageBuilder()
expect(typeof message.addDialogConfirmIntent).toBe('function')
})
it('should add a delegate directive', () => {
const message = new AlexaMessageBuilder().addDialogConfirmIntent(intent)
expect(message.get()).toEqual({
version: '1.0',
response: {
shouldEndSession: true,
directives: [
{
type: 'Dialog.ConfirmIntent',
updatedIntent: intent
}
]
}
})
})
})
})
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc