File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -220,8 +220,6 @@ A common scenario of processing actions is:
220220
221221### Using sendToWatson to update context
222222
223- Using sendToWatson to update context simplifies the bot code compared to solution using updateContext below.
224-
225223``` js
226224const checkBalance = async (context ) => {
227225 // do something real here
@@ -258,6 +256,20 @@ const processWatsonResponse = async (bot, message) => {
258256controller .on (' message_received' , processWatsonResponse);
259257```
260258
259+ ### Using updateContext to update context
260+
261+ sendToWatson should cover majority of use cases,
262+ but updateContext method can be useful when you want to update context from bot code,
263+ but there is no need to make a special request to Watson.
264+
265+ ``` js
266+ if (params .amount ) {
267+ const context = message .watsonData .context ;
268+ context .paymentAmount = params .amount ;
269+ await watsonMiddleware .updateContext (message .user , context);
270+ }
271+ ```
272+
261273## Implementing event handlers
262274
263275Events are messages having type different than ` message ` .
You can’t perform that action at this time.
0 commit comments