Compare commits
3 Commits
344dafbb48
...
f05bfa4047
Author | SHA1 | Date |
---|---|---|
|
f05bfa4047 | |
|
1d300e07ca | |
|
89db3e83c9 |
|
@ -423,10 +423,10 @@ const webhook = async (req, res) => {
|
||||||
|
|
||||||
let { name, phone_number } = req.body.meta.sender
|
let { name, phone_number } = req.body.meta.sender
|
||||||
|
|
||||||
const {id: ticketId, account_id: accountId} = req.body
|
const { id: ticketId, account_id: accountId } = req.body
|
||||||
|
|
||||||
//channel: 'Channel::FacebookPage'
|
//channel: 'Channel::FacebookPage'
|
||||||
console.log("2 =============> ticketId id: ", ticketId, " | accountId account_id: ",accountId)
|
console.log("2 =============> ticketId id: ", ticketId, " | accountId account_id: ", accountId)
|
||||||
|
|
||||||
if (!phone_number) {
|
if (!phone_number) {
|
||||||
|
|
||||||
|
@ -437,23 +437,29 @@ const webhook = async (req, res) => {
|
||||||
|
|
||||||
let crmPhone = phone_number.replace('+', '')
|
let crmPhone = phone_number.replace('+', '')
|
||||||
|
|
||||||
const companies = [
|
const company = await Company.findOne({
|
||||||
// { companyId: "99", account_id: "1" },
|
integrations: {
|
||||||
{ companyId: "99", account_id: "15" },
|
$elemMatch: {
|
||||||
]
|
name: "omnihit",
|
||||||
|
"config.accountId": `${accountId}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const obj = companies.find(c => +c.account_id == +accountId)
|
if (!company) {
|
||||||
|
return res.status(StatusCodes.NOT_FOUND).send({ msg: "companyId not found!" })
|
||||||
|
}
|
||||||
|
|
||||||
console.log('=======> name: ', name)
|
console.log('=======> name: ', name)
|
||||||
console.log('=======> crmPhone: ', crmPhone)
|
console.log('=======> crmPhone: ', crmPhone)
|
||||||
console.log('=======> accountId: ', accountId)
|
console.log('=======> accountId: ', accountId)
|
||||||
console.log('=======> companyId: ', obj.companyId)
|
console.log('=======> companyId: ', company.companyId)
|
||||||
|
|
||||||
console.log('=======> ticketId: ', ticketId)
|
console.log('=======> ticketId: ', ticketId)
|
||||||
|
|
||||||
|
|
||||||
await whatsappJournalingCRM(
|
await whatsappJournalingCRM(
|
||||||
companyId = obj.companyId,
|
companyId = company.companyId,
|
||||||
crmPhone = crmPhone,
|
crmPhone = crmPhone,
|
||||||
crmAgent = '0000',
|
crmAgent = '0000',
|
||||||
crmFirstName = name,
|
crmFirstName = name,
|
||||||
|
@ -519,8 +525,6 @@ const webhook_crm = async (req, res) => {
|
||||||
|
|
||||||
const { phone } = contact
|
const { phone } = contact
|
||||||
|
|
||||||
// const obj = omnihitV2Integration.find(o => o.companyId == companyId)
|
|
||||||
|
|
||||||
const config = await getIntegrationsConfig(companyId, 'omnihit')
|
const config = await getIntegrationsConfig(companyId, 'omnihit')
|
||||||
|
|
||||||
if (config) {
|
if (config) {
|
||||||
|
@ -551,15 +555,6 @@ const webhook_crm = async (req, res) => {
|
||||||
return res.set('Content-Type', 'text/xml').status(StatusCodes.OK).send(responseXml)
|
return res.set('Content-Type', 'text/xml').status(StatusCodes.OK).send(responseXml)
|
||||||
}
|
}
|
||||||
|
|
||||||
const integration = async (req, res) => {
|
|
||||||
const { companyId } = req.query
|
|
||||||
const { integration } = req.body
|
|
||||||
|
|
||||||
console.log("====> companyId: ", companyId, " | integration: ", integration)
|
|
||||||
|
|
||||||
res.send()
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
contactCreate,
|
contactCreate,
|
||||||
uploadCrmConfig,
|
uploadCrmConfig,
|
||||||
|
|
Loading…
Reference in New Issue