Comments (12)
@stevkan , Thanks.
My temporary solution is below,
save current conversationId then call botConnection.end() and remove webchat when stop conversation.
re-create webchat when start conversation.
like BotChatUI.ts
from botframework-directlinejs.
Hi @rainmakerho,
Can you provide your code so I can see how you are using the commands? Also, to verify, are you using the most recent version of the botchat.js?
from botframework-directlinejs.
Hi @stevkan ,
I add 2 button to control stop/resume conversation.
<button onclick="stopConversation()">Stop Conversation</button>
<button onclick="resumeConversation()">Resume Conversation</button>
DirectLine set websocket to false,
const botConnection = new BotChat.DirectLine({
domain: params['domain'],
secret: params['s'],
token: params['t'],
webSocket: false
});
function stopConversation() {
console.log('stopConversation');
botConnection.end();
}
function resumeConversation() {
console.log('resumeConversation');
botConnection.connectionStatus$.next(0);
}
thanks for your help.
from botframework-directlinejs.
Hi @rainmakerho,
Please see below. The code I have provided is working for me to pause/resume a conversation using BotChat.
The html stop/resume buttons take a value of true/false, respectively.
<button onclick="postButtonStop(true)">Stop Conversation</button>
<button onclick="postButtonResume(false)">Resume Conversation</button>
Clicking the buttons pass the values to the stopConversation and resumeConversation functions which set the states for botConnection.activity$.closed and botConnection.connectionStatus$.isStopped. The two functions also post messages back to the bot using back channel and the conversationMsg function.
<script>
botConnection.activity$
.filter(function (activity) {
return activity.type === 'message' && activity.name === 'conversationMsg';
})
.subscribe(function (activity) {
console.log('"conversationMsg" received with value: ' + activity.text);
conversationMsg(activity.text);
});
function stopConversation(newState) {
console.log('stopConversation: ' + newState);
$.when(botConnection.activity$.closed = newState)
.done(function(){
botConnection.connectionStatus$.isStopped = newState;
});
};
function resumeConversation(newState) {
console.log('resumeConversation: ' + newState);
$.when(botConnection.connectionStatus$.isStopped = newState)
.done(function() {
botConnection.activity$.closed = newState;
});
};
function conversationMsg(msg) {
console.log(msg);
};
function postButtonStop(btnValue) {
botConnection
.postActivity({
from: { id: 'me' },
name: 'conversationMsg',
type: 'message',
text: "Conversation paused"
})
.subscribe(function (id) {
console.log('"conversationMsg" sent');
});
stopConversation(btnValue);
};
function postButtonResume(btnValue) {
resumeConversation(btnValue);
botConnection
.postActivity({
from: { id: 'me'},
name: 'conversationMsg',
type: 'message',
text: "Conversation resumed"
})
.subscribe(function (id) {
console.log('"conversationMsg" sent');
});
}
</script>
The pauseDialog is triggered when the 'Conversation paused' message is posted. The post and trigger happen first followed by the botConnection service being paused. The user is left in the pauseDialog with no usable connection and no secondary function to move them on. The resumeDialog is triggered when the 'Conversation resumed' message is posted. The botConnection is first re-established, then the message is posted. The session.endDialog() is called and the user is returned to the conversation where they left off.
bot.dialog('pauseDialog', [
function(session) {
console.log("Conversation paused");
}
]).triggerAction({
matches: /Conversation.*paused/i
});
bot.dialog('resumeDialog', [
function(session) {
console.log("Conversation resumed");
session.endDialog();
}
]).triggerAction({
matches: /Conversation.*resumed/i
});
I hope this helps. This should be a good starting point for you.
Steve.
from botframework-directlinejs.
@stevkan ,
I try your codes. Bot won't get activity when click postButtonStop's button, but webchat still polling.
Thank you.
from botframework-directlinejs.
Unfortunately, I am not an expert in that area. You will need to look around DirectLineJS
to see how to pause the polling.
from botframework-directlinejs.
@rainmakerho, I apologize for not answering. I somehow missed your response. Let me take a look and see if there is anything on polling.
from botframework-directlinejs.
@stevkan , Thank you.
from botframework-directlinejs.
Worked with @stevkan offline. Looks like DirectLineJS doesn't like the idea to pause the polling. @stevkan will follow up.
from botframework-directlinejs.
@rainmakerho, I was just revisiting this thread and it looks like a message I posted sometime ago never actually posted. Please accept my apology for the delay in response.
As was mentioned above, DirectLineJS doesn't have an ability to pause polling, at this time. It'm listing it as a bug, but there is no ETA on when a solution might become available.
from botframework-directlinejs.
Transferring this one from Web Chat to DirectLineJS.
from botframework-directlinejs.
Marking as dupe of #124 and resolving it over that uber-bug.
from botframework-directlinejs.
Related Issues (20)
- subscribe not working when using react-query HOT 4
- This repo is missing important files
- Automated Tests With BotFramework-DirectLineJS HOT 6
- Whether to support the wechat mini program HOT 1
- Hello, how to send by directline, the ID of my QA environment? HOT 2
- Please create an Offline DirectLine Emulation that is supported by Microsoft.
- DirectlineStreaming doesn't work with Node.js HOT 7
- Error with Power Virtual Agent: Site Missing code 403 from https://directline.botframework.com/v3/directline/conversations HOT 1
- DirectlineStreaming - Retrying connection after end HOT 5
- Update webpack target for modern Node HOT 1
- DirectLineStreaming: unhandled rejection from connectWithRetryAsync in activity$
- While sending attachment, activity API was not triggering using botframework-directlinejs HOT 2
- Post an activity with attachment occurs 502 HOT 3
- Attachements limitation and expiry on DirectLine HOT 1
- DirectlineStreaming: Errors on disconnect are written to console HOT 2
- networkInformation: Switching network type, then switching back again, results in RECONNECT_REJECTED HOT 1
- Angular 15 with botframework-directlinejs does not compile due to typings errors. HOT 3
- [Error] NetworkInformation, missing Interface. HOT 4
- Mocking the WebSocket URL for end to end testing using playwright/cypress. HOT 2
- Application crashes when refresh token returns an error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from botframework-directlinejs.