@tmarcus96 I would be happy to create a code sample. Here’s what I need:
- JSON Structure - already provided.
- Fields from previous steps that will be used in the JSON.
- Where to place the fields in the JSON. For example the text for the message comes from where?
Once the JSON is created, is there an existing Zap to send the request?
Thanks so much for taking the time to help me out! Answers to your questions are below.
The zap itself gets triggered once the customer responds to the chatbot with their preferred delivery date and time of day (Morning, Afternoon, Evening). The data that the customer responded with is used to find free time-slots in their preferred time-frame. When times are found, they will be recalled in the message to the customer in the form of quick replies (See image attached).
The three main dynamic fields are the preferred delivery date, time of day, and the time recommendations. Delivery date and time of day will be located in the main text of the message, with the time recommendations being individual quick replies.
As for the non-dynamic content, I don’t have it written yet. From what I understand, if the format for this zap is set up correctly with sample text, I should be able to replace with the final content at any point without issue, correct?
The zap is created, but I can’t share it as it isn’t turned on yet (I was waiting to upgrade to pro until I had all of my zaps completed to the point of needing to be tested).
Let me know what else you need from me! This is the first time I’ve made more of an ecosystem of zaps as opposed to individual ones, so there’s a lot of advanced skills that I’m still trying to grasp.
Made a few assumptions and have not tested, but here is how to create the JSON with the trigger values. Let me know if you need more help, we could get on a Zoom meeting...
var date = inputData.deliveryDate;
var time = inputData.timeOfDay;
var timeRecommendation = =];
var simpleTest = "Your Message Here";
//Assumming you have 3-time slots per time of day
if (time =="Morning") {
timeRecommendation.push("09:00 AM", "10:00 AM" , "11:00 AM");
} else if (time =="Afernoon") {
timeRecommendation.push("12:00 PM", "01:00 PM" , "02:00 PM");
} else if (time =="Evening") {
timeRecommendation.push("05:00 pM", "06:00 PM" , "07:00 PM");
}
//Build the JSON using the variable create above.
myJSON = `{"version": "v2", "content": {
"messages": :
{
"type": "text",
"text": "${simpleText}"
}
],
"quick_replies": :
{
"type": "node",
"caption": "${timeRecomendationo0]}",
"target": "My Content"
},
{
"type": "node",
"caption": "${timeRecomendationo1]}",
"target": "My Content"
},
{
"type": "node",
"caption": "${timeRecomendationo2]}",
"target": "My Content"
},
]
}
}`
output = =myJSON];