简体   繁体   English

如何在对话期间强制谷歌动作切换语言?

[英]How do I force google action to switch the language during conversation?

I am building a bot for the google assistant using the action-on-google sdk and dialogflow in a webhook .我正在使用webhook 中action-on-google sdk和 dialogflow 为 google 助手构建一个机器人。

During the conversation, I need to give to the user the option to switch the language, as the implemented language detection doesn't work every time.在对话期间,我需要为用户提供切换语言的选项,因为实现的语言检测并非每次都有效。

Exemple, in the middle of the conversation:例如,在谈话中间:

  • Assistant: "do you want to ask your question in English or in French?"助理:“你想用英语还是法语提问?”
  • User: "in French"用户:“法语”
  • Assistant: "D'accord, j'écoute votre question..."助理:“D'accord,j'écoute votre 问题……”

All I have found is that I can get the language of the request with agent.locale , but I haven't found any way to set it.我所发现的只是我可以使用agent.locale获取请求的语言,但我还没有找到任何设置它的方法。

Any help?有什么帮助吗?

该平台不支持动态交换语言。

If you are using any SDK to call dialogflow then you can change language code based on some logic or some utterance (maybe identify the language and pass the language code accordingly).如果您使用任何 SDK 来调用对话流,那么您可以根据某种逻辑或某种话语更改语言代码(可能识别语言并相应地传递语言代码)。

For python SDK you can use below code and change the language_code accordingly.对于python SDK,您可以使用以下代码并相应地更改language_code

text_input = dialogflow.types.TextInput(text=text, language_code="en")
query_input = dialogflow.types.QueryInput(text=text_input)
response = session_client.detect_intent(session=session, query_input=query_input)

Hope it helps.希望能帮助到你。

暂无
暂无

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

相关问题 如果没有意图匹配,如何防止谷歌动作关闭对话? - How to prevent google action from closing the conversation if there is no intent match? 如何在 DialogFlow Fullfilment 中退出对话以进行操作 - How to exit conversation in DialogFlow Fullfilment for an Action 如何保护用作 Diaglogflow / Google Action 主机的 Google 云 function - How do I secure a Google cloud function being used as the host for a Diaglogflow / Google Action 如何使用 stackdriver 从对话流中检索对话数据? - How do I retrieve conversation's data from dialogflow using stackdriver? 使用 dialogflow 为 google 操作创建对话结束,并在默认后备意图后停止重复最后一个响应 - creating a end of conversation for a google action using dialogflow and stop repeating the last response after a default fallback intent 如何在 Dialogflow 中为多语言代理实现语言切换? - How to implement a language switch for a multilingual agent in Dialogflow? 我需要为出租车预订应用程序 google action 实现 google Transaction API 吗? 因为谷歌行动中没有支付流程 - do I need to implement google Transaction API for taxi booking app google action? because no payment flow in google action 你如何编写一个发布到本地网络 API 的 Google Action - How do you write a Google Action that posts to an API on the local network 如何结束我对助手的自定义操作? - How do I end my custom action on assistant? 我无法删除对谷歌项目的操作 - I can't delete action on google project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM