Editing flows
This guide will show you the basic process of editing a Flow. In this example we will walk through the process to edit the decline messages in the chatbot.
Finding the correct Flow, Node and Action
Flow structure
The basic structure of the Flow resource goes as follows:
a Flow has multiple Nodes
a Node has 1 or more NodeActions
a Node has 0 or more NodeTransitions
the starting node of a flow is marked with
isStartFlow: true
an end node of a flow is marked with
isEndFlow: true
end nodes have
endFlowType
set to either 'accepted', 'declined', 'reset' or 'update'
When a Flow is generated by our AI it will follow the following structure:
There is only 1 start Node
There is only 1 'Accept' end Node
There is only 1 'Decline' end Node
Every node has only 1 Action
Finding the Action Id
To find the correct action to alter, we need to identify which Action belongs to the 'Decline Node' of our target Flow.
With this request we are filtering all the nodes of our target Flow, ensuring only the 'Decline Step' Node shows up including all of its NodeActions (in the case of an AI generated Flow this should be only one say-text Action).
curl "https://api.recrubo.app/public/v2/nodes
?filter[flowId]=<your flow id>\
&filter[endFlowType]=declined\
&include=nodeActions" \
-H 'Accept: application/vnd.api+json' \
-H 'Authorization: Bearer <your auth token>' \
And it should yield a result similar to:
{
"data": [
{
"id": "4801cbb6-3a1a-4f8f-bcc4-c6f9cf7c36ae",
"type": "nodes",
"attributes": {
"createdAt": "2024-07-11T17:16:07+00:00",
"updatedAt": "2024-07-11T17:16:27+00:00",
"name": "My decline step",
"index": 0,
"isStartFlow": false,
"isEndFlow": true,
"endFlowType": "declined" // this node is a decline step
},
"relationships": {
"flow": {
"links": {
"related": "/public/v2/flows/e1cee7fa-2472-47fe-87b0-8074eda4c4b8"
}
},
"nodeActions": {
"links": {
"related": "/public/v2/node-actions?filter[nodeId]=4801cbb6-3a1a-4f8f-bcc4-c6f9cf7
},
"data": [
{
"type": "nodeActions",
"id": "c02c273a-5cef-4de6-8f06-5df2964348cf"
}
]
},
"nodeTransitions": {
"links": {
"related": "/public/v2/node-transitions?filter[nodeId]=4801cbb6-3a1a-4f8f-bcc4-c6f
}
}
}
}
],
"included": [
{
"id": "c02c273a-5cef-4de6-8f06-5df2964348cf",
"type": "nodeActions",
"attributes": {
"createdAt": "2024-07-11T17:16:08+00:00",
"updatedAt": "2024-07-11T17:16:11+00:00",
"actionType": "say",
"variableName": "",
"index": 0,
"subType": "text",
"attachmentData": null,
"value": {
"text": "This is the end node text!" // actual text of the decline step
}
},
"relationships": {
"node": {
"links": {
"related": "/public/v2/nodes/4801cbb6-3a1a-4f8f-bcc4-c6f9cf7c36ae"
}
}
}
}
]
}
In the response we can see that our Node has isEndFlow: true
and endFlowType: declined
, meaning that we have the correct Node. The text of our message is in the included
part of the response, there you should find 1 NodeAction
, this has actionType: say
and subType: text
meaning it is the NodeAction defining the output message
to the candidate.
Using its Id, we can then make a PATCH request that looks as follows:
curl 'http://api.recrubo.app/public/v2/node-actions/<your action id>' \
-X 'PATCH' \
-H 'Accept: application/vnd.api+json' \
-H 'Content-Type: application/vnd.api+json' \
-H 'Authorization: Bearer <your auth token>' \
-d '{
"data": {
"id": "<your action id>",
"type": "nodeActions",
"attributes": {
"value": {
"text": "My new Text!"
}
}
}
}'
Last updated