A Short Tutorial

This quick 3-step tutorial will get you in the right headspace to create powerful automation tools. You don't need to have any prior experience in coding bots or automation tools, but it is suggested that you have a small background in programming, specifically Javascript. CodeCademy is an excellent resource for those who are new to Javascript.

Otherwise, let's get right to it!

  • 1

    Creating Your Custom Script File

    Even though you might not fully understand how the Somiibo scripting language works just yet, let's walk through how to add a script to Somiibo. We'll get to the fun stuff soon enough!
    First, open your favorite text editor, such as Atom and create a new file in a directory of your choice. Name this file myFirstScript.js
    Result image
    Next, we're just going to add some code. Again, we'll go over what it does soon. For now, just add the following code to myFirstScript.js by copying it from below and pasting it into your text editor. Be sure to save the file.

    copy
    
    //my settings
    var userSettings =
    {
      "textbox1": {
        "input": {"type": "text", "default": "https://google.com", "title": "Enter a website", "placeholder": "include the http"}
      }
    }
    
    //my variables
    var myFirstVariable = 42;
    var userWebsite;
    
    //my bot script
    async function run(currentTab) {
      bot.generalProcedure()
    
      if (bot.getProtocol() == 'init') {
        userWebsite = bot.getSetting('bot', 'bot_custom_main_textbox1')
        bot.setProtocol('main')
      }
    
      if (bot.getProtocol() == 'main') {
        await bot.navigateUrl(userWebsite)
        if (bot.getProperty('urlLoaded') == true) {
          bot.alertBox({title: 'Made it!', text: 'Successfully navigated to '+userWebsite, type: 'success', confirmButtonText: 'Ok'})
        } else {
          bot.alertBox({title: 'Oops!', text: 'We never got to '+userWebsite, type: 'warning', confirmButtonText: 'Ok'})
        }
        bot.end();
      }
    
      setTimeout(function () { run() }, bot.getRunDelay());
    }
          
  • 2

    Opening the Custom Module

    Now it's time to put your new script into Somiibo! Go ahead and open Somiibo (or download it here) and click the to open a new bot tab. From the module selection screen, select the Custom Bot Module (pictured in the bottom right below)
    Result image
    This module will open a settings window with only one field. This is where you'll put your myFirstScript.js file. You can do this by clicking the blue Choose File button and then navigating to your script inside the pop-up.
    Result image
    Selecting a script will automatically import the settings defined in the script
  • 3

    Testing Your Custom Script

    Let's test the script! This example script has one setting named Enter a website. Put any URL in this box. For this example, let's enter https://facebook.com and then click the blue Save button
    On the next window you'll be presented with the typical Start and Stop buttons. Go ahead and click to run your custom bot script. This particular example script will navigate to the page you entered in the settings page, and then show you a simple message. Check the image below to see an example of a successful navigation to our example URL https://facebook.com.
    Result image

    Pro Tip:

    Press Cmd + I or Ctrl + I to open the developer tools. Here you can see a console and any errors that might break your bot!

Conclusion

Okay so we didn't go incredibly into detail about each and every aspect of the script. But it's important to understand the basics first. In the next section we will go over some examples of premade custom bots that you can disect all day long! Head over to the example modules to see how some of your favorite bots are made.