Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add lib folder and address review
- Loading branch information
1 parent
a5cdaad
commit 9a90793
Showing
17 changed files
with
1,225 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,4 +35,3 @@ node_modules | |
|
||
# Optional REPL history | ||
.node_repl_history | ||
lib/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/** | ||
* Copyright 2016-2019 IBM Corp. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import Botkit = require('botkit'); | ||
import AssistantV1 = require('ibm-watson/assistant/v1'); | ||
import { BotkitMessage } from 'botkit'; | ||
export interface WatsonMiddlewareConfig { | ||
version: string; | ||
workspace_id: string; | ||
url?: string; | ||
token?: string; | ||
headers?: { | ||
[index: string]: string; | ||
}; | ||
use_unauthenticated?: boolean; | ||
username?: string; | ||
password?: string; | ||
iam_apikey?: string; | ||
iam_url?: string; | ||
minimum_confidence?: number; | ||
} | ||
export interface Payload extends AssistantV1.MessageRequest { | ||
workspace_id: string; | ||
} | ||
export interface Context { | ||
conversation_id: string; | ||
system: any; | ||
[index: string]: any; | ||
} | ||
export declare type BotkitWatsonMessage = BotkitMessage & { | ||
watsonData?: Payload; | ||
watsonError?: string; | ||
}; | ||
export interface ContextDelta { | ||
[index: string]: any; | ||
} | ||
export declare type ErrorCallback = (err: null | Error) => null; | ||
export declare class WatsonMiddleware { | ||
private config; | ||
private conversation; | ||
private storage; | ||
private minimumConfidence; | ||
private readonly ignoreType; | ||
constructor(config: WatsonMiddlewareConfig); | ||
hear(patterns: string[], message: Botkit.BotkitMessage): boolean; | ||
before(message: Botkit.BotkitMessage, payload: Payload): Promise<Payload>; | ||
after(message: Botkit.BotkitMessage, response: any): Promise<any>; | ||
sendToWatson(bot: any, message: Botkit.BotkitMessage, contextDelta: ContextDelta): Promise<void>; | ||
receive(bot: Botkit.BotWorker, message: Botkit.BotkitMessage): Promise<void>; | ||
interpret(bot: Botkit.BotWorker, message: Botkit.BotkitMessage): Promise<void>; | ||
readContext(user: string): Promise<Context>; | ||
updateContext(user: string, contextDelta: ContextDelta): Promise<{ | ||
context: Context | ContextDelta; | ||
}>; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Copyright 2016-2019 IBM Corp. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { Storage } from 'botbuilder'; | ||
import AssistantV1 = require('ibm-watson/assistant/v1'); | ||
import { Payload, Context, ContextDelta } from './index'; | ||
export declare function readContext(userId: string, storage: Storage): Promise<Context | null>; | ||
export declare function updateContext(userId: string, storage: Storage, watsonResponse: { | ||
context: Context | ContextDelta; | ||
}): Promise<{ | ||
context: Context | ContextDelta; | ||
}>; | ||
export declare function postMessage(conversation: AssistantV1, payload: Payload): Promise<AssistantV1.MessageResponse>; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.