简体   繁体   中英

Botman Studio conversation_cache_time

I'm doing a chatbot in the telegram API with Botman Studio that integrates laravel and php. I want to count the time the user uses the chatbot.

When the user types "/ start" the conversation with the bot starts:

在此处输入图片说明

I want from there to start counting the time to enter it into my database in order to know how long users interact with the chatbot.

How could I do this in my conversations?

 <?php return [ /* |-------------------------------------------------------------------------- | Conversation Cache Time |-------------------------------------------------------------------------- | | BotMan caches each started conversation. This value defines the | number of minutes that a conversation will remain stored in | the cache. | */ 'conversation_cache_time' => 1, /* |-------------------------------------------------------------------------- | User Cache Time |-------------------------------------------------------------------------- | | BotMan caches user information of the incoming messages. | This value defines the number of minutes that this | data will remain stored in the cache. | */ 'user_cache_time' => 1, ]; 

Here I establish that after a minute of inactivity, the conversation stops, I want that at the same time that the conversation in the database is stopped the time is stored. How could I establish a condition for it?

Well, if you have a way to know that user quit the conversation, you can store the datetime of when user started a conversation and store datetime of when user ended the conversation. Then if you want to know how much user spent, just subtract endDate - beginDate. You can use Carbon to make your life easier when manipulating Datetimes

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM