Questscript completion actions are useful for scenarios when you need more flexibility or want to integrate with a service not yet supported by Questmate or Zapier.
Completion Action Examples
Send Messages
Send a Slack messageSend a Discord messageSend an SMS messageSend an EmailExport data
Export data to AirtableExport data to Google SheetsExport data to NotionExport data to Zoho Creator Form RecordHow it works
- When editing a Quest, create a new Completion Action and change the type to "QuestScript" using the gear icon
- Enter your own custom Javascript code into the provided text box
- When a Quest run is submitted successfully your QuestScript will execute along with any other Completion Actions provided
Questscript Context
QuestScript code is executed within a limited Javascript environment.
Although limited, Questmate provides the following important functionality:
-
fetchis provided and available for use. See using the Fetch API - Allows scripts to make calls to other services on the internet (useful to call your own server to emulate webhook functionality)
- A
questmateclient is provided to make calls to the Questmate API (further documentation to come) - The
questobject contains a representation of the Quest, including data entered into items
Here is an example of a quest object:
Helpers
We wrote these little helper methods to make it easier to do things like creating a new sub quest and adding assignees to them and setting due dates.
Submit Parent Quest
If you have a quest that contains just sub quests inside (no other item types like text fields or multi-selects etc), then this one-liner makes it so you can submit the full quest when you complete the final sub quest. You don’t have to go back up a level to submit it.
// Useful if all items in the parent Quest are Subquests.
// Eliminates the need to submit the parent after submitting the last Subquest.
await quest.parent.submit()Redirect to URL
You can redirect your users on completion of a Quest to any URL as shown below where we Show a button with the text “Reset Form”. It will countdown from 5 seconds and then automatically redirect users to xkcd.com afterwards.
return {
actions: [
{
type: 'navigate',
linkText: 'Reset Form',
to: 'https://www.xkcd.com',
autoRedirectDelay: 5
}
]
}When making public Quests, it is often useful to be able to loop to the start of a new Quest on completion of a Quest. To do this, you can redirect to the public quest route, creating a new blank Quest to fill out, using the following example. Feel free to adjust the autoRedirectDelay or linkText to suit your needs.
const publicId = await quest.getPublicId();
return {
actions: [
{
type: 'navigate',
autoRedirectDelay: 5,
linkText: 'Reset Form',
to: {
screen: "PublicAssignment",
params: { id: publicId },
type: 'REPLACE',
}
}
]
}autoRedirectDelayis optional and will not automatically redirect users if not present.type: 'REPLACE'is also optional, if not specified the user will be able to go back to the previous Quest after navigating to the redirected location.
Copyright © Questmate Pty Ltd.