https://github.com/toshimaru/docomochatter
Docomo Zatsudan API Client
https://github.com/toshimaru/docomochatter
Last synced: about 1 year ago
JSON representation
Docomo Zatsudan API Client
- Host: GitHub
- URL: https://github.com/toshimaru/docomochatter
- Owner: toshimaru
- License: mit
- Created: 2015-04-18T15:09:32.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-08-13T17:41:26.000Z (almost 11 years ago)
- Last Synced: 2024-04-14T08:41:48.017Z (about 2 years ago)
- Language: CoffeeScript
- Homepage:
- Size: 160 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# docomochatter [](http://badge.fury.io/js/docomochatter)
Docomo Zatsudan(雑談) API Client.
# Requirement
* Node v0.12 or more
* Docomo API key (Get it [here](https://dev.smt.docomo.ne.jp/?p=about.index))
# Usage
Set docomo API key to the environment variable, `DOCOMO_API_KEY`, then instantiate the object and call `create_dialogue()` with your message. `create_dialogue()` returns [Promise](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise), so you can chain methods by using `.then()` and `.catch()`.
```js
var Docomochatter = require('docomochatter');
client = new Docomochatter(process.env.DOCOMO_API_KEY);
client.create_dialogue('hello').then(function(response){
console.log(response.utt);
}).catch(function(error){
console.log(error);
});
```
## via CoffeeScript
```coffee
Docomochatter = require('docomochatter')
client = new Docomochatter(process.env.DOCOMO_API_KEY)
client.create_dialogue('hello')
.then (response) ->
console.log response.utt
.catch (error) ->
console.log error
```
# Sample API response
```
{ utt: 'はろー',
yomi: 'はろー',
mode: 'dialog',
da: '30',
context: 'mnqsaABy9i7ByZBB6QxU9Q' }
```