This document discusses how to navigate users from an Assistant app to an Android app. It provides code to:
1. Check if the user's device supports screen output and send a basic card with a link button if so. If not, it checks if another device is available that supports screen output and requests a transfer.
2. Define functions for the welcome intent and handling a new surface.
3. Build a basic card rich response with a link button that will launch the LINE app when clicked, and provide example HTML to redirect to the LINE app after 5 minutes.
7. Rich Responses - Basic Card
Supported on
¢ actions.capability.SCREEN_OUTPUT
Image, Title, Sub-title, Text body,
Link button, Border
9. 1. Check whether a surface the user is using supports a screen.
[Yes] 2. Send a Basic Card with a Link Button.
[No] 3. Check whether the user has a surface which is supporting a screen.
[Yes] 4. Request to transfer the user to the surface.
[Yes] 5. Send a Basic Card with a Link Button.
Send a Basic Card w/ a Link Button
?
14. // 1. Check whether a surface the user is using supports a screen
const screenSupported =
app.hasSurfaceCapability(app.SurfaceCapabilities.SCREEN_OUTPUT);
if (screenSupported) {
// 2. Send a Basic Card with Link Button
} else {
// 3. Check whether the user has a surface which is supporting a screen.
const screenAvailable =
app.hasAvailableSurfaceCapabilities(app.SurfaceCapabilities.SCREEN_OUTPUT);
if (screenAvailable) {
// 4. Request to transfer the user to the surface.
const context = "<context>";
const notificationTitle = "<title>";
app.askForNewSurface(
context, notificationTitle, [app.SurfaceCapabilities.SCREEN_OUTPUT]);
} else {
...
}
}
21. exports.dialogflowFirebaseFulfillment =
functions.https.onRequest((request, response) => {
const app = new App({request, response});
const inputWelcome = (app) => { ... };
const newSurface = (app) => {
// 5. Send a Basic Card with a Link Button.
};
const actionMap = new Map();
actionMap.set("input.welcome", inputWelcome);
actionMap.set("new_surface", newSurface);
app.handleRequest(actionMap);
});
さっそくアシスタントアプリにつないでみましょう。すると、Default Welcome Intentが恬咾靴泙后ここで、"<context>. Is it okay if I send that to your phone?"という鬴陲Googleアシスタントから卦ってきます。つまり、あなたのAndroid極挑に宥岑を僕っても措いですか燭搬いてきています。Ok、と卦しましょう。