Best practices for developers: Bulk updating article labels for Answer Bot Follow

Comments

9 comments

  • Avatar
    Matt Petersen (Edited )

    I'm getting the following errors when trying to run the Ruby script in terminal:

    bulk_add_labels.rb:1: syntax error, unexpected $undefined, expecting '}'
    {\rtf1\ansi\ansicpg1252\cocoartf1504\cocoasubrtf830
      ^
    bulk_add_labels.rb:2: syntax error, unexpected $undefined, expecting '}'
    {\fonttbl\f0\fmodern\fcharset0 Courier;}
      ^
    bulk_add_labels.rb:2: syntax error, unexpected '}', expecting end-of-input

    Anyone else running into this or know how to fix it? 

  • Avatar
    Matt Petersen

    Please disregard my last comment. The problem had to do with formatting added by TextEdit, even though I was converting the file to plain text. Using Sublime Text instead worked flawlessly. 

  • Avatar
    Patrick (Edited )

    So I tried to write a remove labels in bulk, but it seems we cannot access the label json, are there certain permissions for this?

  • Avatar
    Sean Needham

    Hi Mike, 

    This would be very useful if I could get it to work. Option 2 works and I get a list of sections but when I try to add a label to a section nothing happens. Then I tried to add a label to an individual article an I get this response below. Any ideas feedback much appreciated. 

    Sean,

    Alright, whats the name of your label? example: answer-bot
    answer-bot
    bulk_add_labels.rb:64:in `article': undefined method `[]' for nil:NilClass (NoMethodError)
    from bulk_add_labels.rb:83:in `block in add_answer_bot_label_to_articles'
    from bulk_add_labels.rb:81:in `each'
    from bulk_add_labels.rb:81:in `add_answer_bot_label_to_articles'
    from bulk_add_labels.rb:116:in `block in <main>'
    from bulk_add_labels.rb:93:in `loop'
    from bulk_add_labels.rb:93:in `<main>'

  • Avatar
    Mike Mortimer

    Hey Sean, what's your default locale of your HC set to?

  • Avatar
    Sean Needham

    @Mike /en-gb/

  • Avatar
    Mike Mortimer

    OK, that makes sense Sean - we had en-us hard coded on some of those API endpoints. If you update lines 56 and 63 it should work. Let us know?

  • Avatar
    Sean Needham

    Thanks Mike, This works, Very helpful :)

  • Avatar
    An Nguyen (Edited )

    The script doesn't list all the sections that we have on help center (option #1)

    So I had to modify the line #49 to get the category from a specific category. Then it shows all the sections under the selected category just fine

    #sections_response = JSON.parse(get('help_center/{local}/categories/{categoryID}/sections.json').body)

     

    Thanks Mike for having the script written

Please sign in to leave a comment.

Powered by Zendesk