Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hailiang-wang/directlineapi
Microsoft Botframework Direct Line API library
https://github.com/hailiang-wang/directlineapi
bot botframework chatbot microsoft
Last synced: about 1 month ago
JSON representation
Microsoft Botframework Direct Line API library
- Host: GitHub
- URL: https://github.com/hailiang-wang/directlineapi
- Owner: hailiang-wang
- Created: 2016-07-17T03:21:20.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-03T11:47:09.000Z (over 6 years ago)
- Last Synced: 2024-10-02T12:38:15.933Z (about 1 month ago)
- Topics: bot, botframework, chatbot, microsoft
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/directline-api
- Size: 13.7 KB
- Stars: 9
- Watchers: 3
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Microsoft Botframework Direct Line API library
[![chatoper banner][co-banner-image]][co-url][co-banner-image]: https://user-images.githubusercontent.com/3538629/42217321-3d5e44f6-7ef7-11e8-94e7-1574bfa1dbb8.png
[co-url]: https://www.chatopera.com# welcome
The Direct Line API is a simple REST API for connecting directly to a single bot. This API is intended for developers writing their own client applications, web chat controls, or mobile apps that will talk to their bot.https://docs.botframework.com/en-us/restapi/directline/
## Install
```
npm install directline-api
```## API
> Check out test/test.js for samples.
```
var client = require('directline-api');
// get a token
client.getToken(secret);// create a conversation
client.createConversation(token);// post a message in a conversation
client.postMessage(token, conversationId, {
text: 'YOUR_TEXT'
});// post a message with an userId, userId is your unique id for message sender.
client.ask(token, conversationId, {
text: 'YOUR_TEXT',
from: 'FROM_USERID'
});// post a file in a conversation
client.postFileMessage(token, conversationId, formData);// get messages in a conversation
client.getMessages(token, conversationId, [watermark]);// generate a new conversation and token
client.generateConversationAndToken(secret);// renew a token for a conversation
client.renewConversationToken(token, conversationId);// request with a text and get response
// https://docs.botframework.com/en-us/restapi/directline/#!/Conversations/Conversations_PostMessage
client.ask(token, conversationId, body);```
## Run Test
```
npm install
touch test/conf.json # ADD secret as 'DIRECT_LINE_SECRET'
npm test
```