HomeBlogExternal RequestJokes API Tutorial

Jokes API Tutorial

Jokes API Tutorial

I want to share this simple Jokes API that you can easily implement on your bot. Please refer to the images attached.
Follow the steps below:
1. Add a flow & Create two blocks – External Request Action Block & Message Block ( used to display the Joke with a Custom User Field RandomJoke )
2. With the External Request Block, Set up a GET Request Type with the End Point: https://icanhazdadjoke.com/
3. The Headers will simply have “Accept” as Key & application/json as for its value
Note: No Authorization & API Key are Required. 
4. JSONPath will have $.joke and save it to a CUF of your Choice ( I used RandomJoke )
Note: If you do a “Test Request” you will see the two data that you can reference & display which are “id” and the “joke” itself so the “$” sign will reference both and the $.joke will reference the “joke” data. You may also reference $.id if you want but it will not mean anything to your users so we will just GET the $.joke data. 
5. Display the Joke on a CUF your created on the Message block ( I used RandomJoke ) 
Note: I could have just easily created a template to share the flow but its best if you can set it up yourself to understand the fundamentals better. 
 
You can test the Joke API here: https://m.me/ElegantBotsAI?ref=randomjokesapi 

That’s it! Enjoy…

© Elegant Bots 2019. All Rights Reserved.