Pokemon Battle Simulator
Run this API to receive ability stats from PokeAPI, feed them into ChatGPT and let it tell you who would win Pokemon combat!
Name Variables
The default template assigns Charizard and Dragonite for the Pokemon A Name
and Pokemon B Name
variable. Those variables will later be used in the HTTP request and ChatGPT input.
Change those name inputs to let other Pokemons to participate in combat.
HTTP Request
The HTTP action sends a request to a RESTful API of https://pokeapi.co/, returning information about Pokemon, their characteristics and abilities. The default template sends a request to:
We are placing {{steps.pokemon-a-name.value}}
at the end of the request URL, which is the Variable we assigned in the previous step. This way, we will receive information about Charizard
from the PokeAPI in the default template. To receive information about other Pokemon, we simply change the input in the variable Pokemon Name A
.
In the second HTTP request we repeat the same process to receive information about Pokemon B.
Ability Variables
The HTTP request returns data about the Pokemon we provide it with. More specifically, it will provide an array with information of two of its abilities. We will assign a variable for that arraw in the following way:
We are interested in its abilities and will assign a Variable for it. We will put:
{{steps.pokemon-a.outputs.Body.abilities}}
= Pokemon A Abilities
.
An example for that array would be:
We repeat the same process for Pokemon B Abilities
.
ChatGPT
Since we assigned variables to the Pokemon names and abilities, we can provide ChatGPT with a standardized text input which will work for all Pokemon pairings.
We provide ChatGPT with the following:
Answer this question with the pokemon name and give a one sentence explanation:
Which Pokemon Would win in a battle of abilities between
{{steps.pokemon-a-name.value}}
with{{steps.pokemon-a-abilities.value.[0].ability.name}}
,{{steps.pokemon-a-abilities.value.[1].ability.name}}
VS{{steps.pokemon-b-name.value}}
with{{steps.pokemon-b-abilities.value.[0].ability.name}}
,{{steps.pokemon-b-abilities.value.[1].ability.name}}
?
Result
In the default version of the template, we display ChatGPTs answer in a success response:
An example answer of ChatGPT could be:
We have a lot of flexibility on what we do with this result eventually. We can turn it into a little app and display the result in a Frontend or send the result via Slack.
Modification
One modification you can apply to this template is to delete the Variables Pokemon Name A
and Pokemon Name B
from the route and rather provide those inputs through a request you send to this endpoint.
How to do it:
-
Delete the name variable in the Fastgen route
-
Change the ending of the request URL you send to PokeAPI, for example:
and
- Change the ChatGPT name variable from
{{steps.pokemon-a-name.value}}
and {{steps.pokemon-b-name.value}}
to {{inputs.body.pokemona}}
and {{inputs.body.pokemonb}}
- Now you can send a request to your Fastgen Pokemon endpoint with a body like:
to execute the endpoint without manual changes of Pokemon names within the Fastgen route