BUSINESS MESSAGES: SHOPPING CART SAMPLE
This Business Messages agent demonstrates how a shopping cart may be built in a conversational surface leveraging the functionality and platform of the Business Messages API to facilitate messaging.
This project is setup to run on the Google App Engine.
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 3.3.9 or greater
- Google Cloud SDK (aka gcloud)
- Java 8
- Google App Engine SDK for Java
SETUP
Set up the Business Messages agent:
- Open Google Cloud Console (https://console.cloud.google.com/) with your Business Messages Platform Google account and create a new project for your agent.
Note the Project ID and Project number.
-
Click the menu icon in the top left, then select APIs & Services > Library.
-
Search for and enable "Business Messages API".
-
Register this sample as an agent. See "Register an agent" (https://developers.google.com/business-communications/business-messages/guides/set-up/agent).
The webhook URL will be https://PROJECT_ID.appspot.com/callback
Where PROJECT_ID is the project ID for the project you created when you registered for Business Messages.
-
Create a service account.
-
Navigate to Credentials.
-
Click Create service account.
-
For Service account name, enter your agent's name, then click Create.
-
For Select a role, choose Project > Editor, the click Continue.
-
Under Create key, choose JSON, then click Create.
Your browser downloads the service account key. Store it in a secure location.
-
Click Done.
-
-
Copy the JSON credentials file into the /src/main/resources folder and rename it to "bm-agent-service-account-credentials.json".
RUN THE SAMPLE
-
In a terminal, navigate to this sample's root directory.
-
Run the following commands:
gcloud config set project PROJECT_ID
Where PROJECT_ID is the project ID for the project you created when you registered for Business Messages.
mvn appengine:deploy
-
On your mobile device, use the test business URL that you received when you registered your agent to open a conversation with your agent and type in "Hello". Once delivered, you should receive "Hello" back from the agent. Type "help" to tap the Help suggestion to explore other functionality.