﻿This is a guide for the Pandorabots SDK for the Python programming language. It provides usage guidelines as well code examples.


The first thing to do is download Pandorabots_API_Calls.py. Download this file to the location where you intend to write your scripts that make use of the Pandorabots APIs. For this file to run properly, make sure you have the python Requests library installed.


Getting started is easy. All you have to do is write the following line at the top of your code.


import Pandorabots_API_Calls as API


To create a bot:


API.create_bot(user_key, username, botname)


Example Usage:


>> API.create_bot(‘notARealKey’, ’johnd’, ‘fido’)
fido has been created! 
>>


To delete a bot:


API.delete_bot(user_key, username, botname)


Example Usage:


>> API.delete_bot(‘notARealKey’, ’johnd’, ‘fido’)
fido has been deleted! 
>>


To upload a file to a bot:


API.upload_file(user_key, username, botname, filename, file_kind)


Note: The argument specified by filename should in the same folder as your code, and have one of the following extensions: “.aiml”, “.map”, “.set”, “.substitution”, “.properties”, or “.pdefaults”. The file_kind must be one of the six acceptable aiml filetypes: “aiml”, “map”, “set”, “substitution”, “properties”, or “pdefaults”.


Example Usage:


>> API.upload(‘notARealKey’, ’johnd’, ‘fido’, ‘somefile.aiml’, ‘aiml’)
somefile.aiml successfully uploaded        
>>


To delete a file:


API.delete_file(user_key, username, botname, filename, file_kind)


Note: The argument specified by filename should end in one of the following extensions: “.aiml”, “.map”, “.set”, “.substitution”, “.properties”, or “.pdefaults”. The file_kind must be one of the six acceptable aiml filetypes: “aiml”, “map”, “set”, “substitution”, “properties”, or “pdefaults”.


Example Usage:


>> API.delete_file(‘notARealKey’, ’johnd’, ‘fido’, ‘somefile.aiml’, ‘aiml’)
somefile.aiml successfully deleted        
>>


To compile a bot:


API.compile_bot(user_key, username, botname)


Example Usage:


>> API.compile_bot(‘notARealKey’, ’johnd’, ‘fido’)
fido has been successfully compiled!        
>>


To initiate a conversation with a bot:


API.init_talk(user_key, username, botname, input_text, recent)


This function returns a session_id,which allows the bot to maintain information about individual conversations. 


Note: recent is an optional parameter to pass to your bot. 


Example Usage:


>> session_id = API.init_talk(‘notARealKey’, ’johnd’, ‘fido’,’hello’)
Hi there!
>>


Example Usage with recent:


>> session_id = API.talk(‘notARealKey’, ’johnd’, ‘fido’, ’hello’, recent=True)
Hi there!
>>


To continue a conversation with a bot:


API.init_talk(user_key, username, botname, input_text, session_id, recent)


This function requires a session_id, such as the one returned in the previous example.


Note: recent is an optional parameter to pass to your bot. 


Example Usage:


>> session_id = API.talk(‘notARealKey’, ’johnd’, ‘fido’,’hello’,session_id)
Hi there!
>>


Example Usage with Recent:


>> session_id = API.talk(‘notARealKey’, ’johnd’, ‘fido’, ’hello’, session_id, recent=True)
Hi there!
>>


To debug input to a bot:


API.debug_bot(user_key, username, botname, input_text, session_id, reset, trace, recent)


Note: session_id, reset, trace, and recent  are all optional parameters. Trace, if included, will include AIML trace information for an input  Reset resets a bot’s memory, erasing predicates as well as that and topic information. Trace 


Example Usage with Trace:


 


To view the names of a bot’s files:


API.get_files(user_key, username, bot)


Example Usage:


>> API.get_files(‘notARealKey’, ’johnd’, ‘fido’)
aiml: pops_initial.aiml 
substitutions: person2 person normal gender denormal 
maps: no map files
sets: no set files
properties: properties
pdefaults: no pdefaults
>>


To find out which bots you have:


API.get_bots(user_key, username)


>> API.get_bots(‘notARealKey’,’johnd’)
Number of bots:  1.
fido
>>