How to handle errors when calling an external API

amazon-alexa

#1

Greetings,

I am having some doubts about how to gracefully handle a possible error when making an API call. For example, if i have a trivia skill that gets the questions from a API, how do i respond to the user if there is an error while calling the API?

I found the following link: Notifications and Error Handling

In this link there are some recommendations about how to handle it, but i still have issues finding an answer to my problem. For example, should i tell the user there was an error getting the question and to try again, then redirect the user to the previous state??

What if the problem persists and it’s related to the external API? If the user goes through this message two or three times they’ll probable get tired and give up all together.

How would you handle it?

Thanks in advance.


#2

That’s a tricky one. I’d ask myself a few questions:

  • Is it possible to cache the API results somewhere to minimize the risk of the API not responding (and to speed up the response time)?
  • Is it possible to have some sort of back-up content in case the API doesn’t work?
  • Is there an alternative API you can call in case the first one fails?

I think telling the users “I’m sorry, I’m having trouble accessing …” isn’t a perfect user experience, but if you’re transparent about it and tell them to come back in a little while, it’s still OK.

Or maybe think about a way to add personality to turn a frustrating experience into something memorable. The Twitter Fail Whale is very well known for example:

image


#3

hey @jan,

Thank you for your input. I did not take into account those possibilities. I really like the backup option, maybe it will not work exactly like the API because the API actually stores the points and deliver prizes when the user answers correctly.

It can definetly work to make the user have a better user experience though. I’ll try to figure out the best approach possible considering those options.

Thank you for your support


#4

Great! Let me know what you end up doing :+1: