Robot Not a Dev? Buy Now
Not a Dev?

Misty Community Forum

Training Mission: Hello (REST) of the World

Briefing

Mission Objective: Complete Misty’s Intro to 3rd Party API Integration Tutorial
Mission Type: Training
Capabilities Exercised: misty.SendExternalRequest()
Proof of Completion:* Share your code in the Misty Skills category
Est. Time to Complete: 1 - 2 hours
Launch Date: 10/4/2019
End Date: Ongoing


For this mission, we’d like you to exercise Misty’s ability to request data from external web APIs. We think Misty’s developers will rely heavily on this functionality, and we want to gather feedback from developers who use who it in their code.

You might try using this mission to write a skill that has Misty send a request to a weather API, so you can code Misty to react with unique, emotive responses to different types of weather. Or, you might integrate Misty with a cloud service provider like Microsoft Azure to give Misty text-to-speech capabilities (see the tutorial on this functionality for more details). But don’t let our suggestions bound your imagination – the sky’s the limit! :rocket:

Overview

Misty’s API includes a command for sending HTTP requests to external web APIs. You can call this command in an on-robot skill by using the misty.SendExternalRequest() method. You can also call the REST API endpoint for the command to write an external application that has Misty send a request.

You can configure the SendExternalRequest command to automatically save image and audio file return types to Misty’s system. If your request returns another data type, you’ll need to pass the response data into another function and write the code that describes what Misty should do with it.

When you call the misty.SendExternalRequest() method from an on-robot skill, you can use the misty.Debug() method to print response data to the Skill Runner web console. This is a great way to dig into the response data and understand how to use what Misty receives from the resource at any given URI.

Results

Our goal with this mission is to see how easy it is for developers to integrate Misty with web APIs and cloud services. We’d like to hear your feedback on developing skills with Misty’s SDK, and we’re interested to hear your suggestions on how we can improve Misty’s tutorials and developer documentation.

When you complete the mission, we encourage you to share your skill with other developers by posting it here in the Misty Community Forums. If you film your interactions with Misty, please share your videos here, too – we’d love to see them!

Getting Help

If you get stuck, check out the External Requests tutorial in Misty’s developer documentation. Please leave a comment here or post in the MistyCommunity Slack if you have any questions or run into issues. Take notes on your experience, and let us know when you run into roadblocks. We look forward to hearing about your progress!

Situation

What good is a robot if it can’t make a decision?
Even a simple yes or no would be helpful in situations like - Should I eat out or in? Should I quit or stay? Does he/she love me or not?

In this awesome “yes or no” skill you’ll query an API and then have Misty do something (like play a different sound or wave her arms or move or something cool) to signal Yes or No, Yay or Nay, loves me or loves me not.

You’ll need some way to trigger the API call like maybe recognize a face? Or have someone tap her bumper sensor or maybe have someone touch her head.

I know what you are thinking… Why connect to a web API to get a yes/no answer when any simple random method would suffice? The question is why not…?

Training Mission

Connect Misty to one of the simplest REST APIs out there
Yes Or No? yesno.wtf — foolproof™ decision-making (api available) simple returns either a yes or no.

Rules

Let us know you’ve completed these activities by responding to this thread. Then, check out the competitive 3rd Party Integration to see how you can earn a community badge and get a chance to win some sweet Misty swag!

Results

Share the mission in the community forums, in the Misty Skills category

Resources

Here’s what you’ll need to complete this mission:

  • a Misty II robot, connected to your local Wi-Fi network
  • code editing software (like Visual Studio Code, Sublime, or Atom)
  • Check out this tutorial on sending an external request if you need help
  • Look at the Misty docs for more information on the external request method
  • Or use the REST API endpoint if you prefer to do it that way.

Mission Support

Hit a roadblock? Find a bug? Have feedback? Let us know! As Misty’s earliest developers, you are the real superstars on the journey to making personal robots a reality. Your creativity makes all this possible, and we’re eager to hear your feedback. Reply to this post to start a conversation with a member of the Misty team.

Completed the Training Mission. I will look at the competitive mission now.

2 Likes

Amazing! Keep it up.

Ok, have been working on this, here is some feedback:

The Microsoft Azure intro is “amazing” but perhaps a little overwhelming as a new Misty user just trying to learn to use an API. You don’t need Azure to do this Mission.

The documentation for misty.SendExternalRequest still uses APIXU, which is changing to weatherstack. The tutorial details of using the API and parsing the JSON information is not updated. I followed weatherstacks recommended changes to switch to new API, and reached a point where I knew Misty was reaching the weatherstack site (API Usage in the Weatherstack Account Dashboard were incrementing), but am not able to properly parse the weather data on Misty.

And finally I tried to use the Yes or No API…and have not completed it yet. I chalk it up to me being a beginner, and still learning. Don’t tell me the answer! I will figure it out, but out of robot time this week.

2 Likes

Thanks for the feedback! Appreciate you going through the tutorials and letting us know about the APIXU changes - we’ll update the docs to reflect that. Any luck parsing the Weatherstack response data on Misty? There are still a few days left to share a skill on the forums for a chance to win some gear :slight_smile:

Figured it out. Misty nods or shakes head depending on the returned yes/no answer.

In the Hello World mission, all the code is provided. In this mission, example code is provided but has to be changed for the yes/no api. My hint for those that need it is the website that Misty send the external request to has to return a JSON string. Test this out by typing the exact request into your web browser, and verifying that JSON formatted response is provided back (not a gif or fully populated website).

Also worked through the APIXU to weatherstack changes - you can see them here.

Now on to the next Mission!

4 Likes

This is awesome. We’d also love for you to share your skill in the Misty Skills section. There is a handy guide to posting skills here:

That way there is a growing “directory” of skills that have been created by the amazing Misty community!

Thanks!

1 Like

I tried to complete the tutorial referenced here for external requests then I realized that it links to a tutorial for Misty I. I tried to modify the code to work for Misty II based on the callout in the instructions but it doesn’t seem to work. I’d recommend linking to the tutorial docs for both devices in the future to avoid confusion.

That it does. Or did. Just fixed. Just needed to an an extra “i” to the url :slight_smile:

https://docs.mistyrobotics.com/misty-ii/coding-misty/local-skill-tutorials/#external-requests

Sorry about the @edensjasmine

2 Likes

I’ve been trying to display the gif that the website returns. Is misty capable of displaying that filetype?

Were you able to get this working? Misty should be able to save images formatted as .gifs, but she only shows a still image when you display animated .gifs on her screen.

Hi @edensjasmine. Found this to try.

There is a gif display workaround process. It appears that prework is needed to get the gif to properly work (as a gif). I tried this with one of the gifs from the yesno api website, and it did work but did not fill the entire Misty screen, just top left. Instead of looping once, changed the loopCount to 5 to keep it on Misty screen longer. When you split the gif on the website in step 1, I believe you need to select box “UNOPTIMIZE TRANSPARENT GIF (USE IT IF YOU SEE ARTIFACTS).”

Thanks goes to @cp_sridhar for the code and instructions located below. Hope this helps.


3 Likes

@MorningR. Wow, nice find! I hope that code gets incorporated into the Misty platform in the future to make displaying the gifs easier.

@johnathan - I wasn’t able to get it to work but I mostly focused on triggering the command via touch or bumpers instead last night. I may try again tomorrow now that I know the displayImage method is expected to work with that filetype. I’m fine with the gif just showing up and not looping.

1 Like