How to call api by passing chat text in 10.2 versions

Hi, I’m using botpress 10.2. and trying to call api by passing chat text from user to api .please help me how to call api in botpress 10. + version

hi @ABHI_INIT
i recommended to user new version 12.xxx
there i are new skill call api easy to use

i didn’t find doc for version 10.2
but i think you can do
u get the var from user memory.var
like {{temp.name}}

const axios = require(‘axios’)
URL = “http://api.xxxxxxxxxxxxxxx/”
URL = URL + temp.name

axios
.get(URL)
.then(({data}) => {
data = JSON.parse(JSON.stringify(data).replace(“place name” , “placename”));
user.placename = data.places[0].placename;
console.log(user.placename)
})
.catch(console.error)

to return ui {{user.placename}}

Hi @ABHI_INIT, here’s a sample action to send the user’s message to an api:

async function action(bp: typeof sdk, event: sdk.IO.IncomingEvent, args: any, { user, temp, session } = event.state) {
  /** Your code starts below */

  const axios = require('axios')
  /**
   * Small description of your action
   * @title The title displayed in the flow editor
   * @category Custom
   */
  const myAction = async (name, value) => {
    // List all event fields so you can see the variable you need
    console.log(event)

    // The user message is available here:
    const userMessage = event.preview

    // Then a post request to your API with the user's message
    const { data } = await axios.post('http://someurl/message', { userMessage })
    console.log('API Result', data)
  }

  return myAction(args.name, args.value)

  /** Your code ends here */
}