RCS BUSINESS MESSAGING: BANKING AGENT DEMO

This sample RBM agent demonstrates how to use the RBM Java SDK to
send and receive messages to an RCS enabled device.

This sample is setup to run on the Google App Engine.

This sample RBM agent leverages a prebuilt Dialogflow (https://dialogflow.com/) banking agent
as a natural language understanding (NLU) module to detect users' intents during conversation,
handle free form user responses, and simulate typical banking conversation flows.

See the Google App Engine (https://cloud.google.com/appengine/docs/java/) standard environment
documentation for more detailed instructions.


PREREQUISITES

You must have the following software installed on your development machine:

* [Apache Maven](http://maven.apache.org) 3.3.9 or greater
* [Google Cloud SDK](https://cloud.google.com/sdk/) (aka gcloud)
* [Java 8](http://www.oracle.com/technetwork/java/javase/downloads/index.html)
* [Google App Engine SDK for Java](https://cloud.google.com/appengine/docs/standard/java/download)


SETUP

Set up the RBM agent:

1. Open the RBM Developer Console (https://rbm-console.sandbox.google.com/) with your RBM Platform
Google account and create a new RBM agent.

2. When the agent is available, click the agent's card.

3. In the left navigation, click **Service account**.

4. Click **Create key**, then click **Create**. Your browser downloads a service account key for
your agent. You need this key to make RBM API calls as your agent.

5. Rename the service account key "rbm-agent-service-account-credentials.json" and move it
into the "banking-agent-java/src/main/resources" directory.


Set up the Dialogflow sample agent:

1. Open the Dialogflow banking agent
(https://console.dialogflow.com/api-client/#/agent//prebuiltAgents/Banking).

If you're prompted, sign in with your RBM Platform Google account.

2. Click "Import".

3. Click the menu icon in the top left, then select APIs & Services > Library.

3. In the "Link to Google Project" dialog, set the field to
"Create a new Google project" and click "OK".

4. Click "Proceed to agent".

5. Click the gear icon in the left navigation pane next to the project name "Banking".

6. Under Google Project, copy the Project ID.

7. In this sample's directory, navigate to src/main/java/com/google/rbm/samples,
open DialogFlowHelper.java, and set DIALOGFLOW_PROJECT_ID to the Dialogflow agent's Project ID.

8. Save and close DialogFlowHelper.java.


Set up Dialogflow credentials:

1. Open the Google Cloud Console (https://console.cloud.google.com/).

2. Select the Google Cloud project that Dialogflow created for the Banking sample.

3. Click the menu icon in the top left, then select APIs & Services > Library.

4. Search for and enable "Dialogflow API".

5. Click the menu icon in the top left, then select IAM & Admin > Service accounts.

6. Click "Create service account".

7. For "Service account name", enter "dialogflow". For Role, choose Dialogflow > Dialogflow API
Client. Select "Furnish a new private key" with a key type of JSON, then click "Create".
The browser downloads the new credentials file.

8. Rename the credentials file to "dialogflow-service-account-credentials.json" and
place the file in this sample's "banking-agent-java/src/main/resources" directory.


RUN THE SAMPLE

1. In a terminal, navigate to this sample's root directory.

2. Run the following commands:

    mvn appengine:run

3. In a browser, navigate to http://localhost:8080/.

In order for the sample agent to process your responses, you need to deploy the agent.


DEPLOY THE SAMPLE

1. In a terminal, navigate to this sample's root directory.

2. Run the following commands:

    mvn appengine:deploy

3. In a browser, navigate to  https://YOUR-GCP-PROJECT-ID.appspot.com.


SETUP THE AGENT WEBHOOK

1. Return to the RBM Developer Console, in the left navigation, click **Integrations**.

2. Click Edit subscription and configure a push subscription with a
URL of https://YOUR-GCP-PROJECT-ID.appspot.com/callback


ACTIONS SUPPORTED BY DEMO

This demo is quite sophisticated. It uses Dialogflow to interpret responses from the client and map
those to intents and entities. It also supports live chat with an agent.

You can us the menus and suggested replies to navigate the agent, however,
you can also type or speak free text.

Things to try, type any of the following:
- Check my latest balance
- I want to transfer $250 to my checking account
- I want to check my earnings
- How much am I spending?
- I want to open an account.


Live chat support:

If you enter text that the agent does not understand, it will prompt you with some suggested
menu items, one of these is "Customer Support". Once you tap Customer Support, you
will be transferred to a live agent mode.

Once in live chat, if you navigate to https://YOUR-RBM-PROJECT-ID.appspot.com/chat.jsp you can
type messages that will be sent directly to your registered test device.

To switch back to automatic agent mode, make sure you click the link
"Click here to reset the ACME Bank Demo" on the chat page.