Skip to content

Commit

Permalink
fix(core.gbapp): Added IBM for TTS and removed MSFT while it does not…
Browse files Browse the repository at this point in the history
… compile on AZR.
  • Loading branch information
rodrigorodriguez committed Dec 31, 2021
1 parent 12c9bea commit abe4281
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions packages/whatsapp.gblib/services/WhatsappDirectLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,13 +473,14 @@ export class WhatsappDirectLine extends GBService {
return `${attachment.content.title} - ${attachment.content.text}`;
}

public async sendFileToDevice(to, url, filename, caption) {
public async sendFileToDevice(to, url, filename, caption, chatId) {
const options = {
method: 'POST',
url: urlJoin(this.whatsappServiceUrl, 'sendFile'),
qs: {
token: this.whatsappServiceKey,
phone: to,
phone: chatId ? null : to,
chatId: chatId,
body: url,
filename: filename,
caption: caption
Expand All @@ -498,13 +499,14 @@ export class WhatsappDirectLine extends GBService {
}
}

public async sendAudioToDevice(to, url) {
public async sendAudioToDevice(to, url, chatId) {
const options = {
method: 'POST',
url: urlJoin(this.whatsappServiceUrl, 'sendPTT'),
qs: {
token: this.whatsappServiceKey,
phone: to,
phone: chatId ? null : to,
chatId: chatId,
body: url
},
headers: {
Expand All @@ -521,25 +523,28 @@ export class WhatsappDirectLine extends GBService {
}
}

public async sendTextAsAudioToDevice(to, msg) {
public async sendTextAsAudioToDevice(to, msg, chatId) {

const url = await GBConversationalService.getAudioBufferFromText(
msg
);

await this.sendFileToDevice(to, url, 'Audio', msg);
await this.sendFileToDevice(to, url, 'Audio', msg, chatId);
}

public async sendToDevice(to: string, msg: string, conversationId) {

const cmd = '/audio ';

let chatId = WhatsappDirectLine.chatIds[conversationId];

if (msg.startsWith(cmd)) {
msg = msg.substr(cmd.length);

return await this.sendTextAsAudioToDevice(to, msg);
return await this.sendTextAsAudioToDevice(to, msg, chatId);
} else {

let chatId = WhatsappDirectLine.chatIds[conversationId];


const options = {
method: 'POST',
Expand Down

0 comments on commit abe4281

Please sign in to comment.