dialogflow / dialogflow-fulfillment-nodejs

Dialogflow agent fulfillment library supporting v1&v2, 8 platforms, and text, card, image, suggestion, custom responses
Apache License 2.0
597 stars 282 forks source link

How to create session entities #304

Open newtonmunene99 opened 4 years ago

newtonmunene99 commented 4 years ago

When using the API directly you can set sessionEntityTypes to add session entities to the fulfillment. I haven't found a way to do this using dialogflow-fulfillment

TiagoGouvea commented 4 years ago

@newtonmunene99 did you found how to do it?

newtonmunene99 commented 4 years ago

No I did not. As this library is no longer maintained, I don't think it will get patched in. I just reverted back to using the api without a wrapper. I started working on an express js wrapper but I'm currently overwhelmed by work and it will take a while before I can finish working on it.

TiagoGouvea commented 4 years ago

Yeah, thing are a little slow here, I see.

I discovered a way to make it work.

    if (agent.requestSource == PLATFORMS.ACTIONS_ON_GOOGLE) {
      const conv = agent.conv();
      // Add Entities
      conv.sessionEntities.add({
        name: 'Opportunity',
        entities: [
          {
            value: 'a',
            synonyms: ['react']
          }
        ]
      });
      conv.sessionEntities.send();
    }

Calling agent.conv() you can get the conv object and it worked like expected.

Anyway, I'm using play with it to see how it works. Thanks, @newtonmunene99 for your quick response.

👍