You can add a command to any Question and Response from the "Training & Chat Logs" page in your bot's Admin Console, or by importing a response list file of commands from the "Training & Chat Logs" page.
Commands are in JSON format (key/value pairs). Common keys are: type, action, name, location, extra, etc. The following gives details for each specific command Bot Libre Personal Assistant supports, as well as how to create your own commands using Generic intents.
See this forum post if you are unfamiliar with training your bot using Response Lists.
Below you will find examples for various types of commands. You may use or customize these by referencing the keys and values. If you wish to use voice commands with your Bot Libre Personal Assistant, create commands that match how you would say a date or time naturally (ex: "Set alarm for 6 o'clock am" or "Set alarm for 6:00 am").
Example commands in a response list script:
Take a selfie Opening camera command: {type: "camera", action: "selfie" }
Variables/wild cards are used to customize the Patterns used to match questions to commands. See this forum post for how to use pattern or wildcard responses. Like all responses, you can also add other identifiers such as keywords or required words.
Example commands using star(*) variables:
Pattern("Set timer for * minutes") Setting timer command: { type: "alarm", action: "timer", minutes: star }
Pattern("Send email to * with subject *") Sending email command: { type : "email", action : "send", address: star[0], subject: ""+star[1] } required: email subject keywords: send email
Alarm & Timer Commands
With these commands your bot can set alarms and timers using 12h time, customized to your syntax of choice.
Keys & Values:
- type: "alarm"
- action: "show", "alarm" or "timer"
- hour: "1"-"12"
- minutes: "00" to "59"
- ampm: "am", "pm", "a.m." or "p.m."
- day: any day of the week (ie: "Wednesday" or "wed")
Alarm examples from the Alarm/Timer Command script
Open alarms Opening existing alarms command: { type: "alarm", action: "show" }
// Set an alarm with a name: Set Nap alarm for 4 pm
Pattern("Set * alarm for * *") Setting alarm command: { type: "alarm", action: "alarm", name: star[0], hour: star[1], ampm: star[2]}
// Set a repeating alarm for weekdays/ends: Set alarm 6 am for monday, tuesday, wednesday
Pattern("Set alarm * * for *") Setting alarm command: { type: "alarm", action: "alarm", hour: star[0], ampm: star[1], day: ""+star[2] }
Timer examples from the Alarm/Timer Command script
Set a timer Opening timer command: { type: "alarm", action: "timer" }
Pattern("Set * timer for * hour * minutes") Setting timer command: { type: "alarm", action: "timer", name: ""+star[0], hour: star[1], minutes: star[2] }
Calendar & Event Commands
With these commands your bot can create customized events and access your native calendar
Keys & Values:
- type: "calendar"
- action: "insert"
- name: the name of your event
- location: the location of your event
- begin: begin time in SimpleDateFormat "MMMM d h mm aa" or "MMMM d"
- end: end time in SimpleDateFormat "MMMM d h mm aa" or "MMMM d"
Event examples from the Calendar/Event Command script
Create event Creating event command: { type: "calendar", action: "insert" }
//Create event with name and location: "Create event My Birthday at the pub"
Pattern("Create event * at *") Creating event command: { type: "calendar", action: "insert", name:""+star[0], location:""+star[1] }
//Create event with begin and end time: "Create event from August 20th to September 1st"
Pattern("Create event from * to *") Creating event command: { type: "calendar", action: "insert", begin:""+star[0], end:""+star[1] }
Camera & Video Commands
With these commands your bot can open your camera to take a photo or video
Keys & Values:
- type: "camera"
- action: "photo", "video" or "selfie"
Camera examples from the Camera/Video Command script
Open camera Opening camera command: { type: "camera", action: "photo" }
//Take a selfie (front-facing camera, may not work on all devices)
Take a selfie Opening camera command: {type: "camera", action: "selfie" }
Email Commands
With these commands your bot can send emails for you
Keys & Values:
- type: "email"
- action: "send"
- address: the email address to send to ([email protected])
- subject: the subject line of the email
- message: the message body of the email
Email examples from the Email Command script
//Send email with subject
Pattern("Send email to * with subject *") Sending email command: { type : "email", action : "send", address:""+ star[0], subject: ""+star[1] }
//Example command to email a group:
Send email to Gaming Group Sending email command: { type : "email", action : "send", subject: "Gaming this week", address : "[email protected], [email protected], [email protected]", message : "Hey guys, "}
Map Commands
With these commands your bot can access Google Maps, give directions and pick a mode (walking, biking or driving)
Keys & Values:
- type: "map"
- query: the location to find on the map
- directions-to: the location you want directions to
- directions-from: if you need directions from a remote location to another remote location
- mode: walking, biking or driving
- avoid: highways or tolls
Map examples from the Map Command script
//Open map to a certain location: "Open map Prairie Centre Mall"
Pattern("Open map *") Opening map command: { type: "map", query:""+star }
//Pick a mode from Driving, Walking or Biking (Automatically chooses driving if you do not specify) //Example: "Bike mode directions to 1425 Deadend Lane"
Pattern("* mode directions to *") Opening map command: { type: "map", mode: star[0], directions-to:""+star[1] }
Pattern("Directions from * to *") Opening map command: { type: "map", directions-to: ""+star[1], directions-from:""+star[0] }
SMS/Text Message Commands
With these commands your bot can send text messages and open contacts
Keys & Values:
- type: "sms"
- action: "send"
- number: the phone number to send a text to
- message: the body of the text message
SMS examples from the SMS/Text Message Command script
Send text Opening contacts command: { type: "sms", action: "send" }
Pattern("Send text to * with message *") Sending text command: { type: "sms", action: "send", number: star[0], message: ""+star[1] }
//Example command for common contacts,
Send text to mom Texting Mom command: { type: "sms", action: "send", number: "18882225555" }
Phone Commands
With these commands your bot can dial or phone a contact
Keys & Values:
- type: "phone"
- action: "dial" or "call"
- number: the phone number
Phone examples from the Phone Command script
Open phone Opening phone command: { type: "phone", action: "dial" }
Pattern("Call *") Opening phone command: { type: "phone", action: "call", number: ""+star }
Call Mom Calling Mom command: { type: "phone", action: "call", number: "1-555-888-4343" }
Open App Commands
With these commands your bot can open any app on your device, given the package name of the app, which you can find in the Google Play Store.
Keys & Values:
- type: "open"
- package: the package name of the app you wish to open
Examples from the Open Common Apps Command script
Open Facebook Opening Facebook command: { type: "open", package: "com.facebook.katana" }
Open WhatsApp Opening WhatsApp command: { type: "open", package: "com.whatsapp" }
Open Gmail Opening Gmail command: { type: "open", package: "com.google.android.gm" }
Creating your own Generic Commands
Using generic arguments, you can create and customize your own commands for your bot. Refer to the Generic Intent Commands script for some examples and ideas, if you do not wish to use the specific-type commands listed above.
Keys & Values:
- type: "intent"
- action: the Constant Value of the action to be performed
- uri: the data to operate on, expressed as a Uri
- dataType: specifies a certain type of intent data
- package: used if you require a package to access another app
- extra: a Bundle of extra data, expressed as an array of key/value pairs (see examples below)
Examples from the Generic Command script
Open map Opening map command: { type: "intent", action: "android.intent.action.VIEW", uri: "geo:0,0", package: "com.google.android.apps.maps" }
Pattern("send email to * with subject *") Opening email command: { type: "intent", action: "android.intent.action.SENDTO", uri: "mailto:"+star[0], extra:[{EXTRA_KEY: "android.intent.extra.SUBJECT", EXTRA_VALUE: "" + star[1]}] }
Pattern("Play music by *") Playing music command: { type : "intent", action: "android.media.action.MEDIA_PLAY_FROM_SEARCH", extra:[ {EXTRA_KEY: "android.intent.extra.focus", EXTRA_VALUE: "vnd.android.cursor.item/*"}, {EXTRA_KEY: "query", EXTRA_VALUE: ""+star} ]}
Scan QR Code Opening scanner command: { type : "intent", action: "com.google.zxing.client.android.SCAN", extra:[ {EXTRA_TYPE: "result", EXTRA_KEY: "SCAN_MODE", EXTRA_VALUE: "QR_CODE_MODE", CODE: "3"} ]}
Open camera Opening camera command: { type : "intent", action: "android.media.action.IMAGE_CAPTURE", extra:[ {EXTRA_TYPE: "result", CODE: "2"} ]}
Certain intents require a result. For Scanner results, use the request code "3", for Video/Camera results, use the request code "2".
If you encountered any issues, or would like help setting up your bot please email us at [email protected] or upgrade to our Platinum service and we can build your bot for you.
|