Action API Response Error

Hello!

I’m trying to recreate the example provided in the Action API documentation page (Action API | Documentation) but I keep getting this error as a response from the API:

“Get Response Failed An unexpected error occurred: string indices must be integers”

Would greatly appreciate any help with this. My code is exactly the same as the example.

Hello @manuel,

Welcome to the Convai Developer Forum!

To help you better, could you please share your code and specify which platform you’re working on? This will allow us to investigate the issue more effectively.

Looking forward to your reply!

I’m trying out the example in the documentation. The example is a python script fetching the CORE API getResponse endpoint:

# Importing a couple of libraries
import base64
import json
import requests

# This function will be useful for passing the request
def convert(l):
  """This little function will help us convert
  the list of dictionaries to the required format"""
  o = ""
  for each in l:
    o += json.dumps(each) + ";"
  return o

# Use your character id here
CHAR_ID = "************************************"

# You should set your Convai API key here
CONVAI_KEY = "************************************"

# This is the URL which will generate actions and responses
action_url = "https://api.convai.com/character/getResponse"

# URL for updating the backstory
url = "https://api.convai.com/character/update"

userText = input("Enter your command: ")

characters = [{"name": "User", "bio": "It's the guy using the Action API."},
              {"name": "Action-API-Doc-Bot", "bio": "Helping create docs here at Convai."},]

actions = "Play, Serve, Give, Call Cab"

objects = [{"name": "Mojito (Can be: Served|Cannot be: Played, Given)","description": "For once, a VIRGIN Mojito."},
           {"name": "Tequilla Sunrise (Can be: Served|Cannot be: Played, Given)","description": "Not my personal favourite."},
           {"name": "White Russian (Can be: Served|Cannot be: Played, Given)","description": "The Dude's favourite drink."},
           {"name": "A Jukebox (Can be: Played|Cannot be: Served, Given)","description": "A jukebox with lots of songs."},
           {"name": "Freshly sliced oranges (Can be: Served|Cannot be: Played, Given)","description": "Some zesty oranges to freshen you up."},
           {"name": "Fish and Chips (Can be: Served|Cannot be: Played, Given)","description": "Good old fish n' chips."},
           {"name": "Some Samosas (Can be: Served|Cannot be: Played, Given)","description": "A tasty Indian snack."},
           {"name": "Book (Can be: Given|Cannot be: Played, Served)","description": "A book to pass your time as you enjoy your meal."},
           ]

payload={'userText': userText,
  'charID': CHAR_ID,
  'sessionID': '-1',
  'voiceResponse': 'false',
  'actions': actions,
  'classification':'multistep', 
  'objects': convert(objects),
  'characters': convert(characters),
  }

files = []

headers = {
  'CONVAI-API-KEY': CONVAI_KEY 
}

response = requests.request("POST", action_url, headers=headers, data=payload, files=files)

print(response.text)

response = json.loads(response.text)

print(json.dumps(response, indent=4))

The API response is not a JSON, but a text that says “Get Response Failed An unexpected error occurred: string indices must be integers”

I am also having trouble with this

Any help? The action API would be of great use for our project.

Could you take a look at this issue? @K3

Anything? Would love to get some pointers to get us going.

Apologies for the delay. Our team is actively working on it, and it should be resolved within this week.

I’ll notify you once the documentation is updated. Thanks for your patience!

Thanks @K3 !

1 Like

Hello @manuel @Juan_Pablo_Rojas ,

Documentation updated.

Could you please try again?

It is now working, thanks so much!

1 Like