Skip to content

Commit

Permalink
🔊 : added better error logging to chatwoot integration
Browse files Browse the repository at this point in the history
  • Loading branch information
smashah committed Aug 7, 2024
1 parent a6d64e8 commit 20b8de0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/cli/integrations/chatwoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ class ChatwootClient {
return data.payload.find(x => (x.phone_number || "").includes(n)) || false
} else false
} catch (error) {
log.error(`CW SEARCH CONTACT ERROR: ${error.message}`)
return;
}
}
Expand All @@ -409,6 +410,7 @@ class ChatwootClient {
}
return resolvedConversation;
} catch (error) {
log.error(`CW GET CONVERSATION ERROR: ${error.message}`)
return;
}
}
Expand All @@ -421,6 +423,7 @@ class ChatwootClient {
});
return data;
} catch (error) {
log.error(`CW CREATE CONVERSATION ERROR: ${error.message}`)
return;
}
}
Expand All @@ -439,6 +442,7 @@ class ChatwootClient {
})
return data.payload.contact
} catch (error) {
log.error(`CW CREATE CONTACT ERROR: ${error.message}`)
return;
}
}
Expand All @@ -450,6 +454,7 @@ class ChatwootClient {
});
return data;
} catch (error) {
log.error(`CW OPEN CONVERSATION ERROR: ${error.message}`)
return;
}
}
Expand All @@ -467,6 +472,7 @@ class ChatwootClient {
});
return data;
} catch (error) {
log.error(`CW SEND CONVERSATION MESSAGE ERROR: ${error.message}`)
return;
}
}
Expand All @@ -486,6 +492,7 @@ class ChatwootClient {
const { data } = await this.cwReq('post', `conversations/${convoReg[contactId]}/messages`, formData, formData.getHeaders());
return data;
} catch (error) {
log.error(`CW SEND ATTACHMENT MESSAGE ERROR: ${error.message}`)
return;
}
}
Expand Down Expand Up @@ -520,6 +527,9 @@ class ChatwootClient {
convoReg[message.chatId] = conversation.id
} else {
//create the conversation
/**
* TODO: Handle create conversation error
*/
convoReg[message.chatId] = (await this.createConversation(contactReg[message.chatId])).id
isNewConversation = convoReg[message.chatId]
}
Expand Down

0 comments on commit 20b8de0

Please sign in to comment.