0
votes

I have two quick questions about Dialogflow. I feel like these should be relatively straightforward issues, but I can't seem to find answers.

1) Is there a way to specify that an intent should be triggered if one context OR another is active? I know you can list multiple input contexts, but from my understanding, that intent will only be triggered if all those contexts are active. Is there any way to trigger the intent if any one of them is active?

2) Is there a way to assign a value to an entity using fulfillment? I think fulfillment usually works in the other direction, but I want to create an entity in Dialogflow, assign it a value through fulfillment, and then be able to simply call the entity in Dialogflow going forward so I don't have to continue to use fulfillment when it's not necessary. The reason I can't assign them through Dialogflow itself is that it's not based on user input.

I would really appreciate help with either of these questions.

Thanks so much

2

2 Answers

0
votes

Ans1. No. When the contexts that you set as input context and all active then only the intent is triggered OR if the event is fired.

if((all_input_contexts_active && user_says_active) || (event_is_active)){
   trigger intent
}else{
   trigger fallback intent
}<br><br>

Ans2. I don't think so. It "MAYBE" possible using Dialogflow SDK that you need to check. But using webhook it looks not supported.

0
votes

Trigger based on one context OR another

No, but you have some ways you can work around this. You're correct that the Input Context must match all of the contexts listed.

But you can also set more than one context as an Outgoing Context.

So, for example, if you have context-a and context-b currently, you can change things so you're setting both context-a and context-ab or you set both context-b and context-ab.

Then you can have an Intent that is triggered on context-ab, which you have set whenever you set -a or -b.

Assign an Entity value during Fulfillment

Yes. You can use Dialogflow's API to set a User Entity (sometimes called a Session Entity - they're the same thing). If you're using the V1 API, you would use the /userEntities endpoint. If you're using the V2 API (and you should), you would use the sessions.entityTypes method.

Either way, you would need to create the Entity Type first, but give it no actual entities to use (or some default ones) and then, as part of your fulfillment, update the Entity Type with the Entities and synonyms. Further calls from the user during that session will use the ones you've set.