oracle digital assistant - github pages...custom component service development in mobile hub...

37

Upload: others

Post on 11-Jun-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a
Page 2: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |

Oracle Digital Assistant The Complete Training

2

Custom Component Development with Mobile Hub

Image courtesy of pixabay.com

Page 3: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a

Copyright © 2018, Oracle and/or its affiliates. All rights reserved.

Safe Harbor StatementThe following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.

3

Page 4: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a

Copyright © 2018, Oracle and/or its affiliates. All rights reserved.

Topic agenda

Mobile Hub introduction

Custom component services in Mobile Hub

Building custom components in Mobile Hub

Backend integration

Local development and debugging

1

2

3

4

5

4

Page 5: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a

Copyright © 2018, Oracle and/or its affiliates. All rights reserved.

Topic agenda

Mobile Hub introduction

Custom component services in Mobile Hub

Building custom components in Mobile Hub

Backend integration

Local development and debugging

1

2

3

4

5

5

Page 6: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 6

Multi channel backendOracle Mobile Hub

PlatformServices RolesNotification Storage DB Offline App Policy Location

Backend Custom API ConnectorsREST, SOAP, Fusion,Integration Cloud

Multi Channel

REST Node.js

Clients

Mobile

Web

Chatbot

REST

Page 7: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 7

Custom component service deployment options

Oracle Mobile Hub

Skill bot Local Container

3rd Party Node ContainersOracle Digital Assistant Skill

Page 8: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a

Copyright © 2018, Oracle and/or its affiliates. All rights reserved.

Mobile Hub benefits• Multi channel backend service– API sharing between web, mobile and bot applications– Secure API access– Payload shaping – Platform services: storage, analytics, database, location, push etc.

• API and API Implementation versioning• Declarative REST, SOAP and Fusion Apps connectors• Single point of administration and maintenance• Diagnostics

8

Page 9: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a

Copyright © 2018, Oracle and/or its affiliates. All rights reserved.

Topic agenda

Mobile Hub introduction

Custom component services in Mobile Hub

Building custom components in Mobile Hub

Backend integration

Local development and debugging

1

2

3

4

5

9

Page 10: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a

Copyright © 2018, Oracle and/or its affiliates. All rights reserved.

Custom component service development in Mobile Hub• Custom component service built as Custom API– Component Service exposed through a Backend– Access to Mobile Hub services and SDK– Leverages Mobile Hub connector framework (REST, SOAP, Fusion, ICS)

• Component service API and Implementation versioned in Mobile Hub– Node programming

• Logs and diagnostic information saved in backend analytics

10

Page 11: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 11

Custom component service architecture

GET

POST

Component 1

Component 2

Component <n>JavaScript

metadata: ()=>({…}),

Invoke(conversation, done) => {…}Invoke(conversation, done) =>

Skill Bot

Oracle Node.js SDK

Component Router

Component SDK

Message Model

Component Service (REST)

Node.js frontend

Page 12: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 12

Custom component service architecture in Mobile Hub

GET

POST

Component 1

Component 2

Component <n>JavaScript

metadata: ()=>({…}),

Invoke(conversation, done) => {…}Invoke(conversation, done) =>

Skill Bot

Oracle Node.js SDK

Component Router

Component SDK

Message Model

Component Service (REST)

Custom API

Node.js frontend

Backend

Page 13: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a

Copyright © 2018, Oracle and/or its affiliates. All rights reserved.

Topic agenda

Mobile Hub introduction

Custom component services in Mobile Hub

Building custom components in Mobile Hub

Backend integration

Local development and debugging

1

2

3

4

5

13

Page 14: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a

Copyright © 2018, Oracle and/or its affiliates. All rights reserved.

Installing Oracle Node.js SDK

• Global installation provides the command line to create custom components• Requires Node and Node Package Manager (NPM) to be installed• Open a terminal window and type

14

MAC / Linux

sudo npm install –g @oracle/bots-node-sdk

Windows

npm install –g @oracle/bots-node-sdk

Page 15: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a

Copyright © 2018, Oracle and/or its affiliates. All rights reserved.

Downloading the custom API template• Oracle Mobile Hub Custom API starter template is available in Oracle Bots Node.js

SDK on GitHub– https://github.com/oracle/bots-node-sdk– Defines GET and POST methods required for Bot custom component services

15

https://github.com/oracle/bots-node-sdk/blob/master/bin/templates/ccservice/component.service.raml

Page 16: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a

Copyright © 2018, Oracle and/or its affiliates. All rights reserved.

Creating a custom component service API

16

Create new API

Open API

Copy & paste RAML(keep title, version, baseUri)

