Connecting Google Assistant to JAICF project
To create an Action and connect the JAICF project to it, please follow these steps:
- Prepare the project.
- Create a Google Assistant channel.
- Download Action Package.
- Register your Action in the Actions Console.
- Create an activation phrase.
- Copy Project ID.
- Download gactions.
- Upload the Action Package into your project.
- Get permission to use.
- Test your bot in the Actions Console simulator.
Prepare the project
Before connecting the channel, prepare the JAICF project in advance:
- Specify the following in the dependencies of
build.gradle.kts
file:
dependencies {
// ...
implementation("com.just-ai.jaicf:jaicp:$jaicfVersion")
implementation("com.just-ai.jaicf:google-actions:$jaicfVersion")
}
$jaicfVersion
with the latest framework version.- Configure depending on the connection method to the platform:
long polling
— the bot will connect to the Just AI server when interacting with the platform. Simple solution, suitable for local development and debugging.For this method, specify the channel
ActionsFulfillment.ActionsFulfillmentSDK
in theJaicpPoller.kt
file:
package com.just-ai.jaicf.template.connections
fun main() {
JaicpPollingConnector(
templateBot,
accessToken,
channels = listOf(
ChatApiChannel,
ChatWidgetChannel,
TelephonyChannel,
ActionsFulfillment.ActionsFulfillmentSDK
)
).runBlocking()
}
webhook
— the bot will receive messages from the platform using the specified link. Must be configured to connect JAICP Cloud.For this method, specify the channel
ActionsFulfillment.ActionsFulfillmentSDK
in theJaicpServer.kt
file:
package com.just-ai.jaicf.template.connections
fun main() {
JaicpServer(
botApi = templateBot,
accessToken = accessToken,
channels = listOf(
ChatApiChannel,
ChatWidgetChannel,
TelephonyChannel,
ActionsFulfillment.ActionsFulfillmentSDK
)
).start(wait = true)
}
Create a channel
Open the JAICF project on JAICP. Go to the Channels tab on the side panel, then click Inbound → Connect channel. In the Voice Assistants section, choose Google Assistant.
Fill in the fields:
- Channel name — here you can change the channel name.
- Web app URL — specify the link to Interactive Canvas web application if needed.
- Triggers — here you can add the phrases that will be associated with your action. If the user says one of these phrases, Google Assistant will suggest activating your action.
Click Create.
Action Package
Download the JSON from your Action Package. To do that, click the link Download action.json under the name of the newly added channel.
Register Action in the Actions Console
Proceed to Action Console and create a new project. To do that, click Add/import Project. Set the name of the project, the language and your country. Choose a category from the suggested options.
Create an activation phrase
Go to Setup → Invocation on the control panel. In the Display name field set the activation phrase for your bot’s Action.
Here you can also choose the voice that the bot will use to talk to users. Save the changes
Copy Project ID
Go to Project settings → copy Project ID.
Download gactions
Download the gactions software for your OS.
Upload the Action Package into your project
Open the Command Prompt (for Windows) or terminal (macOS, Linux). Proceed to the folder containing your gations and the JSON-file for the Action Package. Run this command:
gactions update --action_package PACKAGE_NAME --project PROJECT_ID
- Use the name of the JSON-file instead of
PACKAGE_NAME
. - Use your Project ID that you have copied previously instead of
PROJECT_ID
.
Click Enter
.
Get permission to use
You will receive a URL from gactions that you need to open in any browser. Copy the URL and then paste it into your browser.
A page will open in the browser asking you to select an account and grant permission to manage projects. Select the account where you created the project in the Actions Console, click Allow.
You will see an authorization code that you need to copy and paste back into the console/terminal and then press Enter
.
Testing
Now you can test the Action using the device supporting Google Assistant in the same account that you used to create the project. You can also test your bot in the Action Console simulator.
Before testing, check the permissions for the activity controls in your Google Assistant. To do that, proceed to your Google account → Privacy & personalization → Manage your data & personalization → Activity controls.
The following settings should be turned on:
- Web & App Activity;
- Device Information;
- Voice & Audio Activity.