Methods

(async) Blast(postdata, io) → {Promise}

Blast function to send messages.

Parameters:
NameTypeDescription
postdataObject

the postdata object containing user data

ioObject

the io object for socket communication

Returns:

a promise that resolves when the function completes

Type: 
Promise
Example
const postdata = { user_level: 2, dept: '1', tim: 'Admin', user_dept: '1', user_id: '1', idtl: '1' }
const io = io 
await Blast(postdata, io)

(async) Blast(postdata, io) → {Promise}

Blast function to send messages.

Parameters:
NameTypeDescription
postdataObject

the postdata object containing user data

ioObject

the io object for socket communication

Returns:

a promise that resolves when the function completes

Type: 
Promise
Example
const postdata = { user_level: 2, dept: '1', tim: 'Admin', user_dept: '1', user_id: '1', idtl: '1' }
const io = io 
await Blast(postdata, io)

_escapeString(val) → {string}

Escapes special characters in a string.

Parameters:
NameTypeDescription
valstring

The input string to be escaped.

Returns:

The escaped string.

Type: 
string

_escapeString(val) → {string}

Escapes special characters in a string.

Parameters:
NameTypeDescription
valstring

The input string to be escaped.

Returns:

The escaped string.

Type: 
string

formatDateTime(date) → {string}

Formats a given date and time into a string representation.

Parameters:
NameTypeDescription
dateDate

The date to be formatted.

Returns:

The formatted date and time string in the format 'YYYY-MM-DD HH:mm:ss'.

Type: 
string

formatDateTime(date) → {string}

Formats a given date and time into a string representation.

Parameters:
NameTypeDescription
dateDate

The date to be formatted.

Returns:

The formatted date and time string in the format 'YYYY-MM-DD HH:mm:ss'.

Type: 
string

(async) handleMessage(parsedMessage, isNewMessage, nasabah, res, io)

Handles incoming messages.

Parameters:
NameTypeDescription
parsedMessageObject

The parsed message object.

isNewMessageboolean

Flag indicating if the message is new.

nasabahObject

The nasabah object.

resObject

The response object.

ioObject

The Socket.IO server instance.

(async) handleMessage(parsedMessage, isNewMessage, nasabah, res, io)

Handles incoming messages.

Parameters:
NameTypeDescription
parsedMessageObject

The parsed message object.

isNewMessageboolean

Flag indicating if the message is new.

nasabahObject

The nasabah object.

resObject

The response object.

ioObject

The Socket.IO server instance.

(async) handleNewMessage(parsedMessage)

Handles new incoming messages.

Parameters:
NameTypeDescription
parsedMessageObject

The parsed message object.

(async) handleNewMessage(parsedMessage)

Handles new incoming messages.

Parameters:
NameTypeDescription
parsedMessageObject

The parsed message object.

(async) insertTbLogPesan(Data) → {Promise}

Inserts a record into the tb_log_pesan table.

Parameters:
NameTypeDescription
DataObject

The data object containing the details of the record to be inserted.

Returns:

A promise that resolves with the result of the execution.

Type: 
Promise

(async) insertTbLogPesan(Data) → {Promise}

Inserts a record into the tb_log_pesan table.

Parameters:
NameTypeDescription
DataObject

The data object containing the details of the record to be inserted.

Returns:

A promise that resolves with the result of the execution.

Type: 
Promise

(async) isHoliday(date) → {Promise.<boolean>}

Checks if a given date is a holiday.

Parameters:
NameTypeDescription
dateDate

The date to check.

Returns:
  • True if the date is a holiday, otherwise false.
Type: 
Promise.<boolean>

(async) isHoliday(date) → {Promise.<boolean>}

Checks if a given date is a holiday.

Parameters:
NameTypeDescription
dateDate

The date to check.

Returns:
  • True if the date is a holiday, otherwise false.
Type: 
Promise.<boolean>

(async) module:analytic(req, res)

Handles GET requests to "/analytic" to retrieve conversation analytics data.

Parameters:
NameTypeDescription
reqexpress.Request

The Express request object.

resexpress.Response

The Express response object.

(async) module:analytic(req, res)

Handles GET requests to "/analytic" to retrieve conversation analytics data.

Parameters:
NameTypeDescription
reqexpress.Request

The Express request object.

resexpress.Response

The Express response object.

module:delete_template(req, res)

Handles GET requests to "/delete_template" for deleting a template.

Parameters:
NameTypeDescription
reqexpress.Request

The Express request object.

resexpress.Response

The Express response object.

module:delete_template(req, res)

Handles GET requests to "/delete_template" for deleting a template.

Parameters:
NameTypeDescription
reqexpress.Request

