Looking for a simple way to generate discount codes in your Voiceflow assistant? We’ve built a ready-to-use function powered by our Shopify-based endpoint so you can do just that — no custom code required.
This function lets you create custom discount codes on the fly by plugging it into your flow, entering a few variables, and letting the app handle the rest.
How it works
When a user reaches a point in your Voiceflow assistant where you want to offer a discount (e.g., after submitting a support ticket or subscribing to your mailing list), this function sends the necessary data to our app endpoint, which uses the Shopify API to create the discount code in real-time.
Once set up, it only requires a few input values — and we’ve included sensible defaults for the more complex parameters like discount conditions and customer eligibility.
What it needs
To create a discount, the function expects the following parameters:
Parameter | Description |
---|---|
shopId | Your internal shop identifier (you’ll usually already have this in your flow). |
title | The title of the discount campaign (e.g., Support Ticket Compensation). |
code | The actual code customers will enter at checkout (e.g., THANKYOU10). |
customerGets (object) | Defines the discount. Defaults to 15% off everything, but you can customize it. |
startsAt | ISO 8601 timestamp (e.g., 2025-05-09T13:00:00Z ) for when the discount starts. |
endsAt | ISO 8601 timestamp for when the code expires. |
customerSelection (object) | Defines who can use the code. Defaults to all customers. |
minimumRequirement (object) | Sets a minimum subtotal or quantity to apply the discount. |
usageLimit (number) | Total number of times the code can be used. Leave blank for unlimited. |
appliesOncePerCustomer (boolean) | Set to true if each customer should only be able to use the code once. |
The code
value (the discount code shown to the customer) is automatically generated by AI using the current conversation topic, what the user has said and the percentage discounted. This helps ensure the code feels relevant and timely without needing to be manually crafted.
Defaults you can tweak
To make it easier, the customerGets
, customerSelection
, and minimumRequirement
fields are pre-filled with JSON templates directly in the workflow. You can adjust these as needed without writing complex logic.
Default configuration step included in the workflow
Use cases
Reward a customer who submits a support ticket
Create a code after a user completes a feedback survey
Offer discounts to subscribers or loyalty members
Things to keep in mind
Timestamps must be in ISO 8601 format (e.g.,
2025-05-09T14:00:00Z
)Shopify does not allow the same discount code to be created twice
If you want more complex discount rules (e.g., only on specific products), you’ll need to modify the
items
field insidecustomerGets
This function is built on top of Shopify’s native Discount Code API, so for more advanced configurations or technical details, we recommend reviewing the official Shopify documentation
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article