Integrate Bolt.new AI with Expensify effortlessly. Follow our step-by-step guide to streamline expense management and gain AI-driven insights.
Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
package.json
in the root of your Bolt.new AI project.package.json
. This provides the necessary dependency (axios) for making HTTP requests to Expensify’s API:
{
"name": "bolt-expensify-integration",
"version": "1.0.0",
"dependencies": {
"axios": "^0.27.2"
},
"scripts": {
"start": "tsc && node dist/index.js"
}
}
expensifyClient.ts
. This module will handle all communications with Expensify’s API.expensifyClient.ts
. This sample code includes a function to create an expense in Expensify by posting the required payload:
import axios from 'axios';
const EXPENSIFYAPIURL = 'https://integrations.expensify.com/Integration-Server/ExpensifyIntegrations';
interface Expense {
merchant: string;
total: number;
currency: string;
// Add other expense properties as needed
}
interface ExpensifyCredentials {
partnerUserID: string;
partnerUserSecret: string;
}
// Replace these with your actual credentials
const credentials: ExpensifyCredentials = {
partnerUserID: 'yourpartneruser_id',
partnerUserSecret: 'yourpartneruser_secret'
};
export async function createExpense(expense: Expense): Promise {
try {
// Prepare the payload as required by Expensify’s API.
const payload = {
requestJobDescription: {
type: 'create',
credentials: credentials,
inputSettings: {
type: 'expense',
merchant: expense.merchant,
total: expense.total,
currency: expense.currency
// Map additional fields if necessary
}
}
};
// Make a POST request to Expensify
const response = await axios.post(EXPENSIFYAPIURL, payload, {
headers: {
'Content-Type': 'application/json'
}
});
return response.data;
} catch (error) {
// Handle and rethrow errors for further processing in your app
throw error;
}
}
index.ts
or app.ts
) within your Bolt.new AI project.createExpense
function from your newly created expensifyClient.ts
module:
import { createExpense } from './expensifyClient';
createExpense
wherever needed in your code. For a simple test, add the following code snippet in your main file to invoke the Expensify integration:
async function testExpensifyIntegration() {
const expense = {
merchant: 'Sample Merchant',
total: 100.50,
currency: 'USD'
// Include additional fields as required
};
try {
const result = await createExpense(expense);
console.log('Expense created successfully:', result);
} catch (error) {
console.error('Error creating expense:', error);
}
}
// Call the test function (you can eventually trigger this on a button click or other event)
testExpensifyIntegration();
package.json
, expensifyClient.ts
, and your main application file have been saved.testExpensifyIntegration
function will run and integrate with Expensify.
yourpartneruserid
and yourpartnerusersecret
in expensifyClient.ts
with your actual Expensify API credentials.Expense
interface and payload mapping in the createExpense
function according to your specific use-case and the Expensify API documentation.When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.