Update WhatsappDirectLine.ts
This commit is contained in:
parent
013ad665d7
commit
a7de845164
1 changed files with 6 additions and 5 deletions
|
@ -50,7 +50,6 @@ export class WhatsappDirectLine extends GBService {
|
||||||
public whatsappServiceNumber: string;
|
public whatsappServiceNumber: string;
|
||||||
public whatsappServiceUrl: string;
|
public whatsappServiceUrl: string;
|
||||||
public botId: string;
|
public botId: string;
|
||||||
public watermark: string;
|
|
||||||
|
|
||||||
public conversationIds = {};
|
public conversationIds = {};
|
||||||
|
|
||||||
|
@ -173,19 +172,21 @@ export class WhatsappDirectLine extends GBService {
|
||||||
public pollMessages(client, conversationId, from, fromName) {
|
public pollMessages(client, conversationId, from, fromName) {
|
||||||
GBLog.info(`GBWhatsapp: Starting message polling(${from}, ${conversationId}).`);
|
GBLog.info(`GBWhatsapp: Starting message polling(${from}, ${conversationId}).`);
|
||||||
|
|
||||||
|
let watermark: any;
|
||||||
|
|
||||||
const worker = async () => {
|
const worker = async () => {
|
||||||
try {
|
try {
|
||||||
const response = client.Conversations.Conversations_GetActivities({
|
const response = await client.Conversations.Conversations_GetActivities({
|
||||||
conversationId: conversationId,
|
conversationId: conversationId,
|
||||||
watermark: this.watermark
|
watermark: watermark
|
||||||
});
|
});
|
||||||
|
watermark = response.obj.watermark;
|
||||||
await this.printMessages(response.obj.activities, conversationId, from, fromName);
|
await this.printMessages(response.obj.activities, conversationId, from, fromName);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
GBLog.error(`Error calling printMessages on Whatsapp channel ${err.data}`);
|
GBLog.error(`Error calling printMessages on Whatsapp channel ${err.data}`);
|
||||||
}
|
}
|
||||||
|
setInterval(worker, this.pollInterval);
|
||||||
};
|
};
|
||||||
|
|
||||||
setInterval(worker, this.pollInterval);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async printMessages(activities, conversationId, from, fromName) {
|
public async printMessages(activities, conversationId, from, fromName) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue