Integrating PayPal Agent Toolkit with Node.js: A Step-by-Step Tutorial

PayPal announces its Agent Toolkit in late April 2025, it is a remarkable step in this Agentic Era, allowing developers to integrate PayPal service or create payment workflow using natural language, making operations more intuitive.

As it is a beginning, I have tried it out with using NodeJS as the programming language and share it in form of a video tutorial:

Video url: https://youtu.be/SXngYSKAJQE

Github Repo: https://github.com/gordonchanhk/PayPal-Agent-Toolkit-Demo

I base on the example code in https://paypal.ai > Agent Toolkit > Docs – https://developer.paypal.com/tools/agent-toolkit/ and walk through the coding from ground. Here are couple highlights, which can act as hint to anyone who encountered trouble when trying out the Agent Toolkit:

  1. The example code doesn’t define getModel() and generateText() clearly. You shall need to define the function definition for getModel(), while generateText() is a AI SDK function.
  2. The Vercel AI SDK example code doesn’t config the Agent Toolkit to use Sandbox mode, you shall need to add 'context': {'sandbox': true} under the configuration node upon instantizing the Agent Toolkit instance.
  3. For some instance, you may need to use a custom AI endpoint and different API Key environment variable, use createOpenAI() instead of openai() allows you to pass apiKey and baseUrl.

My example is just showcasing the most base example. It uses terminal instead of building an interactive webpage with SPA. As a developer you shall define your way how to let user to enter the command / the prompt, and shows the response in a way you wish.

Look forward there are more showcase showing how to use PayPal Agent Toolkit.

To learn more about PayPal’s AI related info, check out https://paypal.ai

NodeJs In Action 聊天室範例 (使用Socket.io with v1.4.5)

最近想深化對 NodeJS 的基本認知,參考一本 NodeJS In Action 的書,當中有一個聊天室範例應用到 Socket 。依據範例做當然錯不了,但範例使用的 Socket.io 版本是舊版本  (0.9.6),當昇級至 1.x (比如1.4.5),運行時便有林林種種的問題。

因此我以範例作根本,以 Socket.io 1.4.5 的方法編寫了能運行的 Example:

https://github.com/gordonchanhk/NodeJsInActionChatRoomExample

nodejs-in-action-chatroom