[英]sending payload to dialogflow from dialogflow android sdk
I am using Android client of dialogflow - https://github.com/dialogflow/dialogflow-android-client 我正在使用dialogflow的Android客户端-https: //github.com/dialogflow/dialogflow-android-client
I would like to know how to send payload, lat, lon from my android application to dialogflow. 我想知道如何将有效载荷,经纬度,经度从我的android应用程序发送到dialogflow。 some one could help on this?
有人可以帮上忙吗?
Update 更新
I am able to pass payload when I use the code like below, 使用以下代码时,我可以传递有效负载,
final AIRequest aiRequest = new AIRequest();
AIOriginalRequest aiO = new AIOriginalRequest();
HashMap<String, String> hm = new HashMap<String, String>();
hm.put("element_1", "8888");
hm.put("element_2", "abcd");
aiO.setData(hm);
aiRequest.setOriginalRequest(aiO);
aiRequest.setQuery("find Cheese");
and I am getting this in server as below, 我在下面的服务器中得到这个,
{
"responseId": "ddsds-qwq-qwqwq-wqwqwq",
"session": "<<session>>",
"queryResult": {
"languageCode": "en",
"intentDetectionConfidence": "0.93",
"allRequiredParamsPresent": "true",
"parameters": {
"item": "Cheese"
},
"fulfillmentMessages": [{
"text": {
"text": [""]
}
}],
"queryText": "find Cheese",
"intent": {
"name": "<<session>>",
"displayName": "item-req"
}
},
"originalDetectIntentRequest": {
"payload": {
"element_2": "abcd",
"element_1": "8888"
}
}
}
But as I am using AIService and using startListening method of that, I am not able to set the AIRequest and setOriginalRequest. 但是由于我正在使用AIService并使用其中的startListening方法,因此无法设置AIRequest和setOriginalRequest。 There is no way to set OriginalRequest if are using AIService and startListening.
如果正在使用AIService和startListening,则无法设置OriginalRequest。 The Dialogflow sdk is automatically doing this.
Dialogflow SDK自动执行此操作。
Any one faced such situation or solved this? 有人遇到这种情况或解决了这个问题吗?
There is no direct way to pass such information other than using system entities. 除了使用系统实体之外,没有直接的方式来传递此类信息。 You may need to do a hack if you can't find an entity to extract your data.
如果找不到要提取数据的实体,则可能需要进行黑客入侵。 In my project, I wanted to send a custom UUID.
在我的项目中,我想发送一个自定义的UUID。 Now there was no specific system entity present in the Dialogflow which I could have used to extract the UUID so I used the simple approach of appending UUID to the Android response to Dialogflow and manually extracted it using ||
现在Dialogflow中不存在可以用来提取UUID的特定系统实体,因此我使用了将UUID附加到对Dialogflow的Android响应并使用||手动提取的简单方法。 separator.
分隔器。
You could do the following: 您可以执行以下操作:
'Hi! My name is Abhinav Tyagi. 77.0000 28.0000'
'Hi! My name is Abhinav Tyagi. 77.0000 28.0000'
'Hi! My name is Abhinav Tyagi. 77.0000 28.0000'
'Hi! My name is Abhinav Tyagi. 77.0000 28.0000'
would be my generated message. 'Hi! My name is Abhinav Tyagi. 77.0000 28.0000'
将是我生成的消息。 'Hi! My name is Abhinav Tyagi.||{"lon":"77.0000", "lat":"28.0000"}'
'Hi! My name is Abhinav Tyagi.||{"lon":"77.0000", "lat":"28.0000"}'
'Hi! My name is Abhinav Tyagi.||{"lon":"77.0000", "lat":"28.0000"}'
would be my generated message. 'Hi! My name is Abhinav Tyagi.||{"lon":"77.0000", "lat":"28.0000"}'
将是我生成的消息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.