Get the response of steps, so that I can send it to API through JSON

I have collected the phone number and email Id through two steps, and I want to send them to API. So that I can use the phone number and email id to my API.

Is there any process like this?

2 Likes

@sagor_vrxl, Yes Sagor, it’s possible.

When you get any step value from the user, the step values are stored in app.context.steps which you can access via code.

Under API management, add the API URL you wish to call and in the params, add a key: value pair like this (the LHS value is for your API param name, the RHS value is the variable name you will use in your code to pass a value to it):

"mobileNumber": "{{mobileNo}}" 

After this on the left, you will see the list of APIs you have created. Simply select the API from the list, and you will see a copy icon there.

Copy it, and paste it any of your cloud functions (this will copy the whole api call syntax) and it will look like this:

app.executeApi('APIName', { mobileNo: app.context.steps.stepName }).then(app.log).catch(app.log)`.

Here, for the key value, you can pass the step value that was captured by the step and stored in

app.context.steps

Just make sure you follow the correct syntax for the params while adding them under API Management. as I mentioned initially.

I’ve attached some screenshots too, for reference:

Add an API ^

Screenshot 2020-12-14 at 14.11.20
API name from the list ^


Cloud function to execute the API ^

Hope this helps. Please let me know if there are any issues. Thanks!

3 Likes

Hi Yash,

I have an API response like this:

{
    "email": "[email protected]",
    "message": "Your Order is in progress",
    "name": "abc"
}

and I want to print the message in the next step what should I do?

What I have tried:

image

stored the response in the “message” variable and added a text like “Here is the {{message}} status!!”

But unfortunately, it is not working!!

1 Like

Hi Sagor,

When sending the variable “message”, please use the dot notation to send the value as mentioned here{{variables.variablename.Key-from-api}}. In your case if you wish to send name from api response, you could try sending {{variables.message.name}}

Please let us know in case of any queries

1 Like