Open iMicknl opened 3 years ago
With the help of @xTEddie I built an OfflineHistoryConnection
to mock the IBotConnection
. This will make sure there is no error, thus you can use WebChat in an offline scenario / for showing history activities.
import {
IBotConnection,
ConnectionStatus,
Activity,
} from "botframework-directlinejs";
import { BehaviorSubject } from "rxjs/BehaviorSubject";
import { Observable } from "rxjs/Observable";
import { Subscriber } from "rxjs/Subscriber";
export class OfflineHistoryConnection implements IBotConnection {
referenceGrammarId?: string | undefined;
public connectionStatus$: BehaviorSubject<ConnectionStatus>;
public activity$: Observable<Activity>;
public constructor() {
this.connectionStatus$ = new BehaviorSubject<ConnectionStatus>(
ConnectionStatus.Ended
);
this.activity$ = new Observable<Activity>(
(observer: Subscriber<Activity>) => {
const activity: any = {};
observer.next(activity);
}
).share();
}
public end(): void {
throw new Error("Method not implemented.");
}
public postActivity(activity: Activity): Observable<string> {
return Observable.of(activity.id || "");
}
public getSessionId?: (() => Observable<string>) | undefined;
}
Should this feature request be closed? Or would you like to add something like this to your documentation? (see #4037 for a similar customer request).
I know it's been a while but thank you @iMicknl for this connection mock, it works perfectly
Feature Request.
Is your feature request related to a problem? Please describe.
I am using the ReactWebChat component in a 'transcript viewer' scenario, where no interactivity is allowed. Unfortunately it is required to pass
directLine
, passing an empty object ({}
) will work but throw an javascript error.Describe the suggestion or request in detail
A way to use the ReactWebChat component in an offline / no interactivity scenario.
Describe alternatives you have considered
Passing a mock DirectLine client / RXJS Observable. However, it seems that I did need to use RXJS for this, which add a lot of overhead to my project. If there is a way to add a simple mock object to disable the connection, that would be feasible for me as well.
Additional context
See https://github.com/iMicknl/powerbi-botframework-chat-transcripts/issues/9.
Similar request: https://github.com/microsoft/BotFramework-WebChat/issues/3032
Similar customer request: https://github.com/microsoft/BotFramework-WebChat/issues/4037
[feature-request]