Actions on Google SDK 2.4.1 Updates
Actions on Google SDK 2.4.1 Updates
Developers can extend the functionality of Google Assistant. For instance, they can provide an Action to fulfill something to the Google Assistant, and users can invoke the action with the action name. The actions-on-google-nodejs SDK (here, I call “SDK” simplify) allows them to build actions and to use each features provided by the Actions on Google easily.
On October 5 2018, the new version 2.4.1 of the SDK has been released. I would like to introduce three important updates of the new version here.
Fixing the bug about “followup” feature
Your action can issue an event with the conv.followup()
function. And, your action can receive the event by creating an intent to handle the event.
For example, when your action calls the conv.followup()
in your fulfillment,
app.intent("something", conv => {
conv.followup("follow_up_event_test", {
... // Some parameters
});
});
your action can handle the event by defining the intent to handle the event.
app.intent("followup.test", conv => {
// do something...
});
Until the SDK version 2.3.0, there was the bug that the saved data loss, when using the conv.followup()
function. If your action stores a user name into the conv.data
storage,
app.intent("something", conv => {
conv.data["user_name"] = "Yoichiro";
conv.followup("followup_event_test");
});
the user name is lost. That is, if your action has a code like the following,
app.intent("followup.test", conv => {
conv.ask(`Hi ${conv.data["user_name"]}. Followed up.`);
});
until 2.3.0, you will see the following result.
But, this bug was fixed at 2.4.1. By using 2.4.1, your action can pass the user name when using the conv.followup()
.
Auto-complete for Default Dialogflow intents
When you create a new agent on Dialogflow, you can see two pre-created default intents:
- “Default Welcome Intent”
- “Default Fallback Intent”
Basically, you don’t need to change the names, and you will use them without any touches. However, these names are a bit long, therefore, you might mistype.
If you’re using TypeScript and Visual Source Code or such environment, the mistyping will be reduced substantially. Because, instead you type, these intent name will be autocompleted.
I want to use this feature, but I can’t do that. Because, I’m an IntelliJ IDEA user (the string autocompletion is not supported yet)…
Supporting Digital Transactions
Recently, Actions on Google has started to support Digital Transactions. By the Digital Transactions, your action can treat Digital goods managed by the Google Play and can sell them to your users.
To treat Digital goods, developers need to use different way from steps that are for transactions for Physical goods. That is, there is the following step.
- Gathers information.
- Builds the order.
- Completes the purchases.
- Describes the purchase status.
In the latest 2.4.1 of the SDK, the CompletePurchase
class has been provided. Your action can complete the purchase by sending the instance of the CompletePurchase
class (this is for the step 3 above).
app.intent("something", (conv, params, option) => {
const [skuType, id] = option.split(",");
conv.ask(new CompletePurchase({
skuId: {
skuType: skuType,
id: id,
packageName: <PACKAGE_NAME>,
},
}));
});
As the result, if you need to process Digital Transactions, you need to use the version 2.4.1 of the SDK.
Conclusion
Google Assistant and Actions on Google are evolving everyday, and the number of features developers can use are increasing according to that. Basically, developers access to the features via the SDK. That is, updates information of the SDK is very important for developers.
You can know the updates information from the following page. Please watch updates information to catch up quickly.