Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Transactions for Google Assistant Conversational Actions #892

Merged
merged 28 commits into from Feb 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e5db5a0
:construction: Introduce docs for Google Conversational Actions
rubenaeg Jan 7, 2021
cd221eb
Merge remote-tracking branch 'upstream/master'
rubenaeg Jan 7, 2021
7a300fb
:construction: Add intermediate state
rubenaeg Jan 12, 2021
ad5e575
:pencil: Add docs for Push Notifications for Conversational Actions
rubenaeg Jan 14, 2021
282cef4
:sparkles: Add transactions to Conversational Actions WIP
aswetlow Jan 15, 2021
549741f
:sparkles: Add Google Action Transactions example projects
aswetlow Jan 15, 2021
72c5f96
:pencil: Add docs for Scenes
rubenaeg Jan 15, 2021
d9016f7
:sparkles: Add CompletePurchase to digital goods transactions (wip)
aswetlow Jan 18, 2021
ca225fb
:rewind: Revert changes in example
aswetlow Jan 19, 2021
e61629b
:recycle: Clean up Account Linking Conv Example
rubenaeg Jan 20, 2021
0f29aef
:construction: Introduce docs for Google Conversational Actions
rubenaeg Jan 7, 2021
f6ee5b1
:construction: Add intermediate state
rubenaeg Jan 12, 2021
4a93e79
:pencil: Add docs for Push Notifications for Conversational Actions
rubenaeg Jan 14, 2021
cc7530e
:pencil: Add docs for Scenes
rubenaeg Jan 15, 2021
4501c4e
:recycle: Clean up Account Linking Conv Example
rubenaeg Jan 20, 2021
d1734c7
Merge branch 'master' of github.com:rubenaeg/jovo-framework
rubenaeg Jan 20, 2021
113fdf0
:pencil: Add Simple Response Docs
rubenaeg Jan 20, 2021
22c13af
🔧 Update digital goods example
aswetlow Jan 20, 2021
1643926
:pencil: Add Conversational Actions Transactions Docs
rubenaeg Jan 22, 2021
1d63b0f
Merge branch 'master' into ca-transactions
rubenaeg Jan 22, 2021
0af04f0
:recycle: Update Digital Transactions Example
rubenaeg Jan 22, 2021
7ad28c8
:sparkles: Add Digital Transactions Example for Javascript
rubenaeg Jan 22, 2021
ceff3a9
:recycle: Update Physical Transactions Example
rubenaeg Jan 22, 2021
a8cadac
:sparkles: Add Physical Transaction Javascript Example
rubenaeg Jan 22, 2021
41bd2b7
:wrench: Update package.json for Javascript examples
rubenaeg Jan 22, 2021
bb1dc58
:recycle: Add more convenient check method
aswetlow Jan 27, 2021
e137523
:pencil: Adjust docs for Conversational Actions
rubenaeg Jan 29, 2021
217648e
:bug: Fix package.json
aswetlow Feb 3, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -31,7 +31,7 @@ app.setHandler({

MyNameIsIntent() {
console.log(this.$request.getInputs());

this.tell('Hey ' + this.$inputs.name.value + ', nice to meet you!');
},
});
Expand Down
@@ -0,0 +1,70 @@
{
"invocation": "my test app",
"intents": [
{
"name": "PushNotificationsIntent",
"phrases": ["notify me"]
},
{
"name": "PushNotificationsClickedIntent",
"phrases": []
}
],
"googleAssistant": {
"custom": {
"scenes": {
"PushNotificationsScene": {
"intentEvents": [
{
"intent": "PushNotificationsIntent",
"transitionToScene": "PushNotificationScene_Notifications"
}
]
},
"PushNotificationsScene_Notifications": {
"conditionalEvents": [
{
"condition": "scene.slots.status == \"FINAL\" && (session.params.NotificationsSlot_PushNotificationsClickedIntent.permissionStatus == \"PERMISSION_GRANTED\" || session.params.NotificationsSlot_PushNotificationsClickedIntent.permissionStatus == \"ALREADY_GRANTED\")",
"handler": {
"webhookHandler": "Jovo"
}
},
{
"condition": "scene.slots.status == \"FINAL\" && session.params.NotificationsSlot_PushNotificationsClickedIntent.permissionStatus != \"PERMISSION_GRANTED\" && session.params.NotificationsSlot_PushNotificationsClickedIntent.permissionStatus != \"ALREADY_GRANTED\"",
"handler": {
"webhookHandler": "Jovo"
}
}
],
"slots": [
{
"commitBehavior": {
"writeSessionParam": "NotificationsSlot_PushNotificationsClickedIntent"
},
"config": {
"intent": {
"intentName": "PushNotificationsClickedIntent"
}
},
"defaultValue": {
"sessionParam": "NotificationsSlot_PushNotificationsClickedIntent"
},
"name": "NotificationsSlot_PushNotificationsClickedIntent",
"required": true,
"type": {
"name": "actions.type.Notifications"
}
}
]
}
},
"global": {
"actions.intent.MAIN": {
"handler": {
"webhookHandler": "Jovo"
}
}
}
}
}
}
@@ -0,0 +1,36 @@
{
"name": "jovo-examples-googleassistantconv-push-notifications",
"version": "3.0.0",
"description": "A sample voice app that works with the Jovo Framework",
"main": "src/index.js",
"dependencies": {
"jovo-db-filedb": "^3.1.3",
"jovo-framework": "^3.3.0",
"jovo-platform-googleassistantconv": "^3.1.3",
"jovo-plugin-debugger": "^3.1.3"
},
"devDependencies": {
"gulp": "^4.0.2",
"gulp-install": "^1.1.0",
"gulp-run-command": "0.0.10",
"gulp-zip": "^5.0.1",
"jest": "^26.0.1"
},
"scripts": {
"tsc": "node -v",
"test": "jest",
"bundle": "gulp --gulpfile node_modules/jovo-framework/gulpfile.js --cwd ./",
"start": "cd src && node index.js --webhook",
"launch": "npm start -- --launch"
},
"repository": {
"type": "git",
"url": "git+https://github.com/jovotech/jovo-sample-voice-app-nodejs.git"
},
"author": "Jovo",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/jovotech/jovo-sample-voice-app-nodejs/issues"
},
"homepage": "https://github.com/jovotech/jovo-sample-voice-app-nodejs#readme"
}
@@ -0,0 +1,10 @@
// ------------------------------------------------------------------
// JOVO PROJECT CONFIGURATION
// ------------------------------------------------------------------

