如何存储和检索对话流的聊天记录? [英] How to store and retrieve the chat history of the dialogflow?

查看:356
本文介绍了如何存储和检索对话流的聊天记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将聊天从Google对话流重定向到人。为此,我想获取用户进行对话的历史记录。是否有存储历史记录的平台?如果是,如何访问它。如果没有,如何实现此功能。

I want to redirect the chat from Google dialogflow to a human. For this, I want to get the history of the conversation made by the user. Is there any platform where the history is being stored? If yes, how to access it. If not, how to achieve this functionality..

推荐答案

当前没有API可以检索会话历史记录。唯一的选择是自己保存历史记录。

There's no current API to retrieve session history. The only alternative is to save the history yourself.

您可以使用任何您熟悉的数据库,MySQL,MongoDB,甚至可以使用云托管数据库,例如 Firebase实时数据库

You can use any database you're familiar with, MySQL, MongoDB, or even a cloud hosted database such as Firebase Realtime Database

代码赢了不必太辛苦,每次用户发送新消息并且每次机器人应答时,您都必须使用正确的时间戳记和聊天ID将消息保存到数据库。

The code won't be too hard, everytime the user sends a new message and every time the bot answers, you will have to save that message to the database, with the right timestamp and chat ID.

用户重定向后,您将使用聊天ID获取该会话中的所有消息,并按时间戳进行排序,然后您将获得完整的聊天记录。

When the user is redirected, you will get all the messages from that session using the chat ID, sort them by timestamp, and you will have your complete chat history available.

一些可以帮助您的答案/教程:

Some answers/tutorials that might help you:

  • Best way to store chat messages in a database?
  • Storing chat messages inside a MySql table
  • Firebase Web chat tutorial

这篇关于如何存储和检索对话流的聊天记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