restrict user messages after a certain number of conversation messages

I am using dialogflow cx messenger. I want set one user can send only 20 messages. I tried using custom code which is using webhook. 

So my approach is using webhook, Based on the particular session  I count messages turn and on every intent i call webhook.

My question is: Is it a good way to do this? or is there any other solutions please do let me know.

3 5 129
5 REPLIES 5

Hi,

What I would suggest is to have something in the middle: webchat <-> Proxy <-> dialogflow CX. The proxy is the one that is gonna check that. with this approach you will save a lot of money because basically you will avoid dialogflow cx interactions when users have +20 messages.

Best,

Xavi

Can you give detailed answer please? As i am new to dialogflow 

Well this is not a dialogflow solution itself. It is an architecture design where you deploy somewhere a "man in the middle", that has the logic you mention and forward the requests to diagloflow CX if needed

I am using dialogflow cx messenger. How can i set something in the middle?

you have to deploy a serverless function that gets the call from the webchat, does some logic to check the number of messages sent by that user and forwards the request to dialogflow CX if needed