# General troubleshooting

Troubleshooting information for issues Tray customers may encounter when using the Tray builder

## Help! I made a mistake and my workflow isn't working anymore.

######

### Rollback version

**Do not fret**. You can always roll back your workflow to a previous version.
Click on 'View history' at the very bottom edge of your browser window (while viewing your workflow canvas):
![view-history](https://tray.ai/documentation/images/help/troubleshooting/general-troubleshooting/drjBrUHSXPXfhxh8bfxYd_view-history.png)
PIck a date on the left, then pick a roll back version on the right. Your workflow will revert to the previous version:
![rollback-version](https://tray.ai/documentation/images/help/troubleshooting/general-troubleshooting/6FH9zXTr2FldpNr2xQs2Bo_rollback-version.png)

## Connector says it's not configured properly

### Explanation

Occasionally, when configuring a connector, the connector may throw an error saying it isn’t configured correctly, even if that connector still works.
In these instances, either replacing each input with the same value or simply removing and re-adding the connector should fix this issue.
This can be caused by caching issues, or other similar issues.
If replacing the values or connector doesn’t work, please create a support ticket with the Customer Support team! 

## Callable workflow doesn't show up in call workflow drop-down list

### Explanation

A child workflow (a workflow that starts with the callable trigger and is initiated by a calling/parent workflow) can be set to 'Trigger' or 'Trigger and Respond':
![callable-trigger](https://tray.ai/documentation/images/help/troubleshooting/general-troubleshooting/6OJEHlRgzk0r0TGss4LZhG_callable-trigger.png)
When the child workflow is set to 'Trigger and Respond', the parent workflow (the workflow doing the calling) needs to be set to **'Fire and wait for response'**.\*\* \*\*
Once you select that option, the callable workflow appears in the drop-down menu:
![fire-and-wait](https://tray.ai/documentation/images/help/troubleshooting/general-troubleshooting/1jbsUWDepGiWZ7isPsbexr_fire-and-wait.png)

##

Webhook-triggered workflow not executing

### Explanation

Some services require you to set up a webhook URL in your service's admin or developer dashboard before it will send the event payload to Tray.
Tray can't receive webhooks if they aren't sent and Tray's execution logs won't show a record of webhooks you are expecting; Tray's execution logs only show webhooks received.
You should refer to your service's documentation on webhooks to verify how to set up a webhook and monitor its execution.

### Example webhook setup

Stripe is a good example of a simple webhook setup which illustrates a process which should be common to most services:

### 1 - go to webhook list in the service dashboard

### Example from Stripe:

1. Login to your Stripe admin dashboard.
2. Look for the 'Developers' menu.
3. Click on 'Webhooks'
   ![stripe-webhooks](https://tray.ai/documentation/images/help/troubleshooting/general-troubleshooting/7tDzC4BMA4qRJSZ7iObugA_stripe-webhooks.png)

### 2 - add workflow public URL

Click on 'add endpoint' to add the URL of the Tray workflow you want Stripe to send events to:
![stripe-add-public-url](https://tray.ai/documentation/images/help/troubleshooting/general-troubleshooting/28iZBPxrmxdbiV52tFLsMV_stripe-add-public-url.png)
You can retrieve the public URL from the trigger of your workflow:
![copy-public-url](https://tray.ai/documentation/images/help/troubleshooting/general-troubleshooting/6Fmb9mwlNansy3yczhfyky_copy-public-url.png)

### 3 - set webhook events to send

Stripe allows you to set what events will trigger the webhook:
![set-webhook-events](https://tray.ai/documentation/images/help/troubleshooting/general-troubleshooting/XNmWGdNrOK7Ij0aYyaSli_set-webhook-events.png)

### 4 - monitor webhook events

Once you have a webhook set up, you can monitor its performance within your Stripe admin dashboard under the 'Webhooks' section:
![monitor-webhooks](https://tray.ai/documentation/images/help/troubleshooting/general-troubleshooting/7GGVFhq0wuMOjxzgFd01ry_monitor-webhooks.png)
These logs will let you know if Stripe attempted to send any webhooks and whether they were successful.
Please send this information to Tray when inquiring about the performance of your webhook-triggered workflows.

## Webhook blocked by CORS policy

### Problem

You are trying to ping your Tray webhooks via your browser, perhaps using the JavaScript fetch function.
However, the workflow is never triggered, and your browser receives an error containing a message similar to: 
`"Access ... has been blocked by CORS policy``*:*`` Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource ..."`

### Solution

First, please ensure you have the enabled the flag/checkbox *"Allow webhooks from browsers"* in your webhook connector, as instructed in our [docs](https://tray.ai/documentation/connectors/triggers/webhook-trigger/#enabling-cors)
As noted there, this flag should automatically add the following three headers to the webhook response:

* `Access-Control-Allow-Origin`
* `Access-Control-Allow-Headers`
* `Access-Control-Allow-Method`
  However, there are times when the \*origin \*has stricter requirements, and the error is still returned even though the flag is enabled. In these cases, you may need to **explicitly define Access-Control headers in your **[**trigger-reply**](https://tray.ai/documentation/connectors/core/trigger-event-reply/)**, as shown below:**
  ![cors-policy-trigger-reply](https://tray.ai/documentation/images/help/troubleshooting/general-troubleshooting/ZHKXZ6fk5L9J7hwFK6kX5_cors-policy-trigger-reply.png)
  Also note that to use the trigger-reply, your webhook will need to use an operation such as "Await workflow and respond"

## Loop ends before it's expected to

### Explanation

Tray's 'loop' connector offers 3 types of loops:

1. **Loop List** allows you to iterate through a list (aka array) of objects and will end when the list ends
   If your **Loop List** operation ends before you expect it to, check the length of the list. 
2. **Loop Object** allows you to iterate through the keys of an object. It ends when there are no more keys.
   If your **Loop Object** operation isn't working, check that it has an object with keys to iterate over.
3. The **Loop Forever** operation works similarly to a *while* loop in most programming languages; it needs an ending condition if you intend for it to stop.
   Please see the section on this page on breaking loops for more info.

## Problems with breaking loops

### Explanation

When using many complex loops, or loops using the [Loop Forever operation](https://tray.ai/documentation/connectors/core/loop/?docs_source=search\&docs_term=loop%20c#example-2---the-loop-forever-operation), you may need to forcibly break the loop to continue with the rest of the workflow execution.
However, breaking the correct loop (with [Break Loop](https://tray.ai/documentation/connectors/core/break-loop)) is important to ensure that the expected outcome is achieved.
You don’t, for example, want to select loop-3, which might break the main loop, instead of loop-1, which is the one that needs to be broken to allow the rest of the workflow to take place:
![break-loop-example](https://tray.ai/documentation/images/help/troubleshooting/general-troubleshooting/2k3HvpLUHkHUnoPgVIhLmM_break-loop-example.png)

###

## My error alert workflow doesn't seem to be working

### Explanation

First, verify that your workflow is set to trigger the error alerting workflow when there are errors.
Select **Settings** from the top menu:
![simple-error-handling-alert1](https://tray.ai/documentation/images/help/troubleshooting/general-troubleshooting/33tGztvMTe0srnr9Rl4XhA_simple-error-handling-alert1.png)
Then under \*\*Alerting Workflow \*\*select your newly created Alerting workflow from the dropdown and select **Submit:**
![simple-error-handling-set-alerting-workflow](https://tray.ai/documentation/images/help/troubleshooting/general-troubleshooting/3hFvygkvtbE53WibcRYzfq_simple-error-handling-set-alerting-workflow.png)

###

## Troubleshooting Solution Instances

### Important tips

When an end-user completes the configuration of a solution via the config wizard, a solution instance will be generated.
After this, you will be able to view both the **source workflows** in your project and the **End User workflow instances**, which store logs separately.
Our [docs](https://tray.io/documentation/embedded/troubleshooting/debugging/) explain how to find your End User workflow instances and logs. 
These debug logs\* \*are very important for troubleshooting and investigating, both for customers and Tray support.
As such, \*\*please do NOT **[**delete solution instances**](https://embedded-api-docs.tray.io/?version=latest#ba58ce3c-1e8d-41b9-aa62-8367837b2143)** you want to troubleshoot. \*\*We cannot restore deleted instances or their logs on our end either. 
You can find further information about our logs in our docs [here](https://tray.ai/documentation/platform/enterprise-core/logs-debugging/debug-logs#intro-to-logs)
If needed, you can also temporarily or permanently *disable* your instances as described [here](https://tray.io/documentation/embedded/building-integrations/enabling-instances/) so that they will not trigger while they are investigated. 

## Fixing step output

### Explanation

All connectors come with a default schema that is a prediction of a potential successful response object schema.
However, a response may come back with more granular data.
To reflect that detailed schema in your connector steps, you can press the **Use Output** button to update the schema of any given step. 
![use-output-example](https://tray.ai/documentation/images/help/troubleshooting/general-troubleshooting/67Vt9pex1Yd5RXmHjoZDx4_use-output-example.png)
Steps to Use Output:

1. Click on the Debug button to open the debug logs
2. Click on an execution log that successfully runs through your desired step
3. Click on the step log where you would like to update the data schema
4. Click the Use Output button

One thing to note is that you need to have an example execution where the schema is representative of the one that you want.
For instance, failed and success response objects may differ in structure.
Therefore, you need to run a **successful test execution** to get a sample of what the correct output should look like.

## Boolean Connector comparison not working

### Data types

When using the [**Boolean Condition connector**](https://tray.ai/documentation/connectors/core/boolean-condition/) to compare two values against each other, data types are an important consideration.
If you run an 'Equal to' comparison for:

* a value of *12000* (no " " mean it is a number)
  and
* a value of *“12000”* (" " means it is a string)
  The result will be false, as different data types are not comparable.
  One remedy here is to use the [Text Helpers](https://tray.ai/documentation/connectors/helper/text-helper) 'change type' operation.

### Boolean true / false checks

When checking for true / false values coming from previous steps, it is important to make sure that you select the data type as boolean:\
![set-boolean](https://tray.ai/documentation/images/help/troubleshooting/general-troubleshooting/1cXJhkhpwgg3kZwBPb1dx8_set-boolean.png)
If you leave the data type as string and type in "True" then it will not match what the previous connector has returned (unless it has actually sent "True" as a string!)

### Responding to a webhook

### Overview

When [sending a webhook to Tray](https://tray.ai/documentation/connectors/triggers/webhook-trigger/) that requires a response, you can utilise the [Trigger Event Reply](https://tray.ai/documentation/connectors/core/trigger-event-reply/) connector to send the response, and customise it if necessary. Some services may only need a 200 response, while others may need you to parrot a specific token back to them for security purposes, or include other parameters.

### Responding to webhooks

The inputs available in the **Trigger Event Reply** connector will depend on the **Webhook Trigger** operation selected. **Auto respond with HTTP 200** and **Validate and respond** both handle the reply at the time the webhook is received, and don’t require any other responses from the Trigger Event Reply connector. The connector’s inputs will be empty and give the option to add a property. 

### Customizing the response

If your service requires a response that contains parameters not covered by the auto respond or validate and respond options, you can set the Webhook Trigger to the\*\* Await workflow and respond\*\*  operation, after which, the trigger Event Reply connector will have **Status** and **Body** properties to add input to, and will have it will also have the\*\* Show advanced properties\*\* button available to adjust any headers if needed. 

### Slack response example

If you were to manually subscribe to Slack events in Tray, Slack initially sends a webhook to the specified endpoint URL, and that URL will need to parrot back a challenge value for verification. Here’s an example of how this could be configured:
![slack-webhook-response](https://tray.ai/documentation/images/help/troubleshooting/general-troubleshooting/2hDbZpZ9RNWCCZ4wNU288j_slack-webhook-response.png)
The webhook arrives with a challenge parameter in the body, which we can set the **Trigger Event Reply** connector to include in its body to respond back with. The 200 status is visible in the Output log to show this response was successful. 

## Date/Time Helper returning incorrect day of the week

### Problem

When using the 'Get day of week' operation of the Date & Time Helper, the previous day is returning - e.g. should return Monday but returns Sunday.

### Passing date without a timestamp

This error is caused when a date is passed into the connector using the format **MM/DD/YY or MMM DD YYYY** without a timestamp included:
![wrong-day-without-timestamp](https://tray.ai/documentation/images/help/troubleshooting/general-troubleshooting/5uSPGMsEwbOPmiBs628TvG_wrong-day-without-timestamp.png)

### Passing date with timestamp

This can be corrected by passing in the date including a timestamp. For example, in the format **MMMM DD YYYY HH:mm:ss:**
![correct-day-with-timestamp](https://tray.ai/documentation/images/help/troubleshooting/general-troubleshooting/6Wd4tz4qj4A6w8CSFVFngu_correct-day-with-timestamp.png)
