Giter VIP home page Giter VIP logo

giftshop-demo's Introduction

Gift Shop - jBPM + Google Actions Demo

This is a demo that demonstrates a business oriented simple application with low-code development approach. It involves business processes and rules using BPMN and Decision Tables. Usage sample with images at the end of this file.

jBPM is open source software, released under the Apache Software License. It is written in 100% pure Java™, runs on any JVM and is available in the Maven Central repository too. Red Hat Process Automation Manager RHPAM is the enterprise version of jBPM and can be downloaded and used freely by developers.

In this sample, Google Assistant can be used to order a gift. The request will be handled by a process engine in jBPM, and the item price + delivery fee will be calculated according to the business rules (decision tables).

Google Assistant informs the customer of the total price which consists of the item cost plus the delivery time.

Pre-reqs

  • Java 8
  • MySQL
  • NGrok
  • jBPM 7.29.0
  • Firebase console (with subscription that allows requests to external environments)

Installation

To test this project its necessary to start jBPM, import business project, deploy it. Import the google assistant project to dialogflow and deploy the NodeJS function to firebase.

For now, this file describes a local install without OpenShift

MySQL

  1. Start Docker Container
docker run --rm --name mysql-jbpm -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=mydb -e MYSQL_USER=jbpmuser -e MYSQL_PASSWORD=jbpmpassword -p 3306:3306  -v $HOME/docker/opt/db/mysql:/var/lib/mysql -d mysql:5.7
  1. Configure EAP:

1.1. Datasource:

                <datasource jndi-name="java:jboss/MySqlDS" pool-name="MySqlDS" enabled="true">
                    <connection-url>jdbc:mysql://localhost:3306/mydb</connection-url>
                    <driver-class>com.mysql.jdbc.Driver</driver-class>
                    <driver>mysql-connector-java-5.1.48.jar_com.mysql.jdbc.Driver_5_1</driver>
                    <security>
                        <user-name>jbpmuser</user-name>
                        <password>jbpmpassword</password>
                    </security>
                    <validation>
                        <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>
                        <background-validation>true</background-validation>
                        <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/>
                    </validation>
                </datasource>

1.2. SMTP (change the email and password on the instructions below)

○ → $PATH_TO/jbpm-server-7.29.0.Final-dist/bin/jboss-cli.sh -c
[standalone@localhost:9990 /] /socket-binding-group=standard-sockets/remote-destination-outbound-socket-binding=jbpm-mail-smtp/:add(host=smtp.gmail.com, port=465)
{
    "outcome" => "success",
    "response-headers" => {"process-state" => "reload-required"}
}
[standalone@localhost:9990 /] /subsystem=mail/mail-session=jbpm/:add(jndi-name=java:/jbpmMailSession, [email protected])
{
    "outcome" => "success",
    "response-headers" => {"process-state" => "reload-required"}
}
/subsystem=mail/mail-session=jbpm/server=smtp/:add(outbound-socket-binding-ref=jbpm-mail-smtp, ssl=true, [email protected], password=PASSWORDHERE@123)
{
    "outcome" => "success",
    "response-headers" => {
        "operation-requires-reload" => true,
        "process-state" => "reload-required"
    }
}
[standalone@localhost:9990 /] /system-property=org.kie.mail.session:add(value=java:/jbpmMailSession)
{
    "outcome" => "success",
    "response-headers" => {"process-state" => "reload-required"}
}
[standalone@localhost:9990 /] :shutdown(restart=true)

RHPAM

  1. Start RHPAM with this ( non recomended for prod ) property.
$EAP_HOME/bin/standalone.sh -Dcom.arjuna.ats.arjuna.allowMultipleLastResources=true
  1. Import to Business Central GiftShop application;

  2. Open the GiftShop project, and click on deploy. RHPAM will build and deploy the project on Kie Server. A new kie container will be created to handle the process and rules in this project;

Creating the Google Assistant project

The gift-shop.zip project, contains a zip file that has the intents and fullfilment configurations. All it's required to do is import this zip file into a dialogflow project.

It contains also a simple node.js script (in giftshop-function) used by google assistant to reach the Kie Server via rest API. On this demo, the script runs on the cloud with firebase functions, and tries to reach the Kie Server http address.

Since google assistant runs on the internet, you need to expose your kie containers urls to so the node.js client on firebase can be able to reach it. For local tests, you can use ngrok to create a tunnel and expose kie server.

  1. Download ngrok and start it with:
./ngrok http 8080
  1. Identify the external URL Address and update the node.js client giftshop-function/functions/index.js, variable kieserver_host.
  2. Redeploy it using firebase command line tool:
firebase deploy

Here are some tips on firebase usage:

  • firebase list - List your available projects
  • firebase deploy --project pizza-order-XPT0 - Deploy the new version of your scrip

Using it

Start a simulation on your dialogflow console and enjoy sending gifts to your friends.

Image of Google Assistant

Google assistant started a new process via the Node JS client available on firebase. The NodeJS client executed a rest call to Kie Server with the input collected from the user. A new Order process will be started.

Image of Business Process

The price and value informed to the customer, were calculated dinamicaly by business rules defined in decision tables.

Image of Decision Table

The human tasks have forms which can be obtained and embedded in external apps

Image of Human Task Form

Change the value of a business rule, click on deploy in Business Central, and try to order the same Gift using Google Actions. The new rule will be imediatelly used.

giftshop-demo's People

Contributors

kmacedovarela avatar

Watchers

 avatar  avatar

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.