update_activity_schedule
Modify start and end times for Adobe Target activities to adjust campaign scheduling through API integration.
Instructions
Update the activity schedule in Adobe Target.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tenant | Yes | The tenant identifier. | |
| startsAt | Yes | The start time of the activity in ISO 8601 format. | |
| endsAt | Yes | The end time of the activity in ISO 8601 format. |
Implementation Reference
- The main handler function `executeFunction` that executes the tool logic by making a PUT request to the Adobe Target API to update the activity schedule with provided tenant, startsAt, and endsAt.const executeFunction = async ({ tenant, startsAt, endsAt }) => { const baseUrl = 'https://mc.adobe.io'; const token = process.env.ADOBE_API_KEY; const apiKey = process.env.ADOBE_API_KEY; try { // Construct the URL for the request const url = `${baseUrl}/${tenant}/target/activities/ab/168816/schedule`; // Set up headers for the request const headers = { 'Authorization': `Bearer ${token}`, 'X-Api-Key': apiKey, 'Content-Type': 'application/vnd.adobe.target.v1+json' }; // Prepare the body of the request const body = JSON.stringify({ startsAt, endsAt }); // Perform the fetch request const response = await fetch(url, { method: 'PUT', headers, body }); // Check if the response was successful if (!response.ok) { const errorData = await response.json(); throw new Error(errorData); } // Parse and return the response data const data = await response.json(); return data; } catch (error) { console.error('Error updating activity schedule:', error); return { error: 'An error occurred while updating the activity schedule.' }; } };
- The schema definition for the tool, including name, description, input parameters (tenant, startsAt, endsAt as strings), and required fields.type: 'function', function: { name: 'update_activity_schedule', description: 'Update the activity schedule in Adobe Target.', parameters: { type: 'object', properties: { tenant: { type: 'string', description: 'The tenant identifier.' }, startsAt: { type: 'string', description: 'The start time of the activity in ISO 8601 format.' }, endsAt: { type: 'string', description: 'The end time of the activity in ISO 8601 format.' } }, required: ['tenant', 'startsAt', 'endsAt'] } } }
- lib/tools.js:7-16 (registration)The `discoverTools` function registers the tool by dynamically importing the `apiTool` export from the tool's module path listed in toolPaths.export async function discoverTools() { const toolPromises = toolPaths.map(async (file) => { const module = await import(`../tools/${file}`); return { ...module.apiTool, path: file, }; }); return Promise.all(toolPromises); }
- tools/paths.js:1-5 (registration)The `toolPaths` array lists the path to this tool's module, enabling its discovery and registration in `discoverTools`.export const toolPaths = [ 'adobe/adobe-target-admin-ap-is/update-activity-state.js', 'adobe/adobe-target-admin-ap-is/update-activity-priority.js', 'adobe/adobe-target-admin-ap-is/update-activity-schedule.js' ];