Lauching flow in the future for a specific user

Our use case : at the end of a flow, I want to send a user to another flow, but that flow need to start in 24 hours, not right now.

We have created a module that manages a list of task to be run in the future (almost a copy paste of the old scheduler module).

We learned in the process that jumpTo doesn’t work when called from a module. So we tried to cheat by sending a custom incoming event, catching it from the hooks, forcing the jumpTo from there and finally settings all the flags required to make sure the event is ignored by the QnA+NLU.

For some reasons though, the new custom crafted event doesn’t seem to go through the middlewares.
Im starting to think that an event created from a module (even if flagged as incoming) won’t go through the middlewares.

1 ) If you had to do it, how would you do it?
2 ) Am I wrong in assuming that a new custom event generated from a module won’t go through the middlewares?


They should go through like all other events. The way you did it is exactly how I’d recommend doing it. Perhaps you can copy/paste what a real incoming event looks like (real user message) and your synthetic event ?

There’s a DEBUG flag you can check to see the raw I/O events

That’s my real event :

IOEvent {                                                                                                                                                                                      
  type: 'text',                    
  channel: 'web',                                                                              
  direction: 'incoming',                                                                                                                                                                       
  payload: { type: 'text', text: 'a' },                                                                                                                                                        
  target: '-laDLLOmW-vEtVjVntkK0',                                                                                                                                                             
  botId: 'pierrepaul7',                                                                                                                                                                        
  createdOn: 2019-10-07T19:44:39.241Z,                                                                                                                                                         
  threadId: '7',                                                                                                                                                                               
  id: '157047747924106700',                                                                                                                                                                    
  preview: 'a',                                                                                                                                                                                
  flags: {},                                                                                                                                                                                   
   { user: { timezone: 4, language: 'en', salut: 'aurelien' },
     context: {},                        
     session: { lastMessages: [] },                                                            
     temp: {},                                                                                                                                                                                 
     bot: undefined,
     __stacktrace: [] },             
  suggestions: [],                                                                                                                                                                             
  credentials: undefined,                                                                                                                                                                      
   { entities: [],                                                                                                                                                                             
     language: 'n/a',                                                                                                                                                                          
     detectedLanguage: 'n/a',      
     ambiguous: false,                                                                         
     slots: {},                                                                                                                                                                                
     intent: { name: 'none', confidence: 1, context: 'global' },                                                                                                                               
     intents: [],                                                                                                                                                                              
     errored: false,                                                                                                                                                                           
     includedContexts: [ 'global' ] } }                                                                                                                                                        

And my synthetic event is giving me :

15:44:42.381 OQueue Outgoing queue failed to process job: Unsupported event type: jumpto [Error, Unsupported event type: jumpto]
Error: Unsupported event type: jumpto 

By activating the logs though, there seems to be an before_outgoing_middleware. I guess I could use the replyToEvent and put my hook into this?

Please make sure your synthetic event is of direction incoming

1 Like

You were right, I forgot I had set the direction to ‘outgoing’ while testing. It works like a charm now, thanks!