The Express request object.

resexpress.Response

The Express response object.

parseStatus(webhookData) → {Object|null}

Parses the status from the webhook data.

Parameters:
NameTypeDescription
webhookDataObject

The data received from the webhook.

Returns:
  • The parsed status object, or null if not applicable.
Type: 
Object | null

parseStatus(webhookData) → {Object|null}

Parses the status from the webhook data.

Parameters:
NameTypeDescription
webhookDataObject

The data received from the webhook.

Returns:
  • The parsed status object, or null if not applicable.
Type: 
Object | null

(async) processAgentNotifications(Nasabah, parsedMessage, res)

Processes notifications for agents.

Parameters:
NameTypeDescription
NasabahObject

The nasabah object containing information about the customer.

parsedMessageObject

The parsed message object.

resObject

The response object.

(async) processAgentNotifications(Nasabah, parsedMessage, res)

Processes notifications for agents.

Parameters:
NameTypeDescription
NasabahObject

The nasabah object containing information about the customer.

parsedMessageObject

The parsed message object.

resObject

The response object.

replaceSpintaxWithParams(text, params) → {string}

Replaces spintax patterns in a text with the corresponding parameters.

Parameters:
NameTypeDescription
textstring

The text containing spintax patterns.

paramsArray

The array of parameters to replace the spintax patterns.

Returns:

The text with spintax patterns replaced with parameters.

Type: 
string

replaceSpintaxWithParams(text, params) → {string}

Replaces spintax patterns in a text with the corresponding parameters.

Parameters:
NameTypeDescription
textstring

The text containing spintax patterns.

paramsArray

The array of parameters to replace the spintax patterns.

Returns:

The text with spintax patterns replaced with parameters.

Type: 
string

(async) sendNotification(nomor, nama_divisi, nama_nasabah, nomor_nasabah, isi_pesan) → {Promise.<Object>}

Sends a notification message.

Parameters:
NameTypeDescription
nomorstring

The phone number to send the notification to.

nama_divisistring

The name of the division.

nama_nasabahstring

The name of the customer (nasabah).

nomor_nasabahstring

The phone number of the customer (nasabah).

isi_pesanstring

The content of the message.

Returns:
  • The response from the message sending action.
Type: 
Promise.<Object>

(async) sendNotification(nomor, nama_divisi, nama_nasabah, nomor_nasabah, isi_pesan) → {Promise.<Object>}

Sends a notification message.

Parameters:
NameTypeDescription
nomorstring

The phone number to send the notification to.

nama_divisistring

The name of the division.

nama_nasabahstring

The name of the customer (nasabah).

nomor_nasabahstring

The phone number of the customer (nasabah).

isi_pesanstring

The content of the message.

Returns:
  • The response from the message sending action.
Type: 
Promise.<Object>

(async) updateInboxLogAssign(Data) → {Promise}

Updates the inbox log assign.

Parameters:
NameTypeDescription
DataObject

The data object containing properties such as phone_id, tim, dept, idagent, idtl, idsv, idpb, idpd, and nomor.

Returns:

A promise that resolves with the result of the query execution or rejects with an error.

Type: 
Promise

(async) updateInboxLogAssign(Data) → {Promise}

Updates the inbox log assign.

Parameters:
NameTypeDescription
DataObject

The data object containing properties such as phone_id, tim, dept, idagent, idtl, idsv, idpb, idpd, and nomor.

Returns:

A promise that resolves with the result of the query execution or rejects with an error.

Type: 
Promise

(async) updateInboxLogUnAssign(Data) → {Promise}

Updates the inbox log to unassign a message.

Parameters:
NameTypeDescription
DataObject

The data object containing the necessary information for updating the inbox log.

Properties
NameTypeDescription
phone_idstring

The phone ID of the message.

timstring

The timestamp of the message.

deptstring

The department of the message.

idagentstring

The ID of the agent who unassigned the message.

idtlstring

The ID of the team leader.

idsvstring

The ID of the supervisor.

idpbstring

The ID of the PB.

idpdstring

The ID of the PD.

nomorstring

The number of the message.

Returns:

A promise that resolves with the result of the query.

Type: 
Promise

(async) updateInboxLogUnAssign(Data) → {Promise}

Updates the inbox log to unassign a message.

Parameters:
NameTypeDescription
DataObject

The data object containing the necessary information for updating the inbox log.

Properties
NameTypeDescription
phone_idstring

The phone ID of the message.

timstring

The timestamp of the message.

deptstring

The department of the message.

idagentstring

The ID of the agent who unassigned the message.

idtlstring

The ID of the team leader.

idsvstring

