Skype Bot for Fun and Profit – Part II – Getting it Running

This is a post from the Skype Bot for Fun and Profit series. This is the second part in the series and if you want to get your bot running you will need to have some prerequisites filled out, see the first part for the list.

Configuring and running

There is a skype-bot project at github. It is written in Java and has support for simple functionality. You can clone it via:

git clone https://github.com/toomasr/skype-bot.git

The project is maven based and once you import the project into your favourite IDE that has maven support it should compile out of the box. Before we can actually run the project we need to make couple of adjustments. First make a copy of the project.properties file and make it personal.properties. Then change the username, password and pemfile attributes in the file. Make sure that the folder that has the pem file also has a der file that has the same name (except the extension of course).

Next lets build the project. It is sufficient to just issue a mvn install command. You will end up with a skype-bot-0.0.1-SNAPSHOT.jar in the target folder. Before we can run that we need to start the runtime. See Running the Runtime from the previous post.

Now we are ready to start the bot. Issue a java -jar target/skype-bot-0.0.1-SNAPSHOT.jar. Now expecting that the Runtime is still running and that you updated the credentials in the personal.properties file you should see your need friend come online and you can start a chat.

The bot has the commands that he reacts to defined in the org.zeroturnaround.commands package. But for starters you can tell him “bot: time” and it will tell you the time.

Web Server

The bot also launches a web server on port 2500 that has defined handler on the url http://0.0.0.0:2500/post. You can send a POST message there with the parameters message=? and group=?. This will instruct the bot to issue the message to the group. The group is looked up from the bot’s list of groups that matches the Conversation.PROPERTY.displayname.

So what can we do with this? Most of the todays services have webhooks. For example GitHub has Service Hooks, FogBugz have Web Hooks and others have similar services. This means that you can register a web hook and when an event happens the bot will tell you over Skype (in a group chat for example).

What next?

This is up to you, hopefully you have a friendly bot. Make him tell you important information that you care about and don’t let him waste your time. Check back to the original article if I’ve added anything to the series.

  • care

    In the Maven install command groupId should be com.skype.

  • care

    And in SkypeGlobalListener class OnH264Activated method does not override any method, because there is no such method in any of super classes.

  • http://www.zeroturnaround.com/ Toomas Römer

    The OnH264Activated was added in the latest SDK version I think.

  • http://www.zeroturnaround.com/ Toomas Römer

    Can you explain? Cannot spot it right now.

  • Oli Wade

    I get a COMPILATION ERROR:
    ==
    [ERROR] SkypeGlobalListener.java:[24,7] org.zeroturnaround.SkypeGlobalListener is not abstract and does not override abstract method OnQualityTestResult(com.skype.api.Skype.QUALITYTESTTYPE,com.skype.api.Skype.QUALITYTESTRESULT,java.lang.String,java.lang.String,java.lang.String) in com.skype.api.Skype.SkypeListener
    ==
    Followed by BUILD FAILURE; what could be wrong?

  • http://www.zeroturnaround.com/ Toomas Römer

    The skype API you are using is newer than my code and it does not override the method that the error is babbling about. Override that method in SkypeGlobalListener and you will be good to go.

  • Oli Wade

    Thanks Toomas!

    I added the following and now the build succeeds:
    ==
    @Override  public void OnQualityTestResult(                com.skype.api.Skype.QUALITYTESTTYPE type,                 com.skype.api.Skype.QUALITYTESTRESULT result,                 java.lang.String s1, java.lang.String s2, java.lang.String s3) {  }==

  • Oli Wade

    I also needed to add “skype_instance.Start();” following “skype_instance.Init(transport);” in SkypeEngine.java, following the SkypeKit FatalAssert as per this post:
      http://devforum.skype.com/t5/Accounts-Sign-in/Linux-runtime-terminates-at-GetAccount-in-Java/td-p/11516

  • http://www.zeroturnaround.com/ Toomas Römer

    Thanks for the report. My git repo now have both fixes in (the new override method and the Start() methodcall).

  • Oli Wade

    Perhaps they mean on the github page when you install the skype-sdk-1.0.jar file?
    Regardless it worked for me just as you had written.

  • Oli Wade

    Cheers Toomas; much appreciated!

  • Sam Joseph

    great project! Trying to get it working but failed on the mvn install :-( full details here: https://github.com/toomasr/skype-bot/issues/1

  • http://www.zeroturnaround.com/ Toomas Römer

    I’ve commeted at github. First reaction is that Skype SDK is out of date or maybe even too new.