6. Developer Guide

The Developer Guide provides step-by-step instructions on how to integrate, extend, and customize the Ferdy Framework. This guide is tailored for developers building on top of Ferdy’s APIs and SDKs.

6.1 Getting Started

  1. Sign Up for API Access:

    • Visit the Ferdy Developer Portal.

    • Create a developer account and generate your API key.

  2. Set Up the Environment:

    • Ensure all prerequisites are installed (Python, Node.js, Docker, etc.).

    • Download the Ferdy SDK for your preferred language or platform.

  3. Basic Integration:

    • Use Ferdy APIs or SDKs to add core functionalities like conversational AI, task execution, or voice assistance to your app.


6.2 Ferdy SDK Integration

Web Integration

The Ferdy JavaScript SDK is designed for web applications. It provides pre-built widgets and customizable components.

Install SDK:

npm install ferdy-sdk

Basic Usage:

import { FerdyAPI } from 'ferdy-sdk';

const ferdy = new FerdyAPI({ apiKey: 'YOUR_API_KEY' });

async function getResponse(input) {

const response = await ferdy.converse({ userId: '12345', input });

console.log(response.response);

}

getResponse("What's the weather like today?");

Add Ferdy Widget:

import { FerdyWidget } from 'ferdy-sdk';

FerdyWidget.init({

apiKey: 'YOUR_API_KEY',

container: '#ferdy-chat',

});

Mobile Integration

The Ferdy SDK for Android and iOS supports native and hybrid applications.

Android:

Add the Ferdy SDK to your build.gradle: implementation 'com.ferdy.sdk:android:1.0.0'

  1. Use the Ferdy API:

FerdyClient client = new FerdyClient("YOUR_API_KEY");

String response = client.converse("What's my schedule today?");

Log.d("FerdyResponse", response);

  1. iOS:

Add Ferdy SDK using CocoaPods: pod 'FerdySDK', '~> 1.0'

  1. Use the Ferdy API:

swift let client = FerdyClient(apiKey: "YOUR_API_KEY")

client.converse(input: "What's my schedule today?") { response in

print(response)

}


6.3 Custom Workflows

Extending Task Execution: Developers can create custom workflows using the Task Orchestration Engine.

Define a New Workflow: {

"workflow_name": "custom_task",

"steps": [

{

"type": "API_CALL",

"endpoint": "https://example.com/task",

"method": "POST",

"data": {

"task_type": "email",

"email_body": "Hello, this is a test."

}

},

{

"type": "WAIT",

"duration": 5

},

{

"type": "NOTIFY",

"message": "Task completed successfully"

}

]

}

  1. Upload Workflow to Ferdy: Use the Ferdy CLI: ferdy-cli upload-workflow custom_task.json

  2. Execute Workflow via API:

POST /tasks/execute

Authorization: Bearer YOUR_API_KEY

Content-Type: application/json

Body: {

"workflow_name": "custom_task",

"parameters": {

"email": "user@example.com"

}

}


6.4 Customizing the UI

Ferdy provides customizable widgets for conversational AI and task management.

Default Widget:

<div id="ferdy-chat"></div>

<script src="https://cdn.ferdy.ai/sdk.js"></script>

<script>

FerdyWidget.init({

apiKey: 'YOUR_API_KEY',

container: '#ferdy-chat',

theme: 'dark',

});

</script>

Custom Styling:

#ferdy-chat {

border: 2px solid #000;

border-radius: 10px;

width: 400px;

height: 600px;

}


6.5 Testing and Debugging

  1. Enable Debug Mode: Pass debug: true in the SDK configuration to log API calls and errors.

  2. API Testing with Postman: Import the Ferdy API collection from the Developer Portal to test endpoints.

  3. Error Handling:

    • Common Errors:

      • 401 Unauthorized: Verify API key or token.

      • 400 Bad Request: Check request parameters.

Use the error object in API responses for details: {

"error": {

"code": 400,

"message": "Invalid input format."

}

}


6.6 Extending Ferdy with Plugins

Ferdy allows developers to build and integrate plugins for custom functionality.

  1. Plugin Structure:

Manifest File (plugin.json): {

"name": "My Custom Plugin",

"version": "1.0",

"entry_point": "index.js",

"permissions": ["task_execution", "data_storage"]

}

Entry Point (index.js): module.exports = {

executeTask: async (params) => {

console.log("Executing custom task with params:", params);

return { status: "success" };

}

};

  1. Register Plugin:

Upload the plugin via the Developer Portal or Ferdy CLI: ferdy-cli register-plugin my-plugin.zip

Invoke Plugin: Use the API to trigger the plugin: POST /plugins/my-custom-plugin/execute

Last updated