The ID of the supervisor.

idpbstring

The ID of the PB.

idpdstring

The ID of the PD.

nomorstring

The number of the message.

Returns:

A promise that resolves with the result of the query.

Type: 
Promise

(async) updateOutboxLogAssign(Data) → {Promise.<any>}

Updates the outbox log assignment.

Parameters:
NameTypeDescription
DataObject

The data object containing the following properties:

  • phone_id {string} - The phone ID.
  • tim {string} - The time.
  • dept {string} - The department.
  • idagent {string} - The agent ID.
  • idtl {string} - The TL ID.
  • idsv {string} - The SV ID.
  • idpb {string} - The PB ID.
  • idpd {string} - The PD ID.
  • status {string} - The status.
  • unomor {string} - The unomor.
Returns:

A promise that resolves with the result of the query execution.

Type: 
Promise.<any>

(async) updateOutboxLogAssign(Data) → {Promise.<any>}

Updates the outbox log assignment.

Parameters:
NameTypeDescription
DataObject

The data object containing the following properties:

  • phone_id {string} - The phone ID.
  • tim {string} - The time.
  • dept {string} - The department.
  • idagent {string} - The agent ID.
  • idtl {string} - The TL ID.
  • idsv {string} - The SV ID.
  • idpb {string} - The PB ID.
  • idpd {string} - The PD ID.
  • status {string} - The status.
  • unomor {string} - The unomor.
Returns:

A promise that resolves with the result of the query execution.

Type: 
Promise.<any>

(async) updateOutboxLogUnAssign(Data) → {Promise}

Updates the outbox log by unassigning the specified data.

Parameters:
NameTypeDescription
DataObject

The data to be used for updating the outbox log.

Properties
NameTypeDescription
phone_idstring

The phone ID.

timstring

The time.

deptstring

The department.

idagentstring

The agent ID.

idtlstring

The TL ID.

idsvstring

The SV ID.

idpbstring

The PB ID.

idpdstring

The PD ID.

unomorstring

The unomor value.

Returns:

A promise that resolves with the result of the update query.

Type: 
Promise

(async) updateOutboxLogUnAssign(Data) → {Promise}

Updates the outbox log by unassigning the specified data.

Parameters:
NameTypeDescription
DataObject

The data to be used for updating the outbox log.

Properties
NameTypeDescription
phone_idstring

The phone ID.

timstring

The time.

deptstring

The department.

idagentstring

The agent ID.

idtlstring

The TL ID.

idsvstring

The SV ID.

idpbstring

The PB ID.

idpdstring

The PD ID.

unomorstring

The unomor value.

Returns:

A promise that resolves with the result of the update query.

Type: 
Promise

(async) updateTpl1(Data) → {Promise}

Updates the template flag in the tb_pesan_${datetb} table.

Parameters:
NameTypeDescription
DataObject

The data used to update the template flag.

Properties
NameTypeDescription
nomorstring

The value used to identify the record to update.

Returns:

A promise that resolves with the result of the update query.

Type: 
Promise

(async) updateTpl1(Data) → {Promise}

Updates the template flag in the tb_pesan_${datetb} table.

Parameters:
NameTypeDescription
DataObject

The data used to update the template flag.

Properties
NameTypeDescription
nomorstring

The value used to identify the record to update.

Returns:

A promise that resolves with the result of the update query.

Type: 
Promise

(async) updateTpl2(Data) → {Promise}

Updates the tpl_flag of the tb_nomor_${datetb} table to '0' for the given nomor in the Data object.

Parameters:
NameTypeDescription
Dataobject

The data needed to update the tpl_flag.

Properties
NameTypeDescription
nomorstring

The nomor for which the tpl_flag needs to be updated.

Returns:

A promise that resolves with the result of the executeQuery function.

Type: 
Promise

(async) updateTpl2(Data) → {Promise}

Updates the tpl_flag of the tb_nomor_${datetb} table to '0' for the given nomor in the Data object.

Parameters:
NameTypeDescription
Dataobject

The data needed to update the tpl_flag.

Properties
NameTypeDescription
nomorstring

The nomor for which the tpl_flag needs to be updated.

Returns:

A promise that resolves with the result of the executeQuery function.

Type: 
Promise

Events

GET /webhook

Generates the function comment for the given function body.

Type:
  • string
Parameters:
NameTypeDescription
appObject

the Express app object

Returns:
  • resolves when the function is complete
Type: 
Promise.<void>

GET /webhook

Generates the function comment for the given function body.

Type:
  • string
Parameters:
NameTypeDescription
appObject

the Express app object

Returns:
  • resolves when the function is complete
Type: 
Promise.<void>