Giter Club home page Giter Club logo

bots-node-sdk's Introduction

Oracle Digital Assistant Node.js SDK

This SDK is the main developer resource for Oracle Digital Asistant integrations in a Node.js express environment. It provides two primary solutions for custom implementations against the Digital Assistant platform:

SDK Installation

To install the SDK globally:

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

To install the SDK locally in your current directory:

npm install @oracle/bots-node-sdk

When installed locally, use npx @oracle/bots-node-sdk instead of just bots-node-sdk to run the command-line interface (CLI) commands described in the Getting Started section.

Getting Started

This section explains the basic CLI commands to get your component service up and running. See the CLI documentation for a complete list of all the arguments and options that you can configure with each command.

Create a Component Service

Use the init command to create a component service package. For example:

bots-node-sdk init PizzaService --name pizza-service 

This example creates a component service named pizza-service in a directory named PizzaService. The component service includes one sample custom component named helloWorld.

Add a Custom Component to Existing Service

You use the init component <name> custom command to add a component to an existing package. For example:

bots-node-sdk init component myCustomComponent custom

This example creates a component of type custom named myCustomComponent. Instead of typing custom for the component type argument, you can type c as a shortcut.

Add an Entity Event Handler to Existing Service

You use the init component <name> entityEventHandler command to add an event handler to an existing package. For example:

bots-node-sdk init component myEventHandler entityEventHandler

This example creates a handler of type entityEventHandler that is named myEventHandler. Instead of typing entityEventHandler for the component type argument, you can type e as a shortcut.

Add an SQL Query Event Handler to Existing Service

You use the init component <name> sqlQueryEventHandler command to add an event handler to an existing package. For example:

bots-node-sdk init component myEventHandler sqlQueryEventHandler

This example creates a handler of type sqlQueryEventHandler that is named myEventHandler. Instead of typing sqlQueryEventHandler for the component type argument, you can type s as a shortcut.

Add an LLM Transformation Handler to Existing Service

You use the init component <name> llmTransformation command to add an event handler to an existing package. For example:

bots-node-sdk init component myEventHandler llmTransformation

This example creates a handler of type LlmTransformation that is named myEventHandler. Instead of typing llmTransformation for the component type argument, you can type t as a shortcut.

Add an LLM Validation & Customization Handler to Existing Service

You use the init component <name> llm command to add the event handler to an existing package. For example:

bots-node-sdk init component myEventHandler llm

This example creates a handler of type LlmComponent that is named myEventHandler. Instead of typing llm for the component type argument, you can type l as a shortcut.

Create a Component Service Package

To package the components, use the pack command. For example:

bots-node-sdk pack

This creates a component service package .tgz file that can be hosted as an express service, uploaded to a skill's embedded container in Digital Assistant, or uploaded to Oracle Mobile Hub.

Deploy as an External Component Service

To start a service on a local node server and host the custom component package, use the start command.

npm start

This example creates a component service running on a local node server. It uses the @oracle/bots-node-sdk dev dependency.

Alternatively, you can use this bots-node-sdk command to start the service. This command uses the global bots-node-sdk installation.

bots-node-sdk service

To see the metadata for all deployed components, run this cURL command:

curl -X GET localhost:3000/components

To deploy to a docker container, you can use the following commands:

npm run-script docker-build
docker-compose up

Using TypeScript

The SDK has full support for TypeScript. If you want to use TypeScript to write your custom components and event handlers, all you need to do is specify the language option when you create the component service. For example:

bots-node-sdk init MyComponentService --language typescript

or the shorter format:

bots-node-sdk init MyComponentService  -l t

This example creates a TypeScript project in the MyComponentService directory.

If you subsequently use the init component command to add a component to a TypeScript project, it creates a TypeScript component instead of a JavaScript component.

When run on a TypeScript project, the service and pack commands transpile all files under the src directory into JavaScript files in the build directory.

The benefit of using TypeScript over JavaScript is that it is strongly typed, so, if you use an editor like Visual Code Studio, you'll get code completion features and compile-time type checking similar to Java.

See the README.md that's created in your scaffolded TypeScript project for more information.

More Information

Contributing

This project welcomes contributions from the community. Before submitting a pull request, please review our contribution guide

Security

Please consult the security guide for our responsible security vulnerability disclosure process

License

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

The Universal Permissive License (UPL), Version 1.0

npm version wercker status

bots-node-sdk's People

Contributors