Page 17: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 17

Custom component service endpoints

Page 18: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 18

Disable login requirement

Page 19: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 19

Downloading the custom API scaffold

Page 20: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a

Copyright © 2018, Oracle and/or its affiliates. All rights reserved.

Setting up the local development environment

• Unzip the downloaded scaffold• Open command line and navigate into

custom API root folder– Folder that contains package.json

• Install Oracle Bots Node.js SDK locally– Provides custom component SDK– Handles component request routing

20

npm install @oracle/bots-node-sdk

Page 21: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 21

For better code organization, create a "components" folder and then a folder

for each custom component you build therein

Image courtesy of pixabay.com

Page 22: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a

Copyright © 2018, Oracle and/or its affiliates. All rights reserved.

Editing the custom API

22

https://github.com/oracle/bots-node-sdk/blob/master/bin/templates/ccservice/api.js

Copy Content from api.js

Edit baseUrl, cwd, registerproperties

Copy Content

Page 23: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 23

Custom component service code explainedmodule.exports = function (service) {

const OracleBot = require('@oracle/bots-node-sdk'); OracleBot.init(service);

// implement custom component apiOracleBot.Middleware.customComponent(service, {

baseUrl: '/mobile/custom/helloworldCCS/components',cwd: __dirname,register: [

'. /components']

});

};

Node module definition

Load command for Bot Node.js SDK

Request to custom component routerREST URI to invoke custom component(should match your API URI)

Relative folder custom components areSearched in

Page 24: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a

Copyright © 2018, Oracle and/or its affiliates. All rights reserved.

Creating a custom component

24

bots-node-sdk init component --name helloworldcomp components/helloworld

Page 25: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 25

Generated custom component file & code

Component invocation nameComponent properties

Action transitions

Callback that must be called at the end

Function invoked at runtime

Page 26: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a

Copyright © 2018, Oracle and/or its affiliates. All rights reserved.

Deploying the custom component service to Mobile Hub• compress project root folder to a zip-file• Upload zip-file as custom API

implementation

• Use embedded tester in Oracle Mobile Hub to test GET method• Expose custom API on Mobile Hub

backend

26

Page 27: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 27

Component registration in Oracle Digital Assistant skill'Deployment' to Oracle Digital Assistant

Oracle Mobile Hub Skill

Page 28: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a

Copyright © 2018, Oracle and/or its affiliates. All rights reserved.

Topic Agenda

Mobile Hub introduction

Custom component services in Mobile Hub

Building custom components in Mobile Hub

Backend integration

Local development and debugging

1

2

3

4

5

28

Page 29: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 29

In addition to multi-channel support, backend integration is a good argument

for using Oracle Mobile Hub to create custom components in

Image courtesy of Farbentek at FreeDigitalPhotos.net

Page 30: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 30

Mobile Hub backend integration options

Custom

Component

Remote Service

Skill Bot

Shared API

Recommendedpractice

Connector

Page 31: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 31

You can access the Oracle Mobile Hub SDKthrough the Custom Component SDK to

access Mobile Hub custom APIs, platform APIs and Connectors

conversation.oracleMobile.<function>

Image courtesy of Farbentek at FreeDigitalPhotos.net

Page 32: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a

Copyright © 2018, Oracle and/or its affiliates. All rights reserved.

Topic agenda

Mobile hub introduction

Custom component services in Mobile Hub

Building custom components in Mobile Hub

Backend integration

Local development and debugging

1

2

3

4

5

32

Page 33: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a

Copyright © 2018, Oracle and/or its affiliates. All rights reserved.

Custom component debugging with Oracle Mobile Hub• Install Oracle Custom Code Test Tool– Download from OTN– Follow instructions in readme

• Configure backend with code test toolreference– Code test tool proxy installed as custom API

• Have local copy of component service customAPI– Configure toolsConfig.json with backend access

• Start Local Debugging– Code test tool command

33

https://www.oracle.com/technetwork/topics/cloud/downloads/mobile-cloud-service-3636470.html

Page 34: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 34

Mobile Hub debugging architecture

Internet

Oracle Digital Assistant(Skillbot)

Tunnel(e.g. Ngrok)

Oracle Mobile Hub

Access DependentServices

omce-tools downloadfrom OTN

Local custom component service codeExecuting in omce-tools Node container

Debug with JS Editor like MS Visual Studio Code

Page 35: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 35

Page 36: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a
Page 37: Oracle Digital Assistant - GitHub Pages...Custom component service development in Mobile Hub •Custom component service built as Custom API –Component Service exposed through a

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 37

Oracle Digital Assistant Hands-On

TBD