Cordova或离子聊天机器人实施

时间:2017-07-09 07:06:58

标签: cordova ionic-framework chat chatbot facebook-chatbot

我们使用angular js开发了cordova移动应用程序,我们正在尝试在我们的应用程序中添加聊天机器人(聊天服务)功能,任何人在cordova或混合移动应用程序中实现了相同的功能,请告诉我最好的方法实施

3 个答案:

答案 0 :(得分:0)

您可以使用api.aiwit.ai它们都有很多库,因此您可以将它与您选择的平台集成,在您可以使用http的情况下。 您还可以查看this github repo它包含一个使用api.ai在apache cordova应用程序中创建聊天机器人的示例

答案 1 :(得分:0)

在开始实施以下代码之前,请先阅读并清除有关意图,实体,成就和创建一个代理的基础知识。

https://dialogflow.com/docs/getting-started/basics

正如您在cordova的项目如下所示是快速启动实施 -

使用Cordova CLI安装api.ai插件:

cordova plugin add cordova-plugin-apiai

在代码

中的 onDeviceReady 功能中添加到 index.js 文件(通常位于 js 文件夹中)
ApiAIPlugin.init(
        {
            clientAccessToken: "YOUR_CLIENT_ACCESS_TOKEN", // insert your client access key here
            lang: "en" // set lang tag from list of supported languages
        }, 
        function(result) { /* success processing */ },
        function(error) { /* error processing */ }
    );

ApiAIPromises init方法将应用程序连接到“Dialogflow项目”,它需要一个客户端访问令牌,该令牌可在代理的内部设置中使用。

如果您想要发送文字请求,请添加以下代码:

function sendText(query_text) {
    try {
        ApiAIPlugin.requestText(
            {
                query: query_text
            },
            function (response) {
                // place your result processing here
                alert(JSON.stringify(response));
            },
            function (error) {
                // place your error processing here
                alert(error);
            });
    } catch (e) {
        alert(e);
    }
}

答案 2 :(得分:-1)

您可以检查此nodejs-dialogflow库。

这里是GitHub example,您可以用来入门并查看此link以获取更多详细信息

相关问题