arpitjaiswal avatar bots-training avatar dependabot[bot] avatar diegocornejo avatar junior avatar lesiachaban avatar mvandervliet avatar spavlusieva avatar stevendavelaar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bots-node-sdk's Issues

Integration with twilio/whatsapp

Good afternoon!!

I would like to know if there is any example of integration with twilio/whatsapp. I'm having difficulties with this integration, when we send a message via wahtsapp the component service receives the message, but whatsapp does not receive the skill's response

Thanks

typescript component does not compile

The goal is to create a custom component on my local machine using typescript for debugging purposes
Initially I did create the component with the following command
> bots-node-sdk init PizzaService --name pizza-service --language typescript
then
> npm run start
image

I have tried deleting node_modules and package-lock.json and nothing changed.

This is what package.json has
image

Does anyone have a solution for this, please?

Use of replaceMessage property with AdaptiveCards and MessageModel().rawConversationMessage(payload)

Hi, were are trying to send an adaptive card layout to Teams via a custom component. We want to use the replaceMessage property on the CRC to be able to make cards read only after submit, but we can't see any way to set the replaceMessage property when using the rawConversationMessage. Is this possible?

We're following this blog post for reference: https://blogs.oracle.com/digitalassistant/post/techexchange-quick-tip-using-raw-message-payloads-in-custom-components-to-leverage-channel-specific-ui-extensions-ms-teams-example

Basic Authentication / OAuth Support

Use Case: There may be a use case where a user wants to deploy their custom code on their own server (maybe to use other dependencies not supported on Oracle Mobile Hub); however, the server may not be authenticated.

Problem: It would be great to have support for Basic Authentication (or OAuth) when deploying a custom component that depends on this @oracle/bots-node-sdk package in their package.json.

Solution: Can the @oracle/bots-node-sdk support a config file in the user's custom component code which will easily/declaratively enable basic authentication support (ie, a JSON)?

Problem Pt 2: Can OAuth 2.0 be supported?
Solution 2: Can the Express object be exposed by the @oracle/bots-node-sdk to allow for custom decorations for using middlewares which would enable Basic Authentication or OAuth 2.0 or whatever next-gen authentication method might come next?

Question: How to use NonRawMessage methods?

Hey guys,

I'm currently working on some custom webhook integration and plan is to switch from deprecated MessageModel to MessageFactory. Creating inbound messages (that will be sent to DA skill) work as intendend. However, I struggled a bit with outbound messages (received from DA skill). Previously I was extracting on my own all actions, globalActions, header and footer text. Now I saw there are already defined methods for it within NonRawMessage class but I don't know right way to call it.

new NonRawMessage().getGlobalActions(); does not except any argument and not quite sure how should I or should I pass somehow message payload to class constructor

Thanks in advance,
Kind regards

sdk analysis error using TS (ERROR message: Invalid component path:)

Good afternoon!!

I am using TS to develop a custom component.
But I am not able to instantiate the class that contains the initial logic of the component.
The TS code compiles but when the SDK analyzes the project it displays the following ERROR message: Invalid component path: /home/luizpires/dev/ODA/cognitiveservices.chatbot.oda.corona.poc/build/components/ComponentFirstVisitVerification .js.
Could this be caused by a flag in tsconfig.json?
Is there any way to turn off the sdk analysis?

Thank you very much for your attention

Typescript or babel example

Hello,

I would like to know if there is any example of using the sdk with typescript or babel for the use of imports and other latest JS resources

Thanks

ERROR: spawn npm ENOENT

Hi,

While running the command, "bots-node-sdk init --run", I am continuously getting this error. Tried all options but to no avail.


D:\np\mywork\initiatives\chatbots\oda\scc_customcomp>bots-node-sdk init --run

Will update contents in directory 'scc_customcomp'
Create component package in directory 'scc_customcomp'...

Writing files...

WARN: D:\np\mywork\initiatives\chatbots\oda\scc_customcomp\main.js already exists
WARN: D:\np\mywork\initiatives\chatbots\oda\scc_customcomp\package.json already exists
WARN: D:\np\mywork\initiatives\chatbots\oda\scc_customcomp\README.md already exists
WARN: D:\np\mywork\initiatives\chatbots\oda\scc_customcomp\spec\test.req.json already exists
WARN: D:\np\mywork\initiatives\chatbots\oda\scc_customcomp.gitignore already exists
WARN: D:\np\mywork\initiatives\chatbots\oda\scc_customcomp.npmignore already exists

Installing dependencies...

ERROR: spawn npm ENOENT


Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.