Condition block does not seem to work

I'm working with Typebot to create a WhatsApp channel bot, with a scenario where if a customer wants to talk to a human agent, I'm connecting them through Chatwoot's API inbox. Currently, what I'm doing is, I first create the user to generate the user ID (variable I called Chatwoot ID), using the HTTP call block. Then, from the response I get from this, we capture a variable I called "Chatwoot ID", which is sourced from the data.payload.contact.id, and source_id, which is also named source_id from Chatwoot. The next block will create the conversation and send a first outgoing and first incoming messages. From this response, I'll set 3 more variables: Chatwoot Conversation ID (which is the ticket number from Chatwoot), last_message_id (which is set as 0), and loop_counter (which is also set as 0). Then, I'll send the first incoming message (while not displaying it to the customer), using the same headers and URL as before, but using this as the body: { "content": "Olá, gostaria de ajuda", "message_type": "incoming" } and I'll set this message content, as the first "customer_message". picking anything as “outgoing” even though jt comes back on the HTTPs request and therefore, not displaying the agent messages. Anyone have any ideas on how to get this to work?
No description
No description
1 Reply
Artikuma
ArtikumaOP2mo ago
And that's it. I tried doing a loop but it didn't work. I need to check if there are any new customer messages, so I can do a POST to display it to the agent on Chatwoot, while also checking if there are any messages from the agent to the customer, which I need to display to the customer through Typebot as well. I have tried creating loop before with you which checks to see if the "latest_message_id" is different than the "last_message_id", which, if it is, goes to a second layer where I check the sender_type, and if it's "User", means that it's from an agent, which if it is, I have a check to see if it's not the conversation-ending auto-message, and if it is not, I'll then display the latest_message_content to the customer, set the last_message_id as the latest_message_id and go back to the GET data fetch. For the customer check, if the message_sender_type is not "Outgoing", than that'd be a customer message, in which case I tried just doing POST to show that directly to the agent, adjust the last_message_id to be the "latest_message_id", reset the "customer_message" as "" (empty), and go back to the GET call. Everything the customer submits is seen by the agent on Chatwoot, but if agent sends something back, it seems like my rule is not

Did you find this page helpful?