Is there a way to retrieve the conversation history in Dialogflow?

老子叫甜甜 提交于 2020-03-02 03:55:25

问题


Is there a way to obtain the full conversation between the user and agent. Pretty much similar to what I get by clicking the history tag but programmatically. The point is to save the interaction between user and agent as text.

Thank you guys in advanced!


回答1:


There's no API to retrieve the history from Dialogflow directly. But what you can do is enable logging.

Agent Settings > General > Log Settings > Log interactions to Google Cloud

And all the interactions will be logged into Google Stackdriver, which has an API where you will be able to retrieve all the logs, and hence the chat history.

https://cloud.google.com/logging/docs/reference/v2/rest/

This is how the logs are stored in Stackdriver

{
  insertId: "19ignahfzlu2o7"
  labels: {
    protocol: "V2BETA1"
    request_id: "3033c2e3-7cab-4a00-b2b7-207be8d22366"
    type: "dialogflow_request"
  }
  logName: "projects/dialogflowproject-ca57b/logs/dialogflow_agent"
  receiveTimestamp: "2019-03-27T12:44:42.547531753Z"
  resource: {
    labels: {
      project_id: "dialogflowproject-ca57b"
    }
    type: "global"
  }
  severity: "INFO"
  textPayload: "Dialogflow gRPC Request : session: projects / dialogflowproject - ca57b / agent / sessions / 53 d451c1 - 40 f5 - c00e - cbbd - 178e ff32b971 "
  query_params {
    time_zone: "America/Buenos_Aires"
  }
  query_input {
    text {
      text: "hi"
      language_code: "en"
    }
  }
  "  
  timestamp: "2019-03-27T12:44:42.420Z"
  trace: "53d451c1-40f5-c00e-cbbd-178eff32b971"
}

You can then retrieve the session from there, and build the whole chat history.


The other alternative is to save the interactions to a database when they are happening if the messages goes through your server first, which may not be your case.



来源:https://stackoverflow.com/questions/55377439/is-there-a-way-to-retrieve-the-conversation-history-in-dialogflow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!