Best answer

JSON formatting issues and help needed!

  • 16 September 2020
  • 3 replies
  • 383 views

Userlevel 1

Hello! 

 

I’m not too saavy when it comes to coding or more experienced formatting, so forgive me if the situation sounds a bit confusing!

 

I’m currently in the middle of creating a messenger/SMS chatbot on Manychat, specifically I am working on a section in which the customer will choose a time from a list of times for when they want their order delivered to them. I am doing this by connecting a spreadsheet that lists all the timeslots for each day of the month to the chat platform via zapier (Someone says they want order delivered on 9/20/2020, zapier checks all available times on 9/20/2020 and sends data back to Manychat)

 

Now, I want these times to show up as “Quick Reply Buttons” when sent to the customer, and the only way for me to do this is by using their “Send Dynamic Content” zap, which is formatted in JSON. I’ve never worked with JSON or any other formatting syntax before past Markdown, so I’m having a bit of trouble with how it should be formatted, because every time I try and send a message it says the format is incorrect. A link to the formatting doc on Manychat is here

 

If there are any resources any of you know to help out with understanding JSON it would be greatly appreciated as well, thanks!

icon

Best answer by Mercology 17 September 2020, 17:28

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

3 replies

Userlevel 4
Badge +5

@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?  

 

 

 

Userlevel 1

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. 

Userlevel 4
Badge +5

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": "${timeRecomendation[0]}",
"target": "My Content"
},
{
"type": "node",
"caption": "${timeRecomendation[1]}",
"target": "My Content"
},
{
"type": "node",
"caption": "${timeRecomendation[2]}",
"target": "My Content"
},
]
}
}`

output = [myJSON];