Search code examples
artificial-intelligencedasha

Dasha SDK Jobs, queue


When I use Dasha's old SDK, from another file with "dashaApp.enqueueJobs()" sended call number to the main Dasha.js file and I get the number, but in the new Dasha SDK how I can get the info sented from enqueueJobs?


Solution

  • https://docs.dasha.ai/en-us/default/sdk/node-js/classes/conversationqueue

    when you want to add entry

    application.queue.push("key", {
    
      after: new Date(),
    
      before: new Date(Date.now() + 60 * 60 * 1000)
    
    });
    

    in main handler

    application.queue.on("ready", async (key, conversation) => {
    
    //key -- something for identification of job on your side, for example phone number
      conversation.input = getInput(key);
    
      const result = await conversation.execute();
    
    });
    

    Or you can use queue-less execution https://docs.dasha.ai/en-us/default/sdk/node-js/classes/application#createconversation

    const dasha = require("@dasha.ai/sdk");
    
    const app = await dasha.deploy("path/to/app");
    
    ....
    
    const conv = app.createConversation({
    
      foo: 123,
    
    });
    const result = await conv.execute();