
- FORMAT API.AI PHP WEBOOK FOR MAC
- FORMAT API.AI PHP WEBOOK INSTALL
- FORMAT API.AI PHP WEBOOK CODE
- FORMAT API.AI PHP WEBOOK ZIP
Initialize gaction, open a terminal and run:.Note: on Mac and Linux run “ $chmod +x gactions” in a terminal to make the binary executable. Download Google gactions cli (gaction is a self-updating command line interface that lets you test your actions).You can choose to deploy and public your Assistant Action (only if Big G likes your work) clicking “DEPLOY” button OR keep your action private by setting it as an infinite preview. The action preview will last only 30 minutes. In this tutorial we are implementing a private Action, so we will not publish the Action and we will only work with the ‘ appspot-preview.
The ‘-preview’ part of the URL is a redirection made by Google to preview your application, and it will be changed in ‘ as soon as your application will be reviewed and accepted by the Google team if you decide to make it publicly available.
Your application is now live at ‘ appspot-preview. To view your application in the web browser run: $ gcloud app browse
Deployed service to You can read logs from the command line by running: $ gcloud app logs read You’ll need this in the next section to configure the webhook URL. You should see a log output similar to the following example.$ cd $ gcloud config set project $ gcloud app deploy To deploy the application in the Google App Engine, run:.
Download, install, and initialize the Google Cloud SDK in your machine following the docs or for Mac users running from command line:. I will refer to as the ID of the project that you created in STEP 2 while following the ‘Actions on Google: Building Assistant Actions using API.AI’ video tutorial. If your webhook is running as expected you are now ready to upload it to the server. Deploy the project in the Google App Engine. As said in the previous step, you can get an example of the Json in API.AI project trying the Intent (on the right panel) and clicking the “SHOW JSON” button. $ curl -X POST -H “Content-Type: application/json” -d ‘’ is the Json that you are expecting to receive from the API.AI action. If you want to test with the Json similar to the one sent from API.AI, you can test it sending the JSON body with curl:. $ curl -X POST -H “Content-Type: application/json” To just simply trigger your application, open a second terminal and try to send a Json with curl to your running local webhook:. If your application doesn’t have any bugs (and you didn’t modify the starting part of the server in the ‘app.js’ at the bottom of the file), you will see on the terminal: “ App listening on port 8080”. To launch your application, open a terminal and run:. Because the deployment process takes a few minutes, it’s quicker to debug the application when it runs locally. Be sure that your application works as expected before deploying it to the server. To get an example of the Json sent to the server, go to API.AI, test your Intent in the right panel “ Try it now” and then click the “SHOW JSON” button. The Json contains the Entities that triggered your Intent as parameters and they can be retrieved by parsing the ‘req’ parameter in the app.post method. Note: When an Intent (described in your API.AI action) is triggered, a Json post is sent to the server where the application is listening. Open the ‘ app.js’ file inside with your text editor or your favorite javascript IDE and code your webhook logic inside the function:įunction responseHandler (assistant).
Install the node dependencies in the local node_modules folder, open a terminal and run:. Download the template zip from github: apiai-webhook-template-nodejs, unzip and move the files into the. Create a folder inside, I will refer to this folder as. Create a folder in your workspace, I will refer to this folder as. You can create a webhook in Node.js starting from a template. API.AI recognize the words ‘quick’, ‘hot’ and ‘soup’ but we need an application that process those words and give us a recipe for a quick hot soup. For example, what should the Assistant do when you ask “Do you have a recipe for a quick hot soup?”. Code the behavior of the Assistant when triggered by an Intent.