Zendesk via private messages

Hi @mc.elias ,

I encountered the same issue and was able to resolve it by modifying the code logic of the Zendesk Plugin. Here’s the solution:

In the file of the Zendesk Plugin:

app/jobs/regular/zendesk_job.rb

Make the following changes:

def push_topic!(topic_id)
  topic = Topic.find_by(id: topic_id)
  return unless topic.present?

  if DiscourseZendeskPlugin::Helper.autogeneration_category?(topic.category_id)
    topic.post_ids.each { |post_id| push_post!(post_id) }
  end
end

In the Zendesk Plugin

lib/discourse_zendesk_plugin/helper.rb

    def self.autogeneration_category?(category_id)
      return true if category_id.nil?
      return false if category_id.blank?

      if SiteSetting.zendesk_autogenerate_all_categories?
        true
      else
        SiteSetting.zendesk_autogenerate_categories.split("|").include?(category_id.to_s)
      end
    end

I believe the issue occurs because private category topics do not have a category assigned, which prevents them from syncing with Zendesk based on the current code logic.

To resolve this, I modified the logic to allow topics to be created in Zendesk even if a category is not assigned. I’m not entirely sure if this is the best approach, but it worked for me.

After making these changes, please test it on your end to ensure it resolves the issue for you as well.

I hope this helps!

Thank you

1 Like