Skip to content
This repository was archived by the owner on Aug 12, 2022. It is now read-only.

Commit 0cd2d13

Browse files
author
Stefan Selent
committed
Remove recast name
1 parent c67aa16 commit 0cd2d13

18 files changed

+139
-133
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2016 RecastAI
3+
Copyright (c) 2016 SAP Conversational AI
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+31-29
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,98 @@
11
<p align="center">
2-
<img src="misc/logo2.png" />
2+
<img src="https://cdn.cai.tool.sap/brand/sapcai/sap-cai-black.svg" />
33
</p>
44

5-
| [Installation](#installation) | [Sample Projects](#sample-projects) | [Resources]( #resources) | [Getting Started on Recast.AI]( #getting-started-with-recastai) | [License](#license) |
5+
| [Installation](#installation) | [Sample Projects](#sample-projects) | [Resources]( #resources) | [Getting Started on SAP Conversational AI]( #getting-started-with-sap-conversational-ai) | [License](#license) |
66
|---|---|---|---|---|
77
<div>
8-
<a href="https://slack.recast.ai/">💬 Questions / Comments? Join the discussion on our community Slack channel!</a>
8+
<a href="https://slack.cai.tool.sap">💬 Questions / Comments? Join the discussion on our community Slack channel!</a>
99
</div>
1010

11-
# Recast.AI - SDK Node.js
12-
Recast.AI official SDK in Node.js
11+
# SAP Conversational AI - SDK Node.js
12+
SAP Conversational AI official SDK in Node.js
1313

1414
## Synospis
1515

16-
This module is a wrapper around the [Recast.AI](https://recast.ai/) [API](https://man.recast.ai/) API, and allows you to:
17-
* [Analyse your text](https://github.com/RecastAI/SDK-NodeJS/wiki/Analyse-text)
18-
* [Manage your conversation](https://github.com/RecastAI/SDK-NodeJS/wiki/Manage-your-conversation)
19-
* [Receive and send messages](https://github.com/RecastAI/SDK-NodeJS/wiki/Receive-and-send-messages)
16+
This module is a wrapper around the [SAP Conversational AI](https://cai.tool.sap/) [API](https://cai.tool.sap/docs/) API, and allows you to:
17+
* [Analyse your text](https://github.com/SAPConversationalAI/SDK-NodeJS/wiki/Analyse-text)
18+
* [Manage your conversation](https://github.com/SAPConversationalAI/SDK-NodeJS/wiki/Manage-your-conversation)
19+
* [Receive and send messages](https://github.com/SAPConversationalAI/SDK-NodeJS/wiki/Receive-and-send-messages)
2020

2121
## Installation
2222

2323
Install the package using npm, as shown below:
2424
```bash
25-
npm install --save recastai
25+
npm install --save sapcai
2626
```
2727

28-
You can now use the SDK in your code.
28+
You can now use the SDK in your code. All you need is your bot's token. In case you have enabled our versioning feature in the settings of your bot, you can refer to our [versioning documentation](https://cai.tools.sap/docs/concepts/versioning) to learn how to select the appropriate token for you versions and environments.
29+
30+
_Note:_ The `train` API needs to be initialized with the bot version. If versioning is not enabled for the bot, the default `v1` should be used. For more info see our documentation on [versioning](https://cai.tools.sap/docs/concepts/versioning).
2931

3032
#### ES5
3133

3234
Using the entire SDK:
3335
```js
34-
var recastai = require('recastai').default
36+
var sapcai = require('sapcai').default
3537

36-
var client = new recastai('YOUR_TOKEN')
38+
var client = new sapcai('YOUR_TOKEN')
3739
```
3840

3941
Extracting one single API:
4042
```js
41-
var recastai = require('recastai').default
43+
var sapcai = require('sapcai').default
4244

43-
var converse = new recastai.converse('YOUR_TOKEN')
45+
var converse = new sapcai.converse('YOUR_TOKEN')
4446
```
4547

4648
#### ES6
4749

4850
Using the entire SDK:
4951
```js
50-
import recastai from 'recastai'
52+
import sapcai from 'sapcai'
5153

52-
const client = new recastai('YOUR_TOKEN')
54+
const client = new sapcai('YOUR_TOKEN')
5355
```
5456

5557
Extracting one single API:
5658
```js
57-
import { converse } from 'recastai'
59+
import { converse } from 'sapcai'
5860

5961
const clientConverse = new converse('YOUR_TOKEN')
6062
```
6163

6264
## Sample projects
6365

64-
Check out our [NodeJS starter-kit](https://github.com/RecastAI/starter-NodeJS) for a usage example of the SDK.
66+
Check out our [NodeJS starter-kit](https://github.com/SAPConversationalAI/starter-NodeJS) for a usage example of the SDK.
6567

6668
## Resources
67-
* [Bot Builder Guide](https://recast.ai/docs): Best practices and tips to use the Recast.AI platform
68-
* [API Documentation](https://man.recast.ai/)
69-
* [Your first bot](https://blog.recast.ai/build-your-first-bot-with-recast-ai/) - Build your first bot with Bot Builder
70-
* [Advanced chatbot tutorial(Moviebot)](https://recast.ai/blog/nodejs-chatbot-movie-bot/) - Overview of how to get started building your bot's server
69+
* [Bot Builder Guide](https://cai.tool.sap/docs) - Best practices and tips to use the SAP Conversational AI platform
70+
* [API Documentation](https://cai.tool.sap/docs/)
71+
* [Your first bot](https://cai.tool.sap/blog/build-your-first-bot-with-recast-ai/) - Build your first bot with Bot Builder
72+
* [Advanced chatbot tutorial(Moviebot)](https://cai.tool.sap/blog/nodejs-chatbot-movie-bot/) - Overview of how to get started building your bot's server
7173

7274
## Author
7375

74-
Jérôme Houdan, jerome.houdan@recast.ai
76+
Jérôme Houdan, jerome.houdan@sap.com
7577

76-
You can follow us on Twitter at [@recastai](https://twitter.com/recastai) for updates and releases.
78+
You can follow us on Twitter at [@sapcai](https://twitter.com/sapcai) for updates and releases.
7779

78-
## Getting started with Recast.AI
80+
## Getting started with SAP Conversational AI
7981

8082
We build products to help enterprises and developers have a better understanding of user inputs.
8183

8284
- **NLP API**: a unique API for text processing, and augmented training.
83-
- **Bot Building Tools**: all you need to create smart bots powered by Recast.AI's NLP API. Design even the most complex conversation flow, use all rich messaging formats and connect to external APIs and services.
85+
- **Bot Building Tools**: all you need to create smart bots powered by SAP Conversational AI's NLP API. Design even the most complex conversation flow, use all rich messaging formats and connect to external APIs and services.
8486
- **Bot Connector API**: standardizes the messaging format across all channels, letting you connect your bots to any channel in minutes.
8587

8688
Learn more about:
8789

88-
| [API Documentation](https://recast.ai/docs/api-reference/) | [Discover the platform](https://recast.ai/docs/create-your-bot) | [First bot tutorial](https://recast.ai/blog/build-your-first-bot-with-recast-ai/) | [Advanced NodeJS tutorial](https://recast.ai/blog/nodejs-chatbot-movie-bot/) | [Advanced Python tutorial](https://recast.ai/blog/python-cryptobot/) |
90+
| [API Documentation](https://cai.tool.sap/docs/api-reference/) | [Discover the platform](https://cai.tool.sap/docs/create-your-bot) | [First bot tutorial](https://cai.tool.sap/blog/build-your-first-bot-with-recast-ai/) | [Advanced NodeJS tutorial](https://cai.tool.sap/blog/nodejs-chatbot-movie-bot/) | [Advanced Python tutorial](https://cai.tool.sap/blog/python-cryptobot/) |
8991
|---|---|---|---|---|
9092

9193
## License
9294

93-
Copyright (c) [2018] [Recast.AI](https://recast.ai)
95+
Copyright (c) [2018] [SAP Conversational AI](https://cai.tool.sap)
9496

9597
Permission is hereby granted, free of charge, to any person obtaining a copy
9698
of this software and associated documentation files (the "Software"), to deal

index.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
declare module 'recastai' {
1+
declare module 'sapcai' {
22
export interface Message {
33
chatId: string;
44
content: string;
55
conversationId: string;
6-
recastToken: string;
6+
sapcaiToken: string;
77
senderId: string;
88
type: string;
99
addReply(replies: object[]): void;

package.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "recastai",
2+
"name": "sapcai",
33
"version": "4.0.0",
4-
"description": "Recast.AI official SDK in NodeJs",
4+
"description": "SAP Conversational AI official SDK in NodeJs",
55
"main": "lib/index.js",
66
"types": "index.d.ts",
77
"directories": {
@@ -15,17 +15,17 @@
1515
},
1616
"repository": {
1717
"type": "git",
18-
"url": "git+https://github.com/RecastAI/SDK-NodeJs.git"
18+
"url": "git+https://github.com/SAPConversationalAI/SDK-NodeJs.git"
1919
},
2020
"keywords": [
21-
"recastai"
21+
"sapcai"
2222
],
23-
"author": "Jerome Houdan <jerome.houdan@recast.ai> (https://recast.ai)",
23+
"author": "Jerome Houdan <jerome.houdan@sap.com> (https://cai.tool.sap)",
2424
"license": "MIT",
2525
"bugs": {
26-
"url": "https://github.com/RecastAI/SDK-NodeJs/issues"
26+
"url": "https://github.com/SAPConversationalAI/SDK-NodeJs/issues"
2727
},
28-
"homepage": "https://github.com/RecastAI/SDK-NodeJs#readme",
28+
"homepage": "https://github.com/SAPConversationalAI/SDK-NodeJs#readme",
2929
"devDependencies": {
3030
"babel-cli": "^6.22.0",
3131
"babel-eslint": "^6.0.4",

spec/test.js

+34-31
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ import nock from 'nock'
66
import path from 'path'
77

88
import Client from '../src'
9-
import { Entity, Conversation, RecastError, Response } from '../src/apis/resources'
9+
import { Entity, Conversation, SapcaiError, Response } from '../src/apis/resources'
1010
import json from './resource/json'
1111
import conversationJson from './resource/conversationJson'
1212

13-
const TOKEN = process.env.RECAST_TOKEN || 'FAKE_TOKEN'
13+
const TOKEN = process.env.SAPCAI_TOKEN || 'FAKE_TOKEN'
1414
const LANGUAGE = 'FR'
15-
const BOT_SLUG = process.env.RECAST_BOT_SLUG || 'FAKE_BOT_SLUG'
16-
const USER_SLUG = process.env.RECAST_USER_SLUG || 'FAKE_USER_SLUG'
15+
const BOT_SLUG = process.env.SAPCAI_BOT_SLUG || 'FAKE_BOT_SLUG'
16+
const USER_SLUG = process.env.SAPCAI_USER_SLUG || 'FAKE_USER_SLUG'
17+
const BOT_VERSION = process.env.SAPCAI_BOT_VERSION || 'v1'
1718

1819
describe('Client class', () => {
1920

@@ -38,7 +39,7 @@ describe('Client class', () => {
3839

3940
it('should be instanciable all params', () => {
4041
expect(new Client(TOKEN, LANGUAGE, USER_SLUG, BOT_SLUG)).to.be.an.instanceof(Client)
41-
expect(new Client(TOKEN, LANGUAGE, USER_SLUG, BOT_SLUG).train).to.not.be.undefined
42+
expect(new Client(TOKEN, LANGUAGE, BOT_VERSION, USER_SLUG, BOT_SLUG).train).to.not.be.undefined
4243
})
4344

4445
// Attribute
@@ -57,12 +58,12 @@ describe('Client class', () => {
5758
const client = new Client(TOKEN)
5859

5960
describe('textRequest', () => {
60-
nock('https://api.recast.ai')
61+
nock('https://api.cai.tool.sap')
6162
.post('/v2/request')
6263
.once()
6364
.reply(200, json)
6465

65-
nock('https://api.recast.ai')
66+
nock('https://api.cai.tool.sap')
6667
.post('/v2/request')
6768
.once()
6869
.reply(404, 'invalid parameter')
@@ -93,12 +94,12 @@ describe('Client class', () => {
9394
})
9495

9596
describe('textConversation', () => {
96-
nock('https://api.recast.ai')
97+
nock('https://api.cai.tool.sap')
9798
.post('/v2/converse')
9899
.once()
99100
.reply(200, json)
100101

101-
nock('https://api.recast.ai')
102+
nock('https://api.cai.tool.sap')
102103
.post('/v2/converse')
103104
.once()
104105
.reply(404, 'invalid parameter')
@@ -201,9 +202,9 @@ describe('Entity class', () => {
201202
})
202203
})
203204

204-
describe('RecastError', () => {
205+
describe('SapcaiError', () => {
205206
it('should throw an error', () => {
206-
assert.throws(() => { RecastError() }, TypeError, 'Cannot call a class as a function')
207+
assert.throws(() => { SapcaiError() }, TypeError, 'Cannot call a class as a function')
207208
})
208209
})
209210

@@ -246,14 +247,14 @@ describe('Conversation class', () => {
246247
})
247248

248249
describe('Train class', () => {
249-
const client = new Client(TOKEN, LANGUAGE, USER_SLUG, BOT_SLUG)
250+
const client = new Client(TOKEN, LANGUAGE, BOT_VERSION, USER_SLUG, BOT_SLUG)
250251
describe('Bots api', () => {
251-
nock('https://api.recast.ai')
252+
nock('https://api.cai.tool.sap')
252253
.get(`/v2/users/${USER_SLUG}/bots/${BOT_SLUG}`)
253254
.once()
254255
.reply(200, 'success')
255256

256-
nock('https://api.recast.ai')
257+
nock('https://api.cai.tool.sap')
257258
.put(`/v2/users/${USER_SLUG}/bots/${BOT_SLUG}`, { name: 'foo' })
258259
.once()
259260
.reply(200, {})
@@ -276,17 +277,17 @@ describe('Train class', () => {
276277
})
277278

278279
describe('Entities api', () => {
279-
nock('https://api.recast.ai')
280-
.get(`/v2/users/${USER_SLUG}/bots/${BOT_SLUG}/entities`)
280+
nock('https://api.cai.tool.sap')
281+
.get(`/v2/users/${USER_SLUG}/bots/${BOT_SLUG}/versions/${BOT_VERSION}/dataset/entities`)
281282
.once()
282283
.reply(200, 'success')
283284

284-
nock('https://api.recast.ai')
285+
nock('https://api.cai.tool.sap')
285286
.get('/v2/entities')
286287
.once()
287288
.reply(200, 'success')
288289

289-
nock('https://api.recast.ai')
290+
nock('https://api.cai.tool.sap')
290291
.post('/v2/entities', { slug: 'foo' })
291292
.once()
292293
.reply(200, {})
@@ -322,30 +323,32 @@ describe('Train class', () => {
322323
const synonymSlug = 'mySynonym'
323324
const data = { slug: 'myGazette' }
324325

325-
nock('https://api.recast.ai')
326-
.get(`/v2/users/${USER_SLUG}/bots/${BOT_SLUG}/entities`)
326+
nock('https://api.cai.tool.sap')
327+
.get(`/v2/users/${USER_SLUG}/bots/${BOT_SLUG}/versions/${BOT_VERSION}/dataset/gazettes`)
327328
.once().reply(200, 'success')
328-
.get(`/v2/users/${USER_SLUG}/bots/${BOT_SLUG}/gazettes`)
329+
.get(`/v2/users/${USER_SLUG}/bots/${BOT_SLUG}/versions/${BOT_VERSION}/dataset/gazettes/${slug}`)
329330
.once().reply(200, 'success')
330-
.get(`/v2/users/${USER_SLUG}/bots/${BOT_SLUG}/logs/${slug}`)
331+
.delete(`/v2/users/${USER_SLUG}/bots/${BOT_SLUG}/versions/${BOT_VERSION}/dataset/gazettes/${slug}`)
331332
.once().reply(200, 'success')
332-
.delete(`/v2/users/${USER_SLUG}/bots/${BOT_SLUG}/logs/${slug}`)
333+
.get(`/v2/users/${USER_SLUG}/bots/${BOT_SLUG}/versions/${BOT_VERSION}/dataset/logs/${slug}`)
333334
.once().reply(200, 'success')
334-
.post(`/v2/users/${USER_SLUG}/bots/${BOT_SLUG}/gazettes`, data)
335+
.delete(`/v2/users/${USER_SLUG}/bots/${BOT_SLUG}/versions/${BOT_VERSION}/dataset/logs/${slug}`)
335336
.once().reply(200, 'success')
336-
.put(`/v2/users/${USER_SLUG}/bots/${BOT_SLUG}/gazettes`, data)
337+
.post(`/v2/users/${USER_SLUG}/bots/${BOT_SLUG}/versions/${BOT_VERSION}/dataset/gazettes`, data)
337338
.once().reply(200, 'success')
338-
.get(`/v2/users/${USER_SLUG}/bots/${BOT_SLUG}/gazettes/${slug}/synonyms`)
339+
.put(`/v2/users/${USER_SLUG}/bots/${BOT_SLUG}/versions/${BOT_VERSION}/dataset/gazettes`, data)
339340
.once().reply(200, 'success')
340-
.get(`/v2/users/${USER_SLUG}/bots/${BOT_SLUG}/gazettes/${gazetteSlug}/synonyms/${synonymSlug}`)
341+
.get(`/v2/users/${USER_SLUG}/bots/${BOT_SLUG}/versions/${BOT_VERSION}/dataset/gazettes/${slug}/synonyms`)
341342
.once().reply(200, 'success')
342-
.post(`/v2/users/${USER_SLUG}/bots/${BOT_SLUG}/gazettes/${slug}/synonyms`, data)
343+
.get(`/v2/users/${USER_SLUG}/bots/${BOT_SLUG}/versions/${BOT_VERSION}/dataset/gazettes/${gazetteSlug}/synonyms/${synonymSlug}`)
343344
.once().reply(200, 'success')
344-
.post(`/v2/users/${USER_SLUG}/bots/${BOT_SLUG}/gazettes/${slug}/synonyms/bulk_create`, [data])
345+
.post(`/v2/users/${USER_SLUG}/bots/${BOT_SLUG}/versions/${BOT_VERSION}/dataset/gazettes/${slug}/synonyms`, data)
345346
.once().reply(200, 'success')
346-
.put(`/v2/users/${USER_SLUG}/bots/${BOT_SLUG}/gazettes/${gazetteSlug}/synonyms/${synonymSlug}`, data)
347+
.post(`/v2/users/${USER_SLUG}/bots/${BOT_SLUG}/versions/${BOT_VERSION}/dataset/gazettes/${slug}/synonyms/bulk_create`, [data])
347348
.once().reply(200, 'success')
348-
.delete(`/v2/users/${USER_SLUG}/bots/${BOT_SLUG}/gazettes/${gazetteSlug}/synonyms/${synonymSlug}`)
349+
.put(`/v2/users/${USER_SLUG}/bots/${BOT_SLUG}/versions/${BOT_VERSION}/dataset/gazettes/${gazetteSlug}/synonyms/${synonymSlug}`, data)
350+
.once().reply(200, 'success')
351+
.delete(`/v2/users/${USER_SLUG}/bots/${BOT_SLUG}/versions/${BOT_VERSION}/dataset/gazettes/${gazetteSlug}/synonyms/${synonymSlug}`)
349352
.once().reply(200, 'success')
350353

351354
it('Should list gazettes', done => {

src/apis/build/index.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -31,34 +31,34 @@ export default class Build {
3131
return request.send(data).then(res => res.body.results)
3232
}
3333

34-
getConversation = (user, bot, conversationId, options = {}) => {
34+
getConversation = (user, bot, version, conversationId, options = {}) => {
3535
const token = options.token || this.token
3636
const proxy = options.proxy
3737

38-
const request = agent('GET', `${constants.DIALOG_ENDPOINT}/users/${user}/bots/${bot}/builders/v1/conversation_states/${conversationId}`)
38+
const request = agent('GET', `${constants.DIALOG_ENDPOINT}/users/${user}/bots/${bot}/versions/${version}/builder/v1/conversation_states/${conversationId}`)
3939
.set('Authorization', `Token ${token}`)
4040
if (proxy) { request.proxy(proxy) }
4141
return request.send()
4242
}
4343

44-
updateConversation = (user, bot, conversationId, data = {}, options = {}) => {
44+
updateConversation = (user, bot, version, conversationId, data = {}, options = {}) => {
4545
const token = options.token || this.token
4646
const proxy = options.proxy
4747
if (data.memory && data.memory.constructor !== Object) {
4848
return Promise.reject('Invalid memory parameter')
4949
}
5050

51-
const request = agent('PUT', `${constants.DIALOG_ENDPOINT}/users/${user}/bots/${bot}/builders/v1/conversation_states/${conversationId}`)
51+
const request = agent('PUT', `${constants.DIALOG_ENDPOINT}/users/${user}/bots/${bot}/versions/${version}/builder/v1/conversation_states/${conversationId}`)
5252
.set('Authorization', `Token ${token}`)
5353
if (proxy) { request.proxy(proxy) }
5454
return request.send(data)
5555
}
5656

57-
deleteConversation = (user, bot, conversationId, options = {}) => {
57+
deleteConversation = (user, bot, version, conversationId, options = {}) => {
5858
const token = options.token || this.token
5959
const proxy = options.proxy
6060

61-
const request = agent('DELETE', `${constants.DIALOG_ENDPOINT}/users/${user}/bots/${bot}/builders/v1/conversation_states/${conversationId}`)
61+
const request = agent('DELETE', `${constants.DIALOG_ENDPOINT}/users/${user}/bots/${bot}/versions/${version}/builder/v1/conversation_states/${conversationId}`)
6262
.set('Authorization', `Token ${token}`)
6363
if (proxy) { request.proxy(proxy) }
6464
return request.send()

src/apis/constants.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
export default {
2-
REQUEST_ENDPOINT: 'https://api.recast.ai/v2/request',
3-
CONVERSE_ENDPOINT: 'https://api.recast.ai/v2/converse',
4-
DIALOG_ENDPOINT: 'https://api.recast.ai/build/v1',
5-
CONVERSATION_ENDPOINT: 'https://api.recast.ai/connect/v1/messages',
6-
MESSAGE_ENDPOINT: 'https://api.recast.ai/connect/v1/conversations/:conversation_id/messages',
7-
TRAIN_ENDPOINT: 'https://api.recast.ai/v2',
2+
REQUEST_ENDPOINT: 'https://api.cai.tool.sap/v2/request',
3+
CONVERSE_ENDPOINT: 'https://api.cai.tool.sap/v2/converse',
4+
DIALOG_ENDPOINT: 'https://api.cai.tool.sap/build/v1',
5+
CONVERSATION_ENDPOINT: 'https://api.cai.tool.sap/connect/v1/messages',
6+
MESSAGE_ENDPOINT: 'https://api.cai.tool.sap/connect/v1/conversations/:conversation_id/messages',
7+
TRAIN_ENDPOINT: 'https://api.cai.tool.sap/v2',
88

99
ACT_ASSERT: 'assert',
1010
ACT_COMMAND: 'command',

0 commit comments

Comments
 (0)