Skip to content

Commit

Permalink
omni
Browse files Browse the repository at this point in the history
  • Loading branch information
ggazzo committed Jul 3, 2023
1 parent cecac0e commit 59b71ea
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ export default (): void => {

b.on('getRoutingConfig', async () => {
const agent = rand(agents);

if (!agent) {
return;
}
await agent.getRoutingConfig();
const { departments } = (await agent.getAgentDepartments()) || {
departments: [],
Expand All @@ -151,11 +155,17 @@ export default (): void => {

b.on('getQueuedInquiries', async () => {
const agent = rand(agents);
if (!agent) {
return;
}
await agent.getQueuedInquiries();
});

b.on('takeInquiry', async () => {
const agent = rand(agents);
if (!agent) {
return;
}
const response = await agent.getQueuedInquiries();
if (!response?.inquiries) {
return;
Expand All @@ -170,6 +180,10 @@ export default (): void => {
}

const processedInquiry = rand(inquiries);

if (!processedInquiry) {
return;
}
try {
// Re-fetch inquiry
await agent.getInquiry(processedInquiry._id);
Expand All @@ -186,6 +200,9 @@ export default (): void => {

b.on('message', async () => {
const agent = rand(agents);
if (!agent) {
return;
}
const sub = agent.getRandomLivechatSubscription();

if (!sub) {
Expand Down
4 changes: 4 additions & 0 deletions src/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export default (): void => {
async function getLoggedInClient() {
const client = rand(clients);

if (!client) {
throw new Error('No logged in client found');
}

if (client.status === 'logging') {
throw new AlreadyLoggingError();
}
Expand Down

0 comments on commit 59b71ea

Please sign in to comment.