Call API with a parameter

In my bot for the cloud version I want to call API that returns a details based on the parameter, it keeps raising error " “Not found because of proxy error: Error: getaddrinfo ENOTFOUND xxxxxx”
Request failed with status code 404.
For API without parameter I managed to get the result.
Any one can help me with the correct syntax.

Hi @ibrahimbukh ,

Can you paste the syntax here after removing the sensitive data?

Hi Bassam

const url = 'http://xxxxx/api/values/GetcustInfo/
const response = await axios.get(url ,{params: {
phone: ‘123456789’
workflow.CustName =[0].name

Is this API published on the internet? Botpress platform is on the cloud, and if this API is local Botpress can’t access it.

You can use something like NGROK to publish your APIs in an easy way that is free.

Yes, its published in Internet.

if it is a GET request, then try:

const url = 'http://xxxxx/api/values/GetcustInfo?phone=123456789
const response = await axios.get(url)
workflow.CustName =[0].name

raised error
** 18:52:32debugExecute code “Call api”*
** 18:52:32errorError executing action “inline-ins-880aa81e50.js” in flow:Main:node:Standard8 [SyntaxError, Invalid or unexpected token]*
** 18:52:32debugEntering workflow (flow:Error) [node:Entry] from (flow:Main) [node:Standard8]*
** 18:52:32debugTransition from (flow:Error) [node:Entry] to [node:Standard]*
** 18:52:32debugSending Message. Type: text. Text: Sorry, an error occurred. Please try again later*
** 18:52:32debugTransition from (flow:Error) [node:Standard] to [node:End]*

other API without parameters working fine this way.**

There is a missing quote at the end did you try it with it?

const url = 'http://xxxxx/api/values/GetcustInfo?phone=123456789'
const response = await axios.get(url)
workflow.CustName =[0].name

New error now.

19:01:01errorError executing action “inline-ins-880aa81e50.js” in flow:Main:node:Standard8
HTTP (get) URL
Received “Not found because of proxy error: Error: getaddrinfo ENOTFOUND xxxxxx”
Request failed with status code 404
19:01:01debugEntering workflow (flow:Error) [node:Entry] from (flow:Main) [node:Standard8]

Hi @ibrahimbukh ,

Can you try this code?

const url = ''

const activities = 'activity?type=diy&participants=1'

const response = await axios.get(`${url}/${activities}`)


I out the same code as requested and got below error

Can you try that code in another bot, a new clean one? I am just trying to pinpoint where the issue is.
Because this code works for me directly, so please bear with me.

This works , but if you assigned to workflow variable workflow.CustName =[0].Name
you got error.


I don’t know the response of your API, but it seems that .data[0] doesn’t exist. Maybe the API returns nothing.

So check with console.log(

HI Bassam,
its returning one record, the question is how to assign values from returned record to a workflow variable.

  • 09:54:16debugSending Message. Type: text. Text: Ahlan أهلا
  • 09:54:16debugStarting from Main flow
  • 09:54:16debugTransition from (flow:Main) [node:Start] to [node:Standard8]
  • 09:54:16debugExecute code “Call api”
  • 09:54:17info{ Phone: ‘’, ACCOUNTNUM: ‘XXXXX’, Name: ‘XXXXXXXXXXX’ }
  • 09:54:17debugTransition from (flow:Main) [node:Standard8] to [node:End1]
  • 09:54:17debugExecuting “Conversation End” workflow
  • 09:54:17debugTransition from (flow:Conversation End) [node:Entry] to [node:Standard]
  • 09:54:17debugTransition from (flow:Conversation End) [node:Standard] to [node:End]
  • 09:54:17debugEnd of workflow

Which values do you want? In which format, etc. etc.

But the general idea is, or (case sensitive)
Or["Phone"], or["ACCOUNTNUM"]

You can read more here: JSON Literals