new(security.gblib): SMS Auth.
This commit is contained in:
parent
1a5f76f2ac
commit
36a9a8eb1d
1 changed files with 18 additions and 15 deletions
|
@ -354,23 +354,26 @@ export class GBConversationalService {
|
||||||
|
|
||||||
// tslint:disable:no-unsafe-any due to Nexmo.
|
// tslint:disable:no-unsafe-any due to Nexmo.
|
||||||
public async sendSms(min: GBMinInstance, mobile: string, text: string): Promise<any> {
|
public async sendSms(min: GBMinInstance, mobile: string, text: string): Promise<any> {
|
||||||
let botNumber = process.env.BOT_NUMBER;
|
|
||||||
|
|
||||||
GBLog.info(`Sending SMS from ${botNumber} to ${mobile} with text: '${text}'.`);
|
let botNumber = min.core.getParam<string>(min.instance, 'Bot Number', null);
|
||||||
const accountSid = process.env.TWILIO_ACCOUNT_SID;
|
if (botNumber) {
|
||||||
const authToken = process.env.TWILIO_AUTH_TOKEN;
|
|
||||||
const client = twilio(null, authToken, { accountSid: accountSid });
|
|
||||||
|
|
||||||
|
|
||||||
const msg = await client.messages
|
GBLog.info(`Sending SMS from ${botNumber} to ${mobile} with text: '${text}'.`);
|
||||||
.create({
|
const accountSid = process.env.TWILIO_ACCOUNT_SID;
|
||||||
body: text,
|
const authToken = process.env.TWILIO_AUTH_TOKEN;
|
||||||
from: '+' + botNumber,
|
const client = twilio(null, authToken, { accountSid: accountSid });
|
||||||
to: '+' + mobile
|
|
||||||
})
|
|
||||||
|
|
||||||
GBLogEx.info(min, `SMS sent, return: ${msg.sid}.`);
|
|
||||||
|
|
||||||
|
const msg = await client.messages
|
||||||
|
.create({
|
||||||
|
body: text,
|
||||||
|
from: '+' + botNumber,
|
||||||
|
to: '+' + mobile
|
||||||
|
})
|
||||||
|
|
||||||
|
GBLogEx.info(min, `SMS sent, return: ${msg.sid}.`);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!min.instance.smsKey && min.instance.smsSecret) {
|
if (!min.instance.smsKey && min.instance.smsSecret) {
|
||||||
|
@ -423,8 +426,8 @@ export class GBConversationalService {
|
||||||
|
|
||||||
public async sendToMobile(min: GBMinInstance, mobile: string, message: string, conversationId) {
|
public async sendToMobile(min: GBMinInstance, mobile: string, message: string, conversationId) {
|
||||||
GBLog.info(`Sending message ${message} to ${mobile}...`);
|
GBLog.info(`Sending message ${message} to ${mobile}...`);
|
||||||
return min.whatsAppDirectLine ? await min.whatsAppDirectLine.sendToDevice(mobile, message, conversationId):
|
return min.whatsAppDirectLine ? await min.whatsAppDirectLine.sendToDevice(mobile, message, conversationId) :
|
||||||
await this.sendSms(min, mobile, message);
|
await this.sendSms(min, mobile, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async getAudioBufferFromText(text): Promise<string> {
|
public static async getAudioBufferFromText(text): Promise<string> {
|
||||||
|
|
Loading…
Add table
Reference in a new issue