Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
machine:
node:
version: 7.2.0

test:
override:
- echo 'todo'
9 changes: 5 additions & 4 deletions dist/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ var MyAction = function () {
// create a google action server
this.agent = new _googleActionsServer.ActionServer();

this.agent.setGreetings(['Hello, my name is Wassim (aka Maneki Nekko on the Internet). \n Congratulations! This is your first action on Google Actions and Google Home. \n Tell me somthing and I will repeat it']);
this.agent.setGreetings(['Hello, my name is Wassim (aka Maneki Nekko on the Internet).\n Congratulations! This is your first action on Google Actions and Google Home.\n Tell me somthing and I will repeat it.']);

this.agent.setConversationMessages(['Tell me something else', 'Try something else', 'Try again', 'Come on, try again']);
this.agent.setConversationMessages(['Tell me something else.', 'Try something else.', 'Try again.', 'Come on, try again.']);

this.assistant = null;
}
Expand Down Expand Up @@ -60,13 +60,14 @@ var MyAction = function () {
this.agent.welcome(this.welcomeIntent.bind(this));
this.agent.intent(_googleActionsServer.ActionServer.intent.action.TEXT, this.textIntent.bind(this));
this.agent.intent('my.deeplink.intent', this.dateIntent.bind(this));
this.agent.listen();
return this.agent.listen();
}
}]);

return MyAction;
}();

// instantiate


new MyAction().listen();
module.exports = new MyAction().listen();
19 changes: 10 additions & 9 deletions lib/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ class MyAction {
this.agent = new ActionServer();

this.agent.setGreetings([
`Hello, my name is Wassim (aka Maneki Nekko on the Internet).
Congratulations! This is your first action on Google Actions and Google Home.
Tell me somthing and I will repeat it`
`Hello, my name is Wassim (aka Maneki Nekko on the Internet).
Congratulations! This is your first action on Google Actions and Google Home.
Tell me somthing and I will repeat it.`
]);

this.agent.setConversationMessages([
`Tell me something else`,
`Try something else`,
`Try again`,
`Come on, try again`
`Tell me something else.`,
`Try something else.`,
`Try again.`,
`Come on, try again.`
]);

this.assistant = null;
Expand Down Expand Up @@ -56,8 +56,9 @@ class MyAction {
this.agent.welcome(this.welcomeIntent.bind(this));
this.agent.intent(ActionServer.intent.action.TEXT, this.textIntent.bind(this));
this.agent.intent('my.deeplink.intent', this.dateIntent.bind(this));
this.agent.listen();
return this.agent.listen();
}
}

// instantiate
(new MyAction()).listen();
module.exports = (new MyAction()).listen();
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
"type": "git",
"url": "git@github.com:manekinekko/google-actions-starter.git"
},
"devDependencies": {},
"scripts": {
"start": "npm run build && npm run server",
"server": "nodemon dist/action.js",
"ngrok": "ngrok http 8080",
"build": "babel lib -d dist",
"build:watch": "npm run build -- -w",
"test": "npm run build && mocha --timeout 5000",
"action:simulate": "gactions simulate",
"action:preview": "node ./scripts/preview_action.js",
"action:config": "node ./scripts/update_action_config.js -f",
Expand All @@ -33,7 +33,12 @@
"release": "npm run build && npm version patch && git push --tags && git push && npm publish"
},
"dependencies": {
"@manekinekko/google-actions-server": "^2.0.4"
"@manekinekko/google-actions-server": "dblock/google-actions-server#tests"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you use @manekinekko/google-actions-server#2.0.6 instead?

},
"devDependencies": {
"mocha": "^3.2.0",
"chai": "^3.5.0",
"supertest": "^3.0.0"
},
"keywords": [
"google",
Expand Down
75 changes: 75 additions & 0 deletions test/test_action.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
'use strict';

var chai = require('chai');
var expect = chai.expect;
var request = require('supertest');

describe('MyAction', function() {
var myAction;

beforeEach(function() {
myAction = require('../dist/action');
});

afterEach(function() {
myAction.close();
});

it('responds to an invalid payload', function() {
return request(myAction)
.post('/')
.expect(400).then(function(response) {
expect(response.text).to.eql('Action Error: Missing inputs from request body');
});
});

it('responds to action.MAIN', function() {
return request(myAction)
.post('/')
.send({
inputs: [{
intent: 'assistant.intent.action.MAIN'
}]
})
.expect(200).then(function(response) {
expect(response.body).to.eql({
conversation_token: '{"state":null,"data":{}}',
expect_user_response: true,
expected_inputs: [{
input_prompt: {
initial_prompts: [{
ssml: `Hello, my name is Wassim (aka Maneki Nekko on the Internet).
Congratulations! This is your first action on Google Actions and Google Home.
Tell me somthing and I will repeat it.`
}],
no_input_prompts: [{
ssml: "Sorry"
}]
},
possible_intents: [{
intent: "assistant.intent.action.TEXT"
}]
}]
})
});
});

it('repeats text in action.TEXT', function() {
return request(myAction)
.post('/')
.send({
inputs: [{
intent: 'assistant.intent.action.TEXT',
raw_inputs: [{
query: "testing 123"
}]
}],
})
.expect(200).then(function(response) {
expect(response.body.expected_inputs[0].input_prompt.initial_prompts[0].ssml).to.eql(`
I heard testing 123.
Tell me something else.
`)
});
});
});