module.exports = {
googleAction: {
projectId: '<PROJECT ID>',
},
endpoint: '${JOVO_WEBHOOK_URL}',
};
@@ -0,0 +1,57 @@
'use strict';

const { App } = require('jovo-framework');
const {
GoogleAssistant,
PushNotificationsApi,
} = require('jovo-platform-googleassistantconv');
const { JovoDebugger } = require('jovo-plugin-debugger');
const { FileDb } = require('jovo-db-filedb');

// ------------------------------------------------------------------
// APP INITIALIZATION
// ------------------------------------------------------------------

const app = new App();

app.use(new GoogleAssistant(), new JovoDebugger(), new FileDb());

// ------------------------------------------------------------------
// APP LOGIC
// ------------------------------------------------------------------

app.setHandler({
LAUNCH() {
this.$googleAction.setNextScene('PushNotificationsScene');
this.ask('If you want me to send you notifications, just say "notify me".');
},

PushNotificationsClickedIntent() {
this.tell('Hello World!');
},

async ON_PERMISSION() {
if (
this.$googleAction.isPermissionGranted() ||
this.$googleAction.isPermissionAlreadyGranted()
) {
const credentials = require('../credentials.json');
const reminderUserId = this.$googleAction.getNotificationsUserId();

const api = new PushNotificationsApi(credentials);

await api.sendPushNotification({
userId: reminderUserId,
intent: 'PushNotificationsClickedIntent',
title: 'Click me!',
locale: 'en',
});

this.ask('Great!');
} else {
this.ask('Ok.');
}
},
});

module.exports = { app };
@@ -0,0 +1,17 @@
// ------------------------------------------------------------------
// APP CONFIGURATION
// ------------------------------------------------------------------

