Output message "please wait" before call api

v4

#1

Hello

I would like to send a message “please wait we are working on your request” before to call my api.
But this message appear when I’ send a message with the results of api.
In my web plugin, I used delegate component. Bellow you can see my code

 onStartPmChecklist() {
return this.$delegate(StartDateListOfPmCheckListComponent, {
  resolve: {
    successStartDate: this.onEndPmChecklist,
  },
});
  }

  onEndPmChecklist(startDate: string) {
this.$component.data.startDate = startDate;
return this.$delegate(EndDateListOfPmCheckListComponent, {
  resolve: {
    successEndDate: this.onListPmChecklist,
  },
});
  }

  onListPmChecklist(endDate: string) {
this.$data.serialNumber = this.$component.data.serialNumber;
this.$data.endDate = endDate;
this.$data.startDate = this.$component.data.startDate;
return this.$delegate(ListOfPmCheckListComponent, {
  resolve: {
    needAnotherHelp: this.onNeedAnotherHelp,
    notNeedAnotherHelp: this.onNotNeedAnotherHelp,
  },
});
  }

const TPL_TICKET = 'pm_checkList';

@Component()
export class ListOfPmCheckListComponent extends BaseComponent {
  async START() {
    const system_id = this.$data.serialNumber;
    const f_api_endDate = this.$data.endDate;
    const f_api_startDate = this.$data.startDate;
    console.log(
      `system_id : ${system_id}, f_api_startDate : ${f_api_startDate}, f_api_endDate :${f_api_endDate}`,
    );
    this.$send('please wait');
    const data: PmCheckListCRM[] = await checkListApi(system_id, f_api_startDate, f_api_endDate);
   

    if (data.length == 0) {
      this.$send({ message: this.$t('emptyPMCheckList') });
    } else {
      this.$send([
        {
          message: this.$t('belowPreventive'),
        },
      ]);

      const arrPdfFile: PDFFile[] = [];
      const arrInfoPM: InfoPM[] = [];

      for (const index in data) {
        const obj = new PDFFile(
          `PMCheckList_${data[index].caseNumber}.pdf`,
          data[index].checkListInfo.pdfEncrypt,
        );

        const info = new InfoPM(data[index].caseNumber, data[index].endDate);

        arrPdfFile.push(obj!);
        arrInfoPM.push(info);

        this.$send({
          message: this.$t('detailPM', {
            case_number: data[index].caseNumber,
            close_date: data[index].endDate,
            ownername: data[index].ownername,
          }),
        });
      }
    }
    return this.$send(YesNoOutput, { message: this.$t('needAnotherHelpService') });
  }

  @Intents(['YesIntent'])
  needAnotherHelp() {
    return this.$resolve('needAnotherHelp');
  }

  @Intents(['NoIntent'])
  notNeedAnotherHelp() {
    return this.$resolve('notNeedAnotherHelp');
  }

  UNHANDLED() {
    this.$send({ message: this.$t('responseNotValid') });
    return this.START();
  }
}

Can you help me, please ?

Romain


#2

Thank you @Romain.Rivolta. This sounds interesting, similar to how progressive responses work for Alexa, and how other asynchronous platforms like Facebook Messenger and Google Business Messages work: https://www.jovo.tech/docs/output#send-multiple-responses

Right now, this doesn’t work for our existing web clients, but this sounds like a great addition.

Maybe we could build this by using sockets @AlexSwe?


#3

Thanks very much @jan. We wait the response by @AlexSwe
Best regards


#4

I like the idea.

I heard @norbert and team are working on a web socket integration :slight_smile:


#5

Hello

Thanks you for your answers.
@AlexSwe and @norbert do you have an approximate date for this package ?

Best Regards,
Romain