Most API.AI samples consist of two parts: the Node.js app for fulfillment and the project that you import into API.AI. You need to deploy both parts for the sample to work. We provide the following samples:
API.AI Webhook Template - A template project for API.AI that includes a webhook template
git clone https://github.com/actions-on-google/apiai-webhook-template-nodejs
Silly Name Maker - A very simple API.AI agent that doesn't have fulfillment.
git clone https://github.com/actions-on-google/apiai-silly-name-maker
Silly Name Maker with Webhook - A version of Silly Name Maker that uses fulfillment.
git clone https://github.com/actions-on-google/apiai-silly-name-maker-webhook-nodejs
Facts about Google - Learn how to use more advanced concepts of API.AI, such as contexts.
git clone https://github.com/actions-on-google/apiai-facts-about-google-nodejs
Name Psychic - Request user profile information and persist it across conversations
git clone https://github.com/actions-on-google/apiai-name-psychic-nodejs
Number Genie - A guess a number game that shows great VUI design.
git clone https://github.com/actions-on-google/apiai-number-genie-nodejs
All Actions SDK samples consist of two parts, the Node.js app for fulfillment
and the action package that you preview or deploy with the
You need to deploy both parts for the sample to work.
Eliza - A version of Eliza for Actions on Google.
git clone https://github.com/actions-on-google/actionssdk-eliza-nodejs
Ordinal Number Speaker - A very simple action that speaks back any number you say with an ordinal version of the number.
git clone https://github.com/actions-on-google/actionssdk-say-number-nodejs
In general, each sample contains the following files:
- API.AI project zip file or agent.json - Contains the project to import into API.A or the action package to deploy
- app.js - The fulfillment code
- app.yaml - Google App Engine project manifest. You don't need this file if you are not using Google App Engine.
- package.json - Node.js dependencies for the project.
- node_modules directory - Contains downloaded project dependencies, including the actions-on-google client library. This directory appears after you run
Download the sample and dependenciesRun the following commands where
<sample_url>is one of the sample URLs above and
<sample_dir>is the directory that git creates.
git clone <sample_url> cd <sample_dir> npm install
Deploy the Node.js app for fulfillment
These instructions assume you are using Google App Engine. See deploying to Heroku for instructions on how to deploy to Heroku.
This tutorial assumes you are using Google App Engine, but you can use any hosting platform that supports Node.js.
- Download, install, and initialize the Google Cloud SDK.
- Download and install Node.js
- Go to the Google Cloud Console projects page and select or create a new project. Make a note of the project ID, because it is used for configuration and deployment.
- Enable billing for your project. See the console's help center for more information.
- Deploy the project to Google App Engine. This process takes a few minutes.
$ cd <sample_dir> $ gcloud config set project <project_id> $ gcloud app deploy
You should see output that is similar to the following example. Make note of the endpoint URL. You'll need this in the next section to configure the fulfillment URL.
Updating service [default]...done. Deployed service [default] to [https://project-id.appspot.com] You can read logs from the command line by running: $ gcloud app logs read To view your application in the web browser run: $ gcloud app browse
Import and configure the API.AI project (for API.AI only)
- Create an
API.AI agent named
- Restore the zip into the MyAction project:
- Click on the gear icon to the right of the agent name.
- Click on the Export and Import tab.
- Click Restore from Zip and select the API.AI project zip file.
RESTOREin the text box and click Restore.
- Enable fulfillment:
- Click Fulfillment and slide the Enabled slider to the right.
- In the URL field, enter the endpoint URL for fulfillment.
Previewing and Testing Actions
See Previewing and Testing Actions for information on how to test actions once deployed.