简体   繁体   English

Botman Studio对话时间

[英]Botman Studio conversation_cache_time

I'm doing a chatbot in the telegram API with Botman Studio that integrates laravel and php. 我正在Botman Studio中使用电报API做一个聊天机器人,该机器人集成了laravel和php。 I want to count the time the user uses the chatbot. 我想计算用户使用聊天机器人的时间。

When the user types "/ start" the conversation with the bot starts: 当用户键入“ / start”时,与机器人的对话开始:

在此处输入图片说明

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. 然后,如果您想知道用户花费了多少,只需减去endDate-beginDate。 You can use Carbon to make your life easier when manipulating Datetimes 您可以使用Carbon来简化Datetime的生活

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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