Tag: Shotgun

Replying to Shotgun messages on an Android phone.

by on Aug.03, 2011, under Coding, Python

On the project “Them Greeks“, we are using Shotgun for managing the project.

One of the things that annoys me the most is that i cannot reply straight to one of the shotgun emails from a note or Ticket.

To make it even more frustrating i have an android phone and using any of the browsers available i cannot for  the life of me make a reply….

So i decided to see if i could get the shotgun_api3 to run on SL4A python on my android. It worked. Next to write a little wrapper i could use to reply to messages i got in my email.

One of the things I had to do was get the email notes to include the note id, so that i could reply directly to the note via the api.

So to get this to work, you will need to have an android phone with SL4A installed on your android phone.

You will also need Python for Android installed.

Once you have these, you will need to get hold of the shotgun_api and copy it to your phone.
You will need to place the in your sl4a scripts dir, it should live here:


So here is my first version of the code, it will need to go into the same directory as above to run.

You can put it into a new directory, but you need to put the in there as well.

# setup imports.
import android,os,sys
# setup android
droid = android.Android()
# setup where to find the shotgun api on my phone
# I placed it in my sl4a scripts directory
scripts = os.getcwd()
scripts = scripts +'/scripts/'
from shotgun_api3 import Shotgun
# setup the api script and project im working on.
# this is how sg allows us to communicate with it.
SERVER_PATH = "server path"
SCRIPT_NAME = "script name here"
SCRIPT_KEY = "script key here"
# currently I am the only one using this.
# at a later date ill allow for other users.
userId = 188#kym watts
def replytoNote(noteId='',noteText='',userId=''):
 #  this is a base function for replying to a note in sg with some android ui
 #  bits added to the mix.
 noteID = droid.dialogGetInput('Value', 'enter noteid:', str(noteId)).result
 print type(noteID), noteID
 if not noteID == None:

  noteId = int(noteID)
  replyText = 'enter reply for note %s:' % (noteId)
  noteText = droid.dialogGetInput('Value', replyText, '').result
  #noteId = 974 #"pipeline - planning" note
  #noteText = 'Did you know if you put your mind to it.\nYou can do awesome things.\n\n'
  dReply = {
   'content': noteText
  print 'msg sent to note id:%s'%(noteId)
 print 'no note id returned.'

noteId = 1304
noteText = 'sent from my android phone.'

So some things that you need to update yourself before you run this for the first time:

SERVER_PATH = "server path"
SCRIPT_NAME = "script name here"
SCRIPT_KEY = "script key here"

These you need to get from your shogun server. It might be good in terms of tracking and debgging to create a api script just for this script.

userId = 188#kym watts

You will also need to know what your user name is , so that your reply’s will come from you and not the api script.

So thats pretty much it.
Some stuff i would like to add in the future is:

Functions to handle tickets and other things to reply to in shotgun.
Functions to deal with queue of reply’s till there is a valid connection with the sg server, this would mean i cn read my mail and do replys on the train and have them send when my phone has service again.

So what happens when you run this?

It will prompt you with 2 text inputs.

The First needs to know what the noteid is. This s the note you want to reply to.

The second is the text that you want to reply with. This text field will accept the enter key to seperate things with a new line.

If you can think of any other useful things this could have give me a shout at:

watts[ d o t]kym[ a t ]gmail[ d o t]com

Leave a Comment :, , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!