Link between API and it's transition

Hi All,

The API call part is working absolutely fine. The isssue I am facing is in the below scenario:

After the api response is stored in session.response and the api is called, my value will be found at session.response.data.result.0.value.1, so when i get this according to the response the value is 0.

I wanna say to the user that if vim is up or not according to the resultant value 1 or 0

I tried using the transition {{session.response.data.result.0.value.1}}===‘0’ to transit to next block saying The vim is down, Please try again later but it isn’t working out.

Can anyone please help me with it.

Thanks

Can you please share the action code where you are saving value from your response to session variable?

session.response.data.result.0.value.1

const axios = require(‘axios’)

/**

  • @title Call the Github API to fetch Botpress repositories

  • @category Turorial

  • @author Botpress, Inc.
    */
    const callApi = async () => {
    // We call the Github API
    const { data } = await axios.get(‘http://34.232.145.110:9091/api/v1/query?query=osm_vim_status’)

    // We assign the response to the session variable so we can use it later
    session.response = data
    }

// Actions are async, so make sure to return a promise
return callApi()// JavaScript source code

This is the “CODE”. I am saving the value in session.response, later fetch it from the botpress using session.response.data.result.0.value.1

Can you try below expression in your transition code?
{{session.response.data.result[0].value[1]}}==‘0’

Hi,
I could solve it. We aren’t supposed to put the curly braces and there should be triple equal signed and the assigned value should be within quotes…

So the solution for the same would be session.response.data.result.0.value.1===0

Thanks for all the help.
Really appreciate it.

Regards,
Joshitha