Skip to content

Commit fdec767

Browse files
committed
conversation example
1 parent 647e9be commit fdec767

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

examples/conversation.v1.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const message = function(text) {
2525
input: {
2626
text: text
2727
},
28+
// pass the context from previous response
2829
context: currentContext
2930
};
3031
return new Promise((resolve, reject) => conversation.message(payload, function(err, data) {
@@ -38,15 +39,16 @@ const message = function(text) {
3839
}));
3940
};
4041

41-
message('first message').then(resp1 => {
42+
// This example makes two successive calls to conversation service.
43+
message('first message').then(response1 => {
4244
// APPLICATION-SPECIFIC CODE TO PROCESS THE DATA
4345
// FROM CONVERSATION SERVICE
44-
console.log(JSON.stringify(resp1, null, 2));
46+
console.log(JSON.stringify(response1, null, 2));
4547

4648
// invoke a second call to conversation
4749
message('second message')
48-
.then(resp2 => {
49-
console.log(JSON.stringify(resp2, null, 2));
50+
.then(response2 => {
51+
console.log(JSON.stringify(response2, null, 2));
5052
console.log('Note that the two reponses have the same context.conversation_id');
5153
})
5254
.catch(err => {

0 commit comments

Comments
 (0)