Skip to main content
Skip table of contents

Guide to Resolve Stuck Conversations Due to Active Tasks in Redis

There are cases in the system where a conversation might remain stuck on the Ongoing Conversations Dashboard for a long time. In these scenarios, while the actual conversation has already been closed in the system, the task representing that conversation remains active in Redis.

The Realtime Dashboard fetches all tasks from Redis and uses this data to display records. These tasks are maintained in Redis by the Routing Engine, which also keeps them in its in-memory pool.

It has been observed that a task is cleared from the in-memory pool when a conversation ends but fails to be removed from Redis due to some issue. As a result, the conversation record remains visible on the Active Conversations Dashboard, even though it has already been closed.

Steps to Clear Task(s)

1. Identify the Stuck Conversations

  • Go to the Ongoing Conversations Dashboard.

image-20250116-141312.png

Ongoing Conversations Dashboard

  • Note down the customer ucn of conversations, stuck for a long time.

2. Verify the Conversation is Closed

  • Use the Active Conversations API to confirm the conversation ID is no longer active:

    CODE
    GET <FQDN>/conversation-manager/customer-topics
  • Filter and search for the stuck conversation id identified in the 1st step in the response of the above API, it should not be there as the above API returns active conversations only.

Please proceed further only if the conversation is closed. Otherwise removing any task of an Active conversation can have a negative impact.


3. Fetch Task ID(s)

  • Use the Past Events API to identify the relevant TASK_ENQUEUED events and retrieve the task ID(s):

    CODE
    GET <FQDN>/conversation-manager/customer-topics/<conversation-id>/past-events
  • Filter the events for TASK_ENQUEUED, and note down the id from the data object which is the task id.

    • Note: If there are multiple TASK_ENQUEUED events (e.g., due to conference or transfer cases), note all associated task IDs.


4. Access Redis

  • Connect to the Redis CLI using the following command:

    CODE
    kubectl exec -n ef-external -it redis-master-0 -- redis-cli -a <PASSWORD>

5. Check Task in Redis

  • Verify the task object exists in Redis by running:

    CODE
    KEY task:<task-id>
    • Replace <task-id> with the actual task ID retrieved earlier in the 3rd step.


6. Confirm Task is Removed from In-Memory Pool

  • Use the Task API of Routing Engine to ensure the task no longer exists in the in-memory pool.

    CODE
    GET <FQDN>/routing-engine/task/<task-id>
  • Check for the response:

    CODE
    Task not found in Task pool
    • This confirms that the conversation is stuck because the task exist in Redis as checked in the 5th step and does not exist in the in-memory pool as per the response of this API.

Please proceed further only if the task is removed from in-memory pool but exist in Redis. Otherwise removing such task can have a negative impact.


7. Delete Task(s) from Redis

  • Use the following script to delete one or multiple tasks from Redis:

Script: delete_redis_task.sh
CODE
#!/bin/bash

# Define the following variables
NAMESPACE="ef-external"
REDIS_POD="redis-master-0"
REDIS_PASSWORD="<>" # replace the password here

# Check if at least one task ID is provided
if [ "$#" -eq 0 ]; then
  echo "Usage: $0 <task-id-1> [task-id-2] ... [task-id-n]"
  exit 1
fi

echo "Deleting tasks from Redis..."

# Loop through all task IDs provided as arguments
for TASK_ID in "$@"; do
  TASK_KEY="task:$TASK_ID"
  kubectl exec -n "$NAMESPACE" -it "$REDIS_POD" -- redis-cli -a "$REDIS_PASSWORD" DEL "$TASK_KEY"
done

echo "Task deletion process completed."

How to Run the Script

  1. Save the script as delete_redis_task.sh or any suitable name.

  2. Make the script executable:

    CODE
    chmod +x delete_redis_task.sh
  3. Run the script with the task ID(s) as arguments:

    CODE
    ./delete_redis_task.sh <task-id-1> <task-id-2> <task-id-n>
    • Provide either 1 task id or as many tasks ids as you want to delete from Redis.


Important Notes

Ensure the conversation is inactive before deleting tasks from Redis.

Double-check the task status that the task is not active and only exists in Redis. (Step 5 & 6)

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.