Hi - I'm trying to get my InMoov head to do more during speech and need some guidance.
Setup / context:
- ARC project using the AIMLBot robot skill for conversation.
- Bing Speech Recognition skill for speech input.
- Talk servo (mouth) is driven by an IoTiny (EZB) and speech plays from the IoTiny while the mouth moves.
- I have an ARC JavaScript script attached that was provided/created (by you?), but when I click Start it just sets everything to a default position. I may not be using it correctly.
Problem:
- I can ask a basic question and it verbally replies (mouth moves), but I cannot get the head servos (neck and eyes) to move randomly during the same speech. I want the neck and eyes to move randomly while the robot speaks.
Here is the script I'm using (ARC JavaScript):
function setNeutral() {
Servo.setPosition(D0, 90);
Servo.setPosition(D1, 90);
Servo.setPosition(D2, 20);
Servo.setPosition(D3, 90);
}
function setHappy() {
Servo.setPosition(D0, 100);
Servo.setPosition(D1, 95);
Servo.setPosition(D3, 100);
}
function setCurious() {
Servo.setPosition(D0, 80);
Servo.setPosition(D1, 110);
Servo.setPosition(D3, 110);
}
function setSad() {
Servo.setPosition(D0, 70);
Servo.setPosition(D1, 85);
Servo.setPosition(D3, 75);
}
function setSurprised() {
Servo.setPosition(D0, 110);
Servo.setPosition(D1, 90);
Servo.setPosition(D3, 105);
}
function randomSpeakingMotion() {
Servo.setPosition(D0, Utility.getRandom(75, 105));
Servo.setPosition(D1, Utility.getRandom(75, 105));
Servo.setPosition(D3, Utility.getRandom(80, 100));
}
function openMouth() {
Servo.setPosition(D2, 100);
}
function closeMouth() {
Servo.setPosition(D2, 20);
}
function detectReaction(text) {
text = text.toLowerCase();
if (text.indexOf("hello") >= 0 || text.indexOf("hi") >= 0 || text.indexOf("hey") >= 0) {
setHappy();
} else if (text.indexOf("why") >= 0 || text.indexOf("what") >= 0 || text.indexOf("how") >= 0) {
setCurious();
} else if (text.indexOf("sorry") >= 0 || text.indexOf("can't") >= 0 || text.indexOf("cannot") >= 0) {
setSad();
} else if (text.indexOf("wow") >= 0 || text.indexOf("great") >= 0 || text.indexOf("awesome") >= 0) {
setSurprised();
} else {
setNeutral();
}
}
var reply = getVar("$BotResponse", "");
if (reply == "") {
reply = " ";
}
detectReaction(reply);
// Open the mouth before speaking
openMouth();
// Let the head move while speech is active
while (getVar("$IsSpeaking") == "True") {
randomSpeakingMotion();
sleep(220);
}
// Close mouth and return to neutral
closeMouth();
sleep(300);
setNeutral();
Additional goal:
- I'd like to add a personality selector such as: "What kind of personality do you want the head to have: friendly, silly, serious, or more human-like?" and have the head act according to the chosen personality (or be able to switch among them).
- I also want to be able to ask for things like news and weather and have the robot reply back with that information.
Questions:
- Why does the script just set everything to a default when I click Start - am I starting/using it incorrectly within ARC (Robot Skill, script owner, or EZB setup)?
- How can I have the neck and eyes move randomly during speech (while the IoTiny is speaking and the mouth servo moves)?
- How can I implement selectable personalities (friendly, silly, serious, human-like) so the head behaves differently?
- How can I have the bot fetch and speak news/weather responses within the AIMLBot/Bing speech setup?
Thanks - any pointers about where I'm likely going wrong or what additional information I should provide (ARC project setup, Robot Skills used, EZB servo assignments, etc.) would be helpful.

You’re very close, but there’s a better ARC pattern than putting all of this in one standalone script and pressing Start.
The key issue
Your script is doing two different jobs:
$BotResponse)$IsSpeaking)That usually does not work the way people expect in ARC if the script is launched manually, because:
$BotResponsemay be empty when you press Start$IsSpeakingonly becomes meaningful while ARC is actually speakingRecommended ARC approach
Best practice
Use the AI/chatbot skill’s response script or the speech skill’s recognized phrase script to trigger the behavior, instead of starting a standalone script manually.
For your setup, the clean architecture is:
If you want the jaw to move with speech, Talk Servo is the right skill.
If you want neck and eyes to move randomly during speech, that should be handled by a script triggered when the bot is about to speak, not by a script you manually click Start on.
1) Why does it just set everything to a default when I click Start?
Because the script is not connected to a speech event.
Your script begins with:
So if
$BotResponseis empty, it still falls through and runs your default behavior.Also, pressing Start on a script is not the same as "run this when the robot talks." It just runs the script once in isolation.
What to do instead
Put the script into one of these places:
If you want the script to run after AIMLBot generates a response, then the AIMLBot response script is the correct place.
2) How can I have the neck and eyes move randomly during speech?
Better way
Don’t use a
while ($IsSpeaking == True)loop inside a script launched manually.Instead, create a short motion routine that is triggered when speech begins, and let it run while speech is active.
Option A: Use a script that starts motion, speaks, then stops
This is the most reliable pattern in ARC.
Example JavaScript:
Why this is better
$IsSpeakingtimingOption B: Use a second "background motion" script
If you truly want motion while speech is actively playing, launch a separate motion script from the response script and stop it afterward.
That is more advanced, but it’s the correct pattern if you want continuous motion.
3) How can I implement selectable personalities?
This is a great use case for a global variable and a personality behavior function.
Recommended design
Create a global variable like:
$Personality = "friendly"$Personality = "silly"$Personality = "serious"$Personality = "humanlike"Then branch your motion style and response style based on that variable.
Example personality selector logic
How to switch personalities
You can use:
For example, from speech recognition:
4) How can I have the bot fetch and speak news/weather?
There are two good approaches:
Best approach in ARC
Use the chatbot only as the conversation layer, and use JavaScript to fetch the data.
Use:
Net.hTTPGet()Example weather fetch pattern
If you use a weather API, your script might look like this:
For news, do the same thing with a news API.
Important note
AIMLBot itself is not ideal for live web data unless you use it as a trigger.
AIML is better for:
For dynamic data like weather/news, ARC scripting is the proven method.
What I recommend for your project
Structure it like this
1. Speech recognition
Use Bing Speech Recognition or another STT skill.
2. AIMLBot
Use AIMLBot for personality and conversation.
3. Response script
In AIMLBot’s response script:
$BotResponse$Personality4. News/weather
When the user asks for weather/news:
Net.hTTPGet()A cleaner example
Here is a much better starting point than the current script:
The bigger issue I want to call out directly
Your current design is mixing:
That can work, but in ARC it’s much more stable when you split them into separate robot skills and connect them with
ControlCommand()and global variables.That is the proven ARC way to build conversational robots.
What I need from you to give you the exact fix
Can you tell me:
Where exactly is this script located right now?
Which servos are on which ports?
Do you want the head motion to happen
Do you want the personality to be selected
If you want, I can help you build this into a proper ARC workflow using: