GithubHelp home page GithubHelp logo

ojacques / hubot-apiai Goto Github PK

View Code? Open in Web Editor NEW
14.0 6.0 13.0 249 KB

Add smartness and conversational UX to Hubot with API.AI as back-end

Home Page: https://www.npmjs.com/package/hubot-apiai

License: Apache License 2.0

JavaScript 14.49% CoffeeScript 77.17% Shell 8.34%
hubot-scripts hubot api-ai nlu natural-language-understanding chatbot chatbotai

hubot-apiai's Introduction

Add smartness to hubot with API.AI

A hubot script that adds conversational user experience with api.ai as back-end.

When you talk to Hubot, this script sends the text to api.ai, which in turns handles the dialog and detects intents and parameters. Finally, the script emits an event (robot.emit) so that it can be consumed by other scripts.

example

See src/apiai.coffee for full documentation.

Installation

In hubot project repo, run:

npm install hubot-apiai --save

Then add hubot-apiai to your external-scripts.json:

[
  "hubot-apiai"
]

Configuration variable

API_AI_CLIENT_ACCESS_TOKEN: API AI client access token which you get from https://console.api.ai/api-client/

Create listener scripts

hubot-apiai will emit events which correspond to intents that you describe in API.AI.

Let's say that you have an intent called help-me in API.AI. You can create an hubot script which will act on help-me intents:

module.exports = (robot) ->
  robot.on "help-me", (msg, params) ->
    # Your code here

The parameters from the intent are passed as part of Hubot's event.

NPM Module

https://www.npmjs.com/package/hubot-apiai

TODO

  • Add tests

hubot-apiai's People

Contributors

ojacques avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

hubot-apiai's Issues

Slack adapter and hubot-apiai: sessionId Parameter

Hello:

when using the slackadapter and api.ai i get the following error:
[Thu Oct 05 2017 12:10:00 GMT+0200 (CEST)] DEBUG Calling API.AI with 'hello' and session undefined [...] statusCode: 400, responseBody: '{\n "id": "xxx-xxxx-xxxx",\n "timestamp": "2017-10-05T10:09:12.366Z",\n "lang": "en",\n "status": {\n "code": 400,\n "errorType": "bad_request",\n "errorDetails": "Required \'sessionId\' parameter is empty."\n }\n}', name: 'ServerError', message: 'Wrong response status code.' }

when modifing the following line:

else if robot.adapterName == 'slack'

to = "slackx" and forcing the fallback mechanism, it works fine. Any idea whats wrong there?

how to call a api and print its json responce?

hey! #helpplease
i am developing a bot for my company and i want to call the api in natural language and print its json responce as the result, as far as now, im able to talk to my bot wit api.ai in back end , but i need help in knowing how to call a api and print its json responce.

example:
user: bot can you show me my storage space left in my VM?
bot should call a api and return json responce to user
bot: here is the answer to your question..
displays json responce

behind proxy

Cannot use this behind a proxy... I tried to configured proxy in many different ways but it does not work i get this error:
Error: write EPROTO 140736486470592:error:14077419:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert access denied:../deps/openssl/openssl/ssl/s23_clnt.c:769:

at exports._errnoException (util.js:1018:11)
at WriteWrap.afterWrite (net.js:800:14)

how to extract values of entities/parameter name in api.ai?

hey! thanks for your previous reply it helped me a lot,
I have one more query , I need to extract the values of entities/parameter name in api.ai so that i can pass those values in a POST statement in my companies internal API. I have attached a screen shot of my project. i have highlighted the values i need to extract. is it something like entity.value ?

please help me out
apiai

thanks in advance :)

API.ai v2 support?

It seems using the client access token is only supported in v1 of the api. Are you planning on supporting v2 that uses service accounts?

Why do the hubot name/alias has to prefix the sentence for response ?

Hi Olivier,

first of, thanks a lot for your amazing work, hubot-apiai is great and helps me a lot!
Question title says it all, is there a way to pass a request to the bot without calling its name each time? Although I can understand the use case for it (group chat), I feel the "conversation" would flow more smoothly without it in 1:1 chats with the bot.

Thanks!
Guillaume

Setting up hubot-apiai

Hello, I just want to make sure I'm setting this up right, because it doesn't seem to be giving any responses, though I get what I inputted into my api.ai bot.

I put the API_AI_CLIENT_ACCESS_TOKEN and the token into bin/hubot file, with a line export API_AI_CLIENT_ACCESS_TOKEN=abc123

I have a script.coffee that looks like this

robot.on "greeting", (msg) ->
res.reply "Hi! To find out what I can do, say @bot display help. You can simply highlight that and quote it back to me as well."

In my api.ai there is an intent greeting, with hi recognized, and hi as a response. Do I just put all the dialogue that I want it to say in the api.ai and not have any conversation type stuff in the script?

When I boot up hubot with my adapter for discourse, I get this error

[Sat Mar 03 2018 19:32:29 GMT+0000 (UTC)] INFO Constructor
[Sat Mar 03 2018 19:32:29 GMT+0000 (UTC)] INFO Run
[Sat Mar 03 2018 19:32:29 GMT+0000 (UTC)] ERROR Not enough parameters provided. I need a username, key, and server

Licensing

Hi ojacques,

Have found this module very helpful. However, I noticed that you do not have any licensing in place and was wondering if you would be willing to make your intentions clear in that respect. Thanks in advance for considering this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.