actions-on-google / actions-on-google-java

Java/Kotlin library for Actions on Google
Apache License 2.0
287 stars 39 forks source link

Add Session Entities #32

Closed cbeaujoin closed 4 years ago

cbeaujoin commented 5 years ago

Hi,

Historically, sessions entities were managed from the dialogflow API, now they can be created directly in the webhook : https://groups.google.com/forum/#!msg/dialogflow-enterprise-edition-users/K-wSIgRyT90/-BkkFYLfAgAJ

In order to simplify session entity building could you had the same model as availlable with google-cloud-dialogflow (https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-clients/google-cloud-dialogflow) :

It concerns the SessionEntityType class.

Then once builded it can be added to the webhook response like this :

        SessionEntityType sessionEntityType = SessionEntityType.newBuilder()
                .setEntityOverrideMode(SessionEntityType.EntityOverrideMode.ENTITY_OVERRIDE_MODE_OVERRIDE)
                .setName(sessionId + "/entityTypes/" + entityName)
                .addAllEntities(entities)
                .build();

            responseBuilder.setWebhookResponse$actions_on_google(
                    Optional.ofNullable(responseBuilder.getWebhookResponse$actions_on_google())
                            .orElse(new WebhookResponse())
                            .set("sessionEntityTypes", Lists.newArrayList(sessionEntityType))
            );
cbeaujoin commented 4 years ago

Update : A documentation has been released: https://cloud.google.com/dialogflow/docs/entities-session#creating_session_entities_with_fulfillment

taycaldwell commented 4 years ago

Support for Session Entity Types has been added in Release v1.8.0