简体   繁体   English

覆盖Google Assistant中的关键字以执行自定义操作?

[英]Override keyword in Google Assistant for custom action?

so I've been looking into making custom action with API.ai / Dialogflow and I've even tried some things out. 因此我一直在考虑使用API​​.ai / Dialogflow进行自定义操作,甚至尝试了一些方法。 One thing I'm a little confused about though is if it's possible to just have an "intent" that just sends whatever you say to a server (one that I would be hosting maybe on a rasp pi) AND can be triggered without having to "run" an app. 我有点困惑的一件事是,是否有可能只将您所说的内容发送到服务器(可能由我在rasp pi上发送)的“意图”并且可以触发而无需“运行”一个应用程序。 Most examples have the user say something like "OK google, run mySuperCoolApp" and THEN they can say whatever custom stuff they have set up. 大多数示例都让用户说“ OK google,run mySuperCoolApp”之类的话,然后他们可以说出自己设置的任何自定义内容。 I would like to be able to designate some keyword, (maybe "now"?) so that my intent will run, and then send whatever I said to some server I have set up with a webhook. 我希望能够指定一些关键字(也许是“现在”吗?),以便我的意图能够运行,然后将我说的内容发送到已通过Webhook设置的某些服务器上。

Example: "OK google, now do task 1" Then webhook gets triggered (because now is the first word) and sends that string to my server which then does something... 示例:“好吧,谷歌,现在执行任务1”然后触发webhook(因为现在是第一个单词)并将该字符串发送到我的服务器,该服务器然后执行某些操作...

Is this possible? 这可能吗?

This is possible, but only locally. 这是可能的,但仅限本地。 ie You could override only on the assistant running locally. 即您只能在本地运行的助手上覆盖。 This is done by intercepting the assistant to get the user's query and process it to do local fulfilment. 这是通过拦截助手以获取用户的查询并对其进行处理以实现本地实现来完成的。

You could do something like 你可以做类似的事情

def process_event(self, event):
    if event.type = EventType.ON_RECOGNIZING_SPEECH_FINISHED and event.args:
        query = event.args['text']
        if query == 'now do task':  # check if it matches your command
            self.assistant.stop_conversation() # Stop the usual reply from the Assistant 
            call_a_function() # This will call a function locally to perform a task

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

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