module.exports = {
logging: true,

intentMap: {
'AMAZON.StopIntent': 'END',
},

db: {
FileDb: {
pathToFile: '../db/db.json',
},
},
};
@@ -0,0 +1,27 @@
'use strict';

const { ExpressJS, Lambda, Webhook } = require('jovo-framework');
const { app } = require('./app.js');

// ------------------------------------------------------------------
// HOST CONFIGURATION
// ------------------------------------------------------------------

// ExpressJS (Jovo Webhook)
if (process.argv.indexOf('--webhook') > -1) {
const port = process.env.JOVO_PORT || 3000;
Webhook.jovoApp = app;

Webhook.listen(port, () => {
console.info(`Local server listening on port ${port}.`);
});

Webhook.post('/webhook', async (req, res) => {
await app.handle(new ExpressJS(req, res));
});
}

// AWS Lambda
exports.handler = async (event, context, callback) => {
await app.handle(new Lambda(event, context, callback));
};
26 changes: 11 additions & 15 deletions examples/javascript/02_googleassistantconv/scenes/src/index.js
@@ -1,25 +1,21 @@
'use strict';
const {
Webhook,
ExpressJS,
Lambda
} = require('jovo-framework');
const { Webhook, ExpressJS, Lambda } = require('jovo-framework');

const {app} = require('./app.js');
const { app } = require('./app.js');

if (process.argv.indexOf('--webhook') > -1) {
const port = process.env.JOVO_PORT || 3000;
Webhook.jovoApp = app;
Webhook.listen(port, () => {
console.info(`Local server listening on port ${port}!`);
});
const port = process.env.JOVO_PORT || 3000;
Webhook.jovoApp = app;
Webhook.listen(port, () => {
console.info(`Local server listening on port ${port}!`);
});

Webhook.post('/webhook', async (req, res) => {
await app.handle(new ExpressJS(req, res));
});
Webhook.post('/webhook', async (req, res) => {
await app.handle(new ExpressJS(req, res));
});
}

// AWS Lambda
exports.handler = async (event, context, callback) => {
await app.handle(new Lambda(event, context, callback));
await app.handle(new Lambda(event, context, callback));
};
@@ -0,0 +1,100 @@
{
"invocation": "transactions demo",
"intents": [
{
"name": "YesIntent",
"phrases": [
"Yo",
"Yeah",
"Yes"
]
}
],
"inputTypes": [
{
"name": "NameInputType",
"values": []
}
],
"googleAssistant": {
"custom": {
"scenes": {
"TransactionCompletePurchaseScene": {
"conditionalEvents": [
{
"condition": "scene.slots.status == \"FINAL\"",
"handler": {
"webhookHandler": "Jovo"
}
}
],
"slots": [
{
"commitBehavior": {
"writeSessionParam": "CompletePurchase"
},
"config": "$session.params.purchase",
"name": "CompletePurchase",
"required": true,
"type": {
"name": "actions.type.CompletePurchaseValue"
}
}
]
},
"TransactionDigitalPurchaseCheckScene": {
"conditionalEvents": [
{
"condition": "scene.slots.status == \"FINAL\"",
"handler": {
"webhookHandler": "Jovo"
}
}
],
"slots": [
{
"commitBehavior": {
"writeSessionParam": "DigitalPurchaseCheck"
},
"config": {
"@type": "type.googleapis.com/google.actions.transactions.v3.DigitalPurchaseCheckSpec"
},
"name": "DigitalPurchaseCheck",
"required": true,
"type": {
"name": "actions.type.DigitalPurchaseCheckResult"
}
}
]
}
},
"global": {
"actions.intent.CANCEL": {
"handler": {
"webhookHandler": "Jovo"
}
},
"actions.intent.MAIN": {
"handler": {
"webhookHandler": "Jovo"
}
},
"actions.intent.NO_INPUT_1": {
"handler": {
"webhookHandler": "Jovo"
}
},
"actions.intent.NO_INPUT_2": {
"handler": {
"webhookHandler": "Jovo"
}
},
"actions.intent.NO_INPUT_FINAL": {
"handler": {
"webhookHandler": "Jovo"
}
}
}
}
}
}