GithubHelp home page GithubHelp logo

brntsw / bm-nodejs-appointment-bot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from google-business-communications/bm-nodejs-appointment-bot

0.0 1.0 0.0 610 KB

This sample demonstrates how to create an appointment setting agent for the Business Messages platform using Dialogflow and the Node.js SDK.

License: Apache License 2.0

JavaScript 90.78% CSS 3.01% HTML 6.21%

bm-nodejs-appointment-bot's Introduction

BUSINESS MESSAGES: APPOINTMENT BOT

This sample demonstrates how to create an appointment setting agent for the Business Messages platform using Dialogflow and the Node.js SDK.

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

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

PREREQUISITES

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

SETUP

Register with Business Messages:

1.  Open [Google Cloud Console](https://console.cloud.google.com) with your
    Business Messages Google account and create a new project for your agent.

    Note the **Project ID** and **Project number** values.

2.  Open the
    [Business Messages API](https://console.developers.google.com/apis/library/businessmessages.googleapis.com)
    in the API Library.

3.  Click **Enable**.

4.  [Register your project](https://developers.google.com/business-communications/business-messages/guides/set-up/register)
    with Business Messages. As the webhook URL, use https://PROJECT_ID.appspot.com/callback, where PROJECT_ID is the **Project ID**
    for the Google Cloud project you created in step 1.

5.  Create a service account.

    1.   Navigate to [Credentials](https://console.cloud.google.com/apis/credentials).

    2.   Click **Create service account**.

    3.   For **Service account name**, enter your agent's name, then click **Create**.

    4.   For **Select a role**, choose **Project** > **Editor**, the click **Continue**.

    5.   Under **Create key**, choose **JSON**, then click **Create**.

         Your browser downloads the service account key. Store it in a secure location.

6.  Click **Done**.

7.  Copy the JSON credentials file into this sample's /resources
    folder and rename it to "bm-agent-service-account-credentials.json".

Create a Business Messages agent:

*   Open the [Create an agent](https://developers.google.com/business-communications/business-messages/guides/set-up/agent)
    guide and follow the instructions to create a Business Messages agent.

Create a Dialogflow agent:

1.  Open [Dialogflow Console](https://dialogflow.cloud.google.com/) with your Google account and create a new Dialogflow agent.

2.  After the agent is created, click the great icon next to the name of your agent in the left navigation.

3.  Click the **Service Account** email field. This will open the Service accounts page within the Google Cloud Console.

4.  Download a service account key.

    1.    Click the three dots for see the overflow menu for the existing service account in the table.

    2.    Click **Create key**.

    3.    One the dialog that opens, click **Create** to download the service account key.

    4.    Copy the JSON credentials file into this sample's /resources
          folder and rename it to "df-agent-service-account-credentials.json".

5.  Go back to the Dialogflow Console and from the agent configuration page, click **Export and Import**.

6.  Click the **RESTORE FROM ZIP** button and select the zip file within this samples root directory called dialogflow-appointmentbot.zip.

7.  Once the Dialogflow agent is imported, click **Fulfillment** from the left navigation.

8.  Under **Webhook**, click the **Disabled** toggle onto **Enabled** and enter
    https://PROJECT_ID.appspot.com/fulfillment/dfCallback in the **URL** field. Replace PROJECT_ID with the Google Cloud project you created and registered with Business Messages.

9.  Click **SAVE** at the bottom of this page.

Update the sample launch page Business Messages agent test URL:

1.  Open the views/index.ejs file from the samples route directory.

2.  Locate the **Chat now** anchor link and update the href value to your agent's test URL. You can retrieve your agent's test URL by issuing a [GET request](https://developers.google.com/business-communications/business-messages/guides/set-up/agent#get-agent)via Business Communications API for your agent.

RUN THE SAMPLE

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

2.  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

    gcloud app deploy

3.  On your mobile device, use the test business URL associated with the
    Business Messages agent you created.

bm-nodejs-appointment-bot's People

Contributors

thefalc avatar

Watchers